diff --git a/spicedb/datadog_checks/__init__.py b/spicedb/datadog_checks/__init__.py index 287a197fac..0d1f7edf5d 100644 --- a/spicedb/datadog_checks/__init__.py +++ b/spicedb/datadog_checks/__init__.py @@ -1,2 +1 @@ - __path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore diff --git a/spicedb/datadog_checks/spicedb/__init__.py b/spicedb/datadog_checks/spicedb/__init__.py index 80f41d0ce4..359d395907 100644 --- a/spicedb/datadog_checks/spicedb/__init__.py +++ b/spicedb/datadog_checks/spicedb/__init__.py @@ -1,4 +1,3 @@ - from .__about__ import __version__ from .check import SpicedbCheck diff --git a/spicedb/datadog_checks/spicedb/metrics.py b/spicedb/datadog_checks/spicedb/metrics.py index 8e3f16e306..e2854572f4 100644 --- a/spicedb/datadog_checks/spicedb/metrics.py +++ b/spicedb/datadog_checks/spicedb/metrics.py @@ -1,6 +1,7 @@ """ A definition of the metrics publicly exposed in SpiceDB. """ + from itertools import chain # For the metrics, the key is the SpiceDB name and the @@ -57,7 +58,8 @@ "spicedb_services_dispatches": "application.services.dispatches", # gRPC histogram metrics "grpc_server_handling_seconds": "grpc.server.handling_seconds", - } +} + def construct_counter_metric_config(raw: str, dotted: str): """ @@ -68,15 +70,19 @@ def construct_counter_metric_config(raw: str, dotted: str): # counter metrics, so we remove it return {raw.removesuffix("_total"): {"name": dotted, "type": "counter"}} + def construct_gauge_metric_config(raw: str, dotted: str): return {raw: {"name": dotted, "type": "gauge"}} + def construct_histogram_metric_config(raw: str, dotted: str): return {raw: {"name": dotted, "type": "histogram"}} -METRICS_CONFIG: list[dict[str, dict[str, str]]] = list(chain( - (construct_counter_metric_config(raw, dotted) for raw, dotted in COUNTER_METRICS.items()), - (construct_gauge_metric_config(raw, dotted) for raw, dotted in GAUGE_METRICS.items()), - (construct_histogram_metric_config(raw, dotted) for raw, dotted in HISTOGRAM_METRICS.items()), - )) +METRICS_CONFIG: list[dict[str, dict[str, str]]] = list( + chain( + (construct_counter_metric_config(raw, dotted) for raw, dotted in COUNTER_METRICS.items()), + (construct_gauge_metric_config(raw, dotted) for raw, dotted in GAUGE_METRICS.items()), + (construct_histogram_metric_config(raw, dotted) for raw, dotted in HISTOGRAM_METRICS.items()), + ) +) diff --git a/spicedb/tests/test_e2e.py b/spicedb/tests/test_e2e.py index 5b21fd16f3..3680aa3732 100644 --- a/spicedb/tests/test_e2e.py +++ b/spicedb/tests/test_e2e.py @@ -1,5 +1,6 @@ from .util import get_expected_non_histogram_metrics, get_expected_histogram_metrics + def test_metrics(dd_agent_check, instance): aggregator = dd_agent_check(instance, rate=True) diff --git a/spicedb/tests/util.py b/spicedb/tests/util.py index 7b394d7cf6..f8d2cde604 100644 --- a/spicedb/tests/util.py +++ b/spicedb/tests/util.py @@ -7,16 +7,21 @@ HOST = get_docker_hostname() PORT = "9090" + def get_expected_non_histogram_metrics(): - return list(chain( + return list( + chain( # We add a .count suffix because datadog is going to append it before it's sent. (f"{datadog_name}.count" for datadog_name in COUNTER_METRICS.values()), # We pass through the other metrics straight. GAUGE_METRICS.values(), -)) + ) + ) + def get_expected_histogram_metrics(): return HISTOGRAM_METRICS.values() + def get_fixture_path(filename): return os.path.join(get_here(), "fixtures", filename)