Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: feat: support metrics log stream #28

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

airkei
Copy link
Contributor

@airkei airkei commented Jan 8, 2025

This PR should be merged after #27.

Why

https://tier4.atlassian.net/browse/RT4-13461
This PR support a new log group for metrics.
The reason why we switch the log group is that AWS subscription filter apply its filter based on the target log group level. Thus, by dividing log group, cloudwatch can apply the filter efficiently.
The log group name for metrics will be /aws/greengrass/edge/{self.region}/{self.account_id}/{self.profile}-edge-otaclient-metrics, log stream name will be same as the existing log stream name.

What

Change the existing data format in the queue and add LogGroupType field.
Once logging thread receives the log group type, handle the target log group based on it.

Test

Verified that the modified pytests are passed.

Comment on lines +240 to +247
@computed_field
@property
def aws_cloudwatch_metrics_log_group(self) -> str:
return (
f"/aws/greengrass/edge/{self.region}/"
f"{self.account_id}/{self.profile}-edge-otaclient-metrics"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new log group name for metrics

from queue import Queue
from typing import Literal, TypedDict

from typing_extensions import NotRequired, TypeAlias

LogsQueue: TypeAlias = "Queue[tuple[str, LogMessage]]"
LogsQueue: TypeAlias = "Queue[tuple[LogGroupType, str, LogMessage]]"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the data format of the queue.

@@ -76,10 +76,13 @@ def generate_random_msgs(
) -> list[tuple[str, LogMessage]]:
_res: list[tuple[str, LogMessage]] = []
for _ in range(msg_num):
_ecu, *_ = random.sample(ecus_list, 1)
_ecu_id, *_ = random.sample(ecus_list, 1)
_log_group_type = random.choice(list(LogGroupType))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test both log group type.

@airkei airkei changed the title feat: support metrics log stream DNM: feat: support metrics log stream Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant