Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
dulmandakh committed Dec 7, 2024
1 parent 0f63265 commit 9168819
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions django_prometheus/db/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@ class CursorWrapper(cursor_class):

def execute(self, *args, **kwargs):
execute_total.labels(alias, vendor).inc()
with query_duration_seconds.labels(**labels).time(), ExceptionCounterByType(
errors_total, extra_labels=labels
with (
query_duration_seconds.labels(**labels).time(),
ExceptionCounterByType(errors_total, extra_labels=labels),
):
return super().execute(*args, **kwargs)

def executemany(self, query, param_list, *args, **kwargs):
execute_total.labels(alias, vendor).inc(len(param_list))
execute_many_total.labels(alias, vendor).inc(len(param_list))
with query_duration_seconds.labels(**labels).time(), ExceptionCounterByType(
errors_total, extra_labels=labels
with (
query_duration_seconds.labels(**labels).time(),
ExceptionCounterByType(errors_total, extra_labels=labels),
):
return super().executemany(query, param_list, *args, **kwargs)

Expand Down
3 changes: 2 additions & 1 deletion django_prometheus/tests/end2end/testapp/test_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

_SUPPORTED_CACHES = ["memcached.PyLibMCCache", "memcached.PyMemcacheCache", "filebased", "locmem", "native_redis"]


class TestCachesMetrics:
"""Test django_prometheus.caches metrics."""

Expand Down Expand Up @@ -33,7 +34,7 @@ def test_counters(self, supported_cache):

def test_redis_cache_fail(self):
# Note: test use fake service config (like if server was stopped)
supported_cache = "native_redis"
supported_cache = "redis"
total_before = get_metric("django_cache_get_total", backend=supported_cache) or 0
fail_before = get_metric("django_cache_get_fail_total", backend=supported_cache) or 0
hit_before = get_metric("django_cache_get_hits_total", backend=supported_cache) or 0
Expand Down

0 comments on commit 9168819

Please sign in to comment.