Repository URL to install this package:
|
Version:
0.32.0 ▾
|
from datadog.dogstatsd import DogStatsd
import os
# default values
DEFAULT_HOST = 'localhost'
DEFAULT_PORT = 8125
DEFAULT_PREFIX = None
def get_django_statsd():
"""Configure the client using django settings"""
host = getattr(settings, 'STATSD_HOST', DEFAULT_HOST)
port = int(getattr(settings, 'STATSD_PORT', DEFAULT_PORT))
prefix = getattr(settings, 'STATSD_PREFIX', DEFAULT_PREFIX)
return DogStatsd(host=host, port=port, namespace=prefix)
def get_env_statsd():
"""Configure the client using env vars"""
host = os.getenv('STATSD_HOST', DEFAULT_HOST)
port = int(os.getenv('STATSD_PORT', DEFAULT_PORT))
prefix = os.getenv('STATSD_PREFIX', DEFAULT_PREFIX)
return DogStatsd(host=host, port=port, namespace=prefix)
# support 2 types of pre-configuration of the statsd client
try:
from django.conf import settings
statsd = get_django_statsd()
except ImportError:
statsd = get_env_statsd()