Skip to content

Commit

Permalink
Fix cache update and metric constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferril committed Apr 25, 2024
1 parent c0b21e5 commit ff6af8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion engine/apps/metrics_exporter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class AlertGroupsResponseTimeMetricsDict(typing.TypedDict):
org_id: int
slug: str
id: int
response_time: list
services: typing.Dict[str, list]


Expand Down
5 changes: 3 additions & 2 deletions engine/apps/metrics_exporter/metrics_cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def get_default_states_diff_dict():

@staticmethod
def update_integration_states_diff(metrics_dict, integration_id, service_name, previous_state=None, new_state=None):
state_per_service = {service_name: MetricsCacheManager.get_default_states_diff_dict()}
metrics_dict.setdefault(integration_id, state_per_service)
state_per_service = metrics_dict.setdefault(
integration_id, {service_name: MetricsCacheManager.get_default_states_diff_dict()}
)
if previous_state:
state_value = previous_state
state_per_service[service_name]["previous_states"][state_value] += 1
Expand Down

0 comments on commit ff6af8b

Please sign in to comment.