Browse Source

Pyramid requests metric: add logged_in label

This will allow me to keep track of how much of the traffic is
logged-out vs. logged-in.
merge-requests/55/head
Deimos 6 years ago
parent
commit
ff392aba9e
  1. 3
      tildes/tildes/__init__.py

3
tildes/tildes/__init__.py

@ -111,7 +111,7 @@ def metrics_tween_factory(handler: Callable, registry: Registry) -> Callable:
request_histogram = Histogram( request_histogram = Histogram(
"tildes_pyramid_requests_seconds", "tildes_pyramid_requests_seconds",
"Request processing times", "Request processing times",
labelnames=["route", "status_code", "method"],
labelnames=["route", "status_code", "method", "logged_in"],
) )
def metrics_tween(request: Request) -> Response: def metrics_tween(request: Request) -> Response:
@ -128,6 +128,7 @@ def metrics_tween_factory(handler: Callable, registry: Registry) -> Callable:
route=request.matched_route.name, route=request.matched_route.name,
status_code=response.status_code, status_code=response.status_code,
method=request.method, method=request.method,
logged_in=str(bool(request.user)).lower(),
).observe(duration) ).observe(duration)
return response return response

Loading…
Cancel
Save