Browse Source

Add temporary metric for theme cookie tween

I'm going to make some changes to this tween, so the metric will help me
keep an eye on how often it's triggering, which should make it easier to
be sure the changes are working as expected.
merge-requests/85/head
Deimos 5 years ago
parent
commit
df97cc08b9
  1. 3
      tildes/tildes/metrics.py
  2. 4
      tildes/tildes/tweens.py

3
tildes/tildes/metrics.py

@ -31,6 +31,9 @@ _COUNTERS = {
"login_failures": Counter("tildes_login_failures_total", "Login Failures"),
"messages": Counter("tildes_messages_total", "Messages", labelnames=["type"]),
"registrations": Counter("tildes_registrations_total", "User Registrations"),
"theme_cookie_tween_sets": Counter(
"tildes_theme_cookie_tween_sets_total", "Theme Cookies Set by Tween"
),
"topics": Counter("tildes_topics_total", "Topics", labelnames=["type"]),
"subscriptions": Counter("tildes_subscriptions_total", "Subscriptions"),
"unsubscriptions": Counter("tildes_unsubscriptions_total", "Unsubscriptions"),

4
tildes/tildes/tweens.py

@ -11,6 +11,8 @@ from pyramid.registry import Registry
from pyramid.request import Request
from pyramid.response import Response
from tildes.metrics import incr_counter
def http_method_tween_factory(handler: Callable, registry: Registry) -> Callable:
# pylint: disable=unused-argument
@ -95,6 +97,8 @@ def theme_cookie_tween_factory(handler: Callable, registry: Registry) -> Callabl
secure=True,
domain="." + request.domain,
)
incr_counter("theme_cookie_tween_sets")
return response
return theme_cookie_tween
Loading…
Cancel
Save