Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
quinna-h committed Dec 30, 2024
1 parent a420c18 commit a20be80
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/contrib/django/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit a20be80

Please sign in to comment.