-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor code_owner code from edx-dajango-utils
Initial rollout of moving code_owner monitoring code from edx-django-utils to this plugin. - Adds near duplicate of code owner middleware from edx-django-utils. - Adds code owner for celery using Datadog span processing of celery.run spans. - Uses temporary span tags names using `_2`, like `code_owner_2`, for rollout and comparison with the original span tags. See #784
- Loading branch information
Showing
23 changed files
with
465 additions
and
526 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Datadog Monitoring | ||
################### | ||
|
||
When installed in the LMS as a plugin app, the ``datadog_monitoring`` app adds additional monitoring. | ||
|
||
This is where our code_owner_2 monitoring code lives, for example. |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
App for 2U-specific edx-platform Datadog monitoring. | ||
""" | ||
|
||
import logging | ||
|
||
from django.apps import AppConfig | ||
|
||
from .code_owner.utils import get_code_owner_from_module | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class DatadogMonitoringSpanProcessor: | ||
"""Datadog span processor that adds custom monitoring (e.g. code owner tags).""" | ||
|
||
def on_span_start(self, span): | ||
if not span or not getattr(span, 'name') or not getattr(span, 'resource'): | ||
return | ||
|
||
if span.name == 'celery.run': | ||
# We can use this for celery spans, because the resource name is more predictable | ||
# and available from the start. For django requests, we'll instead continue to use | ||
# django middleware for setting code owner. | ||
get_code_owner_from_module(span.resource) | ||
|
||
def on_span_finish(self, span): | ||
pass | ||
|
||
def shutdown(self, _timeout): | ||
pass | ||
|
||
|
||
class DatadogMonitoring(AppConfig): | ||
""" | ||
Django application to handle 2U-specific Datadog monitoring. | ||
""" | ||
name = 'edx_arch_experiments.datadog_monitoring' | ||
|
||
# Mark this as a plugin app | ||
plugin_app = {} | ||
|
||
def ready(self): | ||
try: | ||
from ddtrace import tracer # pylint: disable=import-outside-toplevel | ||
# QUESTION: Do we want to publish a base constraint that avoids DD major changes without first testing them? | ||
tracer._span_processors.append(DatadogMonitoringSpanProcessor()) # pylint: disable=protected-access | ||
log.info("Attached DatadogMonitoringSpanProcessor") | ||
except ImportError: | ||
log.warning( | ||
"Unable to attach DatadogMonitoringSpanProcessor" | ||
" -- ddtrace module not found." | ||
) |
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
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
Oops, something went wrong.