From df97cc08b9fe878d3b46635dbae7ba67a495d014 Mon Sep 17 00:00:00 2001 From: Deimos Date: Mon, 9 Sep 2019 19:51:15 -0600 Subject: [PATCH] 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. --- tildes/tildes/metrics.py | 3 +++ tildes/tildes/tweens.py | 4 ++++ 2 files changed, 7 insertions(+) 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