Skip to content

Commit

Permalink
Audit and test opentelemetry-instrumentation-django NoOpTracerProvider (
Browse files Browse the repository at this point in the history
  • Loading branch information
Akochavi authored Feb 13, 2023
1 parent 0a4b3b4 commit 7aa4aec
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from django.test import SimpleTestCase
from django.test.utils import setup_test_environment, teardown_test_environment

from opentelemetry import trace as trace_api
from opentelemetry.instrumentation.django import (
DjangoInstrumentor,
_DjangoMiddleware,
Expand Down Expand Up @@ -424,6 +425,16 @@ async def test_tracer_provider_traced(self):
span.resource.attributes["resource-key"], "resource-value"
)

async def test_no_op_tracer_provider(self):
_django_instrumentor.uninstrument()
_django_instrumentor.instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

await self.async_client.post("/traced/")
spans = self.exporter.get_finished_spans()
self.assertEqual(len(spans), 0)


@patch.dict(
"os.environ",
Expand Down

0 comments on commit 7aa4aec

Please sign in to comment.