Skip to content

Commit

Permalink
Merge pull request #2528 from camptocamp/backport/2524-to-master
Browse files Browse the repository at this point in the history
[Backport master] Add a log on failing route
  • Loading branch information
sbrunner authored Nov 12, 2024
2 parents a02e308 + 65645f1 commit 08ef149
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions c2cwsgiutils/stats_pyramid/_pyramid_spy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import time
from typing import Callable, Optional

Expand All @@ -9,6 +10,8 @@

from c2cwsgiutils import prometheus

_LOG = logging.getLogger(__name__)

_PROMETHEUS_PYRAMID_ROUTES_SUMMARY = prometheus_client.Summary(
prometheus.build_metric_name("pyramid_routes"),
"Pyramid routes",
Expand Down Expand Up @@ -61,6 +64,15 @@ def finished_cb(request: pyramid.request.Request) -> None:
name = request.matched_route.name
if kind == "route":
_add_server_metric(request, "route", description=name)
if status >= 500:
_LOG.warning(
"Request %s %s %s route %s return status %s",
request.method,
request.path,
kind,
name,
status,
)
measure.labels(
method=request.method, route=name, status=status, group=str(status // 100 * 100)
).observe(time.process_time() - start)
Expand Down

0 comments on commit 08ef149

Please sign in to comment.