jinja2: tracing ignores suppress_instrumentation()
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- observability
Research direction
Start with the Jinja2 instrumentation package and the shared tracing wrapper it uses, and check how suppress_instrumentation() from opentelemetry.instrumentation.utils is consulted there. Run the reproduction script in the issue, which should print [] under suppression. Done means no spans are created inside the suppressed block, spans resume afterward, and template loading and generate() are covered by tests. The reporter says they plan to open the PR, so confirm with them before starting.
Written by the indexing model from the issue text.
Description
Describe your environment
Python 3.10/3.12/3.14, Jinja2 3.1.6; current main (77dd2d009dec5bfa04fcecb8e2e3d1bb33ff218b).
What happened?
Jinja2 instrumentation emits compilation, loading and rendering spans inside suppress_instrumentation(), even though callers explicitly suppress instrumentation for that operation.
Steps to Reproduce
import jinja2
from opentelemetry.instrumentation.jinja2 import Jinja2Instrumentor
from opentelemetry.instrumentation.utils import suppress_instrumentation
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
exporter = InMemorySpanExporter()
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(exporter))
Jinja2Instrumentor().instrument(tracer_provider=provider)
with suppress_instrumentation():
template = jinja2.Template("Hello {{ name }}!")
assert template.render(name="Jinja") == "Hello Jinja!"
print([span.name for span in exporter.get_finished_spans()])
Expected Result
No instrumentation spans: [].
Actual Result
['jinja2.compile', 'jinja2.render']. Template loading and generate() also ignore suppression.
Additional context
A fix checking the suppression flag in the shared tracing wrapper is locally verified. Tests cover inherited templates, rendered/generated output, exception behavior, and tracing resuming after suppression. I will submit the corresponding PR.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 31
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from open-telemetry/opentelemetry-python-contrib
-
opentelemetry-instrumentation-tornado: server metrics recorded twice when a handler raises, http.server.active_requests goes negativePossibly taken @sivakumar-mahalingam claimed this 25 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
open-telemetry/opentelemetry-python-contrib#5113 · 2 comments · 2 reactions ·
Maintainers usually reply within 2 days
-
httpx: `http.client.duration` has no `net.peer.name` in the default semconv modePossibly taken @jbyers44 claimed this 27 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
open-telemetry/opentelemetry-python-contrib#5100 ·
Maintainers usually reply within 2 days
-
Logging: don't include injected trace context attributes in emitted recordsPossibly taken @RichardoMrMu claimed this 34 days ago. Openfeature-request
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-telemetry/opentelemetry-python-contrib#5071 ·
Maintainers usually reply within 2 days
-
`LoggingInstrumentor` `log_hook` only runs when there is an active spanPossibly taken @git-jxj claimed this 35 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
open-telemetry/opentelemetry-python-contrib#5069 ·
Maintainers usually reply within 2 days
-
[grpc] AIO server spans record uncaught exceptions twicePossibly taken @somuai claimed this 34 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-telemetry/opentelemetry-python-contrib#5068 · 1 comment ·
Maintainers usually reply within 2 days
All issues in open-telemetry/opentelemetry-python-contrib
Similar issues
-
[oblt-aw][autodoc] Update workflow docs for gh-aw v0.92.5 and detector permission scopePossibly taken @github-actions claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
roadmap-100
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
comp/tools P2 tool/browser tool/file type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NousResearch/hermes-agent#143418 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
python-hyper/uritemplate#164 ·