diff --git a/tildes/tildes/metrics.py b/tildes/tildes/metrics.py index 87184ae..71adf54 100644 --- a/tildes/tildes/metrics.py +++ b/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"), diff --git a/tildes/tildes/tweens.py b/tildes/tildes/tweens.py index 378598c..c49e8e1 100644 --- a/tildes/tildes/tweens.py +++ b/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