Last active
January 18, 2019 14:06
-
-
Save cypreess/dfd8814dd8a242cfbd27b10fd8753e71 to your computer and use it in GitHub Desktop.
metrics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statsd | |
from django.conf import settings | |
statsd_client = statsd.StatsClient( | |
settings.METRICS_STATSD_HOST, settings.METRICS_STATSD_PORT | |
) | |
def metric_counter(key, value=1): | |
if settings.METRICS_ENABLED: | |
statsd_client.incr(key, value) | |
def metric_counter_decrement(key, value=1): | |
if settings.METRICS_ENABLED: | |
statsd_client.decr(key, value) | |
def metric_timing(key, value): | |
if settings.METRICS_ENABLED: | |
statsd_client.timing(key, value) | |
def metric_gauge(key, value): | |
if settings.METRICS_ENABLED: | |
statsd_client.gauge(key, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment