-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstrumentator.py
More file actions
36 lines (31 loc) · 1.05 KB
/
instrumentator.py
File metadata and controls
36 lines (31 loc) · 1.05 KB
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
from prometheus_fastapi_instrumentator import Instrumentator, metrics
def init_instrumentator(app):
Instrumentator().instrument(app).expose(app)
instrumentator = Instrumentator(
should_group_status_codes=False,
should_ignore_untemplated=True,
should_respect_env_var=True,
should_instrument_requests_inprogress=True,
excluded_handlers=[".*admin.*", "/metrics"],
env_var_name="ENABLE_METRICS",
inprogress_name="inprogress",
inprogress_labels=True,
)
instrumentator.add(
metrics.request_size(
should_include_handler=True,
should_include_method=False,
should_include_status=True,
metric_namespace="a",
metric_subsystem="b",
)
).add(
metrics.response_size(
should_include_handler=True,
should_include_method=False,
should_include_status=True,
metric_namespace="namespace",
metric_subsystem="subsystem",
)
)
return instrumentator