Open Arvinje opened 15 hours ago
Thanks for reporting. Wrote a quick test for reproducing this ~but it still passes, anyway looking at the code I see how it can fail~:
diff --git a/tests/contrib/opentelemetry/tests.py b/tests/contrib/opentelemetry/tests.py
index 3a302289..a3e0a705 100755
--- a/tests/contrib/opentelemetry/tests.py
+++ b/tests/contrib/opentelemetry/tests.py
@@ -48,6 +48,19 @@ def tracer(elasticapm_client) -> Tracer:
yield Tracer("test", elasticapm_client=elasticapm_client)
+@pytest.mark.parametrize("elasticapm_client", [{"enabled": False}], indirect=True)
+def test_root_transaction_not_enabled(elasticapm_client, tracer):
+ with tracer.start_as_current_span("test"):
+ pass
+
+
def test_root_transaction(tracer: Tracer):
with tracer.start_as_current_span("test"):
pass
@Arvinje Does setting OTEL_SDK_DISABLED=true
env var help?
@xrmx no it doesn't. I hoped similar to the NodeJS package, ELASTIC_APM_ENABLED=false
would turn methods of the OTel bridge into noop.
Describe the bug: ... When
ELASTIC_APM_ENABLED
is set tofalse
,start_span()
should not result in an exception. This happens when the Tracer fromfrom elasticapm.contrib.opentelemetry.trace
is used.To Reproduce
ELASTIC_APM_ENABLED
tofalse
start_as_current_span
orstart_span
(fromTracer
ofelasticapm.contrib.opentelemetry.trace
)Environment (please complete the following information)
6.23.0
Additional context
Here's the exception:
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" ```