From ce0a75e0a7c8425817d616a8999294fe0f8fa14b Mon Sep 17 00:00:00 2001 From: Robert Raposa Date: Thu, 24 Oct 2024 10:11:31 -0400 Subject: [PATCH] fixup! fix some quality failures --- edx_arch_experiments/datadog_monitoring/apps.py | 7 ++++++- edx_arch_experiments/datadog_monitoring/tests/test_app.py | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/edx_arch_experiments/datadog_monitoring/apps.py b/edx_arch_experiments/datadog_monitoring/apps.py index 6aafb76..f6f2952 100644 --- a/edx_arch_experiments/datadog_monitoring/apps.py +++ b/edx_arch_experiments/datadog_monitoring/apps.py @@ -15,7 +15,12 @@ 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'): + """ + Adds custom monitoring at span creation time. + + Specifically, adds code owner span tag for celery run spans. + """ + if not span or not getattr(span, 'name') or not getattr(span, 'resource'): return if span.name == 'celery.run': diff --git a/edx_arch_experiments/datadog_monitoring/tests/test_app.py b/edx_arch_experiments/datadog_monitoring/tests/test_app.py index 3688037..c2fe03d 100644 --- a/edx_arch_experiments/datadog_monitoring/tests/test_app.py +++ b/edx_arch_experiments/datadog_monitoring/tests/test_app.py @@ -1,10 +1,10 @@ """ Tests for plugin app. """ -from unittest.mock import call, patch +from unittest.mock import patch from ddtrace import tracer -from django.test import TestCase, override_settings +from django.test import TestCase from .. import apps @@ -22,7 +22,9 @@ class TestDatadogMonitoringApp(TestCase): def setUp(self): # Remove custom span processor from previous runs. # pylint: disable=protected-access - tracer._span_processors = [sp for sp in tracer._span_processors if type(sp).__name__ != 'DatadogMonitoringSpanProcessor'] + tracer._span_processors = [ + sp for sp in tracer._span_processors if type(sp).__name__ != 'DatadogMonitoringSpanProcessor' + ] def test_add_processor(self): def initialize():