Skip to content

Commit

Permalink
Add a log on failing route
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 12, 2024
1 parent f438097 commit 8be9dd2
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 8be9dd2

Please sign in to comment.