startup.py 582 Bytes
Newer Older
1
from django.conf import settings
2 3 4

from dogapi import dog_stats_api, dog_http_api

5 6 7 8 9

def run():
    """
    Initialize connection to datadog during django startup.

10 11 12
    Can be configured using a dictionary named DATADOG in the django
    project settings.

13
    """
14 15 16 17 18 19 20 21 22 23 24 25

    # By default use the statsd agent
    options = {'statsd': True}

    if hasattr(settings, 'DATADOG'):
        options.update(settings.DATADOG)

    # Not all arguments are documented.
    # Look at the source code for details.
    dog_stats_api.start(**options)

    dog_http_api.api_key = options.get('api_key')