Skip to content

Commit

Permalink
Fix for trying to access session after closing in /metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Verga <[email protected]>
  • Loading branch information
mattiaverga committed Dec 11, 2024
1 parent 7aa3e1b commit 3fd2556
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bodhi-server/bodhi/server/services/metrics_tween.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ def histo_tween_factory(handler, registry):
Collects metrics on individual requests.
"""
def tween(request):
r_patt = get_pattern(request)
r_meth = request.method
gauge_labels = {
'method': request.method,
'path_info_pattern': get_pattern(request),
'method': r_meth,
'path_info_pattern': r_patt,
}
pyramid_request_ingress.labels(**gauge_labels).inc()

Expand All @@ -60,8 +62,8 @@ def tween(request):
finally:
duration = time() - start
pyramid_request.labels(
method=request.method,
path_info_pattern=get_pattern(request),
method=r_meth,
path_info_pattern=r_patt,
status=status,
).observe(duration)
pyramid_request_ingress.labels(**gauge_labels).dec()
Expand Down

0 comments on commit 3fd2556

Please sign in to comment.