startup.py 625 Bytes
Newer Older
1 2 3
"""
Start up initialization of datadog.
"""
4
from django.conf import settings
5
from dogapi import dog_http_api, dog_stats_api
6

7 8 9 10 11

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

12 13 14
    Can be configured using a dictionary named DATADOG in the django
    project settings.

15
    """
16 17 18 19 20 21 22 23 24 25 26 27

    # 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')