Skip to content

Commit

Permalink
type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodonato committed Dec 13, 2024
1 parent 15632f1 commit 20f9df4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions query_exporter/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Configuration management functions."""

from collections import defaultdict
from collections.abc import Mapping
from collections.abc import Iterable, Mapping
from dataclasses import dataclass
from functools import reduce
from importlib import resources
Expand Down Expand Up @@ -245,7 +245,7 @@ def _get_query_metrics(
) -> list[QueryMetric]:
"""Return QueryMetrics for a query."""

def _metric_labels(labels: list[str]) -> list[str]:
def _metric_labels(labels: Iterable[str]) -> list[str]:
return sorted(set(labels) - extra_labels)

return [
Expand Down
4 changes: 2 additions & 2 deletions query_exporter/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ def _update_metric(
value = 0.0
elif isinstance(value, Decimal):
value = float(value)
metric = self._config.metrics[name]
metric_config = self._config.metrics[name]
all_labels = {DATABASE_LABEL: database.config.name}
all_labels.update(database.config.labels)
if labels:
all_labels.update(labels)
labels_string = ",".join(
f'{label}="{value}"' for label, value in sorted(all_labels.items())
)
method = self._get_metric_method(metric)
method = self._get_metric_method(metric_config)
self._logger.debug(
f'updating metric "{name}" {method} {value} {{{labels_string}}}'
)
Expand Down
2 changes: 1 addition & 1 deletion query_exporter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .loop import QueryLoop


class QueryExporterScript(PrometheusExporterScript): # type: ignore
class QueryExporterScript(PrometheusExporterScript):
"""Periodically run database queries and export results to Prometheus."""

name = "query-exporter"
Expand Down

0 comments on commit 20f9df4

Please sign in to comment.