Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
tstirrat15 committed Dec 18, 2024
1 parent 1867002 commit 7df9e90
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
1 change: 0 additions & 1 deletion spicedb/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
1 change: 0 additions & 1 deletion spicedb/datadog_checks/spicedb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from .__about__ import __version__
from .check import SpicedbCheck

Expand Down
18 changes: 12 additions & 6 deletions spicedb/datadog_checks/spicedb/metrics.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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()),
)
)
1 change: 1 addition & 0 deletions spicedb/tests/test_e2e.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
9 changes: 7 additions & 2 deletions spicedb/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 7df9e90

Please sign in to comment.