Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit and test opentelemetry-instrumentation-django NoOpTracerProvider #1611

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