From a20be8040de7c214f00fd90967fabea3f06d18dc Mon Sep 17 00:00:00 2001 From: quinna-h Date: Mon, 30 Dec 2024 17:28:59 -0500 Subject: [PATCH] add test --- tests/contrib/django/test_django.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/contrib/django/test_django.py b/tests/contrib/django/test_django.py index cf44ed6bcdd..93613323162 100644 --- a/tests/contrib/django/test_django.py +++ b/tests/contrib/django/test_django.py @@ -30,6 +30,7 @@ from ddtrace.ext import http from ddtrace.ext import user from ddtrace.internal.compat import ensure_text +from ddtrace.internal.schema import schematize_service_name from ddtrace.propagation._utils import get_wsgi_header from ddtrace.propagation.http import HTTP_HEADER_PARENT_ID from ddtrace.propagation.http import HTTP_HEADER_SAMPLING_PRIORITY @@ -769,6 +770,25 @@ def test_cache_get(test_spans): assert_dict_issuperset(span.get_tags(), expected_meta) +def test_cache_service_schematization(test_spans): + from ddtrace import config + + cache = django.core.cache.caches["default"] + + env = os.environ.copy() + + env["DD_SERVICE"] = "custom-service-name" + + cache.set("test_key", "test_value") + expected_service_name = schematize_service_name(config.django.cache_service_name) + + spans = test_spans.get_spans() + assert spans + + span = spans[0] + assert span.service == expected_service_name + + def test_cache_get_rowcount_existing_key(test_spans): # get the default cache cache = django.core.cache.caches["default"]