File: metrics.py

package info (click to toggle)
django-prometheus 2.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 568 kB
  • sloc: python: 1,776; sh: 5; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from prometheus_client import Counter, Histogram

from django_prometheus.conf import NAMESPACE, PROMETHEUS_LATENCY_BUCKETS

connections_total = Counter(
    "django_db_new_connections_total",
    "Counter of created connections by database and by vendor.",
    ["alias", "vendor"],
    namespace=NAMESPACE,
)

connection_errors_total = Counter(
    "django_db_new_connection_errors_total",
    "Counter of connection failures by database and by vendor.",
    ["alias", "vendor"],
    namespace=NAMESPACE,
)

execute_total = Counter(
    "django_db_execute_total",
    ("Counter of executed statements by database and by vendor, including bulk executions."),
    ["alias", "vendor"],
    namespace=NAMESPACE,
)


execute_many_total = Counter(
    "django_db_execute_many_total",
    ("Counter of executed statements in bulk operations by database and by vendor."),
    ["alias", "vendor"],
    namespace=NAMESPACE,
)


errors_total = Counter(
    "django_db_errors_total",
    ("Counter of execution errors by database, vendor and exception type."),
    ["alias", "vendor", "type"],
    namespace=NAMESPACE,
)

query_duration_seconds = Histogram(
    "django_db_query_duration_seconds",
    ("Histogram of query duration by database and vendor."),
    ["alias", "vendor"],
    buckets=PROMETHEUS_LATENCY_BUCKETS,
    namespace=NAMESPACE,
)