Open
Description
Describe the bug: ...
When ELASTIC_APM_ENABLED
is set to false
, start_span()
should not result in an exception. This happens when the Tracer from from elasticapm.contrib.opentelemetry.trace
is used.
To Reproduce
- Set
ELASTIC_APM_ENABLED
tofalse
- Call
start_as_current_span
orstart_span
(fromTracer
ofelasticapm.contrib.opentelemetry.trace
) - Notice an exception is thrown
Environment (please complete the following information)
- OS: Mac OS, Linux
- Python version: 3.12
- Framework and version [e.g. Django 2.1]: N/A
- APM Server version: N/A
- Agent version:
6.23.0
Additional context
Here's the exception:
with tracer.start_as_current_span(name) as span:\\n
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n
| File \\\"/usr/local/lib/python3.12/contextlib.py\\\", line 137, in __enter__\\n
| return next(self.gen)\\n
| ^^^^^^^^^^^^^^\\n
| File \\\"/app/.venv/lib/python3.12/site-packages/elasticapm/contrib/opentelemetry/trace.py\\\", line 230, in start_as_current_span\\n
| span = self.start_span(\\n
| ^^^^^^^^^^^^^^^^\\n
| File \\\"/app/.venv/lib/python3.12/site-packages/elasticapm/contrib/opentelemetry/trace.py\\\", line 150, in start_span\\n
| span = Span(\\n
| ^^^^^\\n
| File \\\"/app/.venv/lib/python3.12/site-packages/elasticapm/contrib/opentelemetry/span.py\\\", line 65, in __init__\\n
| elastic_span.otel_wrapper = self\\n
| ^^^^^^^^^^^^^^^^^^^^^^^^^\\n
| AttributeError: 'NoneType' object has no attribute 'otel_wrapper'\\n
-
Agent config options
Click to expand
client = elasticapm.Client( central_config=False, transaction_sample_rate=1, ) tracer = Tracer(__name__)
-
requirements.txt
:Click to expand
elastic-apm = "^6.23.0" opentelemetry-api = "^1.28.1" opentelemetry-sdk = "^1.28.1"