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.
This commit is contained in:
Deimos
2019-09-09 19:51:15 -06:00
parent bdc2323680
commit df97cc08b9
2 changed files with 7 additions and 0 deletions

View File

@@ -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"),

View File

@@ -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