Move datadog startup.py over to AppConfig::ready
This commit is contained in:
@@ -963,7 +963,7 @@ INSTALLED_APPS = [
|
|||||||
'eventtracking.django.apps.EventTrackingConfig',
|
'eventtracking.django.apps.EventTrackingConfig',
|
||||||
|
|
||||||
# Monitoring
|
# Monitoring
|
||||||
'openedx.core.djangoapps.datadog',
|
'openedx.core.djangoapps.datadog.apps.DatadogConfig',
|
||||||
|
|
||||||
# For asset pipelining
|
# For asset pipelining
|
||||||
'edxmako.apps.EdxMakoConfig',
|
'edxmako.apps.EdxMakoConfig',
|
||||||
|
|||||||
@@ -2158,7 +2158,7 @@ INSTALLED_APPS = [
|
|||||||
'splash',
|
'splash',
|
||||||
|
|
||||||
# Monitoring
|
# Monitoring
|
||||||
'openedx.core.djangoapps.datadog',
|
'openedx.core.djangoapps.datadog.apps.DatadogConfig',
|
||||||
|
|
||||||
# User API
|
# User API
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
|
|||||||
32
openedx/core/djangoapps/datadog/apps.py
Normal file
32
openedx/core/djangoapps/datadog/apps.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
"""
|
||||||
|
Configuration for datadog Django app
|
||||||
|
"""
|
||||||
|
from django.apps import AppConfig
|
||||||
|
from django.conf import settings
|
||||||
|
from dogapi import dog_http_api, dog_stats_api
|
||||||
|
|
||||||
|
|
||||||
|
class DatadogConfig(AppConfig):
|
||||||
|
"""
|
||||||
|
Configuration class for datadog Django app
|
||||||
|
"""
|
||||||
|
name = 'openedx.core.djangoapps.datadog'
|
||||||
|
verbose_name = "Datadog"
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
"""
|
||||||
|
Initialize connection to datadog during django startup.
|
||||||
|
|
||||||
|
Configure using DATADOG dictionary in the django project settings.
|
||||||
|
"""
|
||||||
|
# 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')
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
"""
|
|
||||||
Start up initialization of datadog.
|
|
||||||
"""
|
|
||||||
from django.conf import settings
|
|
||||||
from dogapi import dog_http_api, dog_stats_api
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
|
||||||
"""
|
|
||||||
Initialize connection to datadog during django startup.
|
|
||||||
|
|
||||||
Can be configured using a dictionary named DATADOG in the django
|
|
||||||
project settings.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# 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')
|
|
||||||
Reference in New Issue
Block a user