File tree 2 files changed +8
-3
lines changed 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 17
17
from prometheus import prometheus_metrics
18
18
19
19
@Request .application
20
- @prometheus_metrics ('/metrics' )
20
+ @prometheus_metrics ('/metrics' , ( '/' , '/healthz' ) )
21
21
def application (request ):
22
22
23
23
if request .method == 'GET' :
Original file line number Diff line number Diff line change 14
14
['method' , 'endpoint' , 'code' ]
15
15
)
16
16
17
- def prometheus_metrics (metrics_path ):
17
+ def prometheus_metrics (metrics_path , monitor_endpoints ):
18
+ monitor_endpoints = set ([metrics_path ] + list (monitor_endpoints ))
18
19
def prometheus_metrics_decorator (f ):
19
20
@wraps (f )
20
21
def f_wrapper (request ):
21
- start_time = time ()
22
+ # Create metrics only for specific endpoints to not flood
23
+ # prometheus with dynamically created labels.
24
+ if request .path not in monitor_endpoints :
25
+ return f (request )
22
26
27
+ start_time = time ()
23
28
if request .method == 'GET' and request .path == metrics_path :
24
29
status = 200
25
30
REQUEST_LATENCIES .labels (
You can’t perform that action at this time.
0 commit comments