Skip to content

Commit

Permalink
Merge pull request #14 from mobidata-bw/metric-fixes
Browse files Browse the repository at this point in the history
metric fixes
  • Loading branch information
the-infinity authored Oct 27, 2023
2 parents 0190b3c + 83b262d commit 17060aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions webapp/prometheus_api/prometheus_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def get_metrics(self) -> str:
type=MetricType.gauge,
identifier='app_park_api_source_last_realtime_update',
)
source_static_parking_site_error_count = Metrics(
help='Parking site static error count by source',
source_static_parking_site_errors = Metrics(
help='Parking site static errors by source',
type=MetricType.gauge,
identifier='app_static_park_api_source_error_count',
identifier='app_static_park_api_source_errors',
)
source_realtime_parking_site_error_count = Metrics(
help='Parking site realtime error count by source',
source_realtime_parking_site_errors = Metrics(
help='Parking site realtime error by source',
type=MetricType.gauge,
identifier='app_realtime_park_api_source_error_count',
identifier='app_realtime_park_api_source_errors',
)
failed_sources = Metrics(
help='Completely failed sources',
Expand All @@ -79,13 +79,13 @@ def get_metrics(self) -> str:
value=int((datetime.now(tz=timezone.utc) - source.realtime_data_updated_at).total_seconds()),
)
)
source_static_parking_site_error_count.metrics.append(
source_static_parking_site_errors.metrics.append(
SourceMetric(
source=source.uid,
value=source.static_parking_site_error_count,
)
)
source_realtime_parking_site_error_count.metrics.append(
source_realtime_parking_site_errors.metrics.append(
SourceMetric(
source=source.uid,
value=source.realtime_parking_site_error_count,
Expand All @@ -102,8 +102,8 @@ def get_metrics(self) -> str:
metrics = (
last_static_update_metrics.to_metrics()
+ last_realtime_update_metrics.to_metrics()
+ source_static_parking_site_error_count.to_metrics()
+ source_realtime_parking_site_error_count.to_metrics()
+ source_static_parking_site_errors.to_metrics()
+ source_realtime_parking_site_errors.to_metrics()
+ failed_sources.to_metrics()
)

Expand Down
2 changes: 1 addition & 1 deletion webapp/prometheus_api/prometheus_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BaseMetric:

def to_metric(self, identifier: str) -> str:
data = asdict(self)
label_list = [f'{key}:"{value}"' for key, value in data.items() if key != 'value']
label_list = [f'{key}="{value}"' for key, value in data.items() if key != 'value']
return f'{identifier}{{{",".join(label_list)}}} {self.value}'


Expand Down

0 comments on commit 17060aa

Please sign in to comment.