elastic / elastic/apm-agent-python
When APM is disabled, OTEL's `start_span` causes exception
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 431
- Forks
- 239
- Merge moyen
- 5 j 10 h
- PR mergées (30 j)
- 7
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_ENABLEDtofalse - Call
start_as_current_spanorstart_span(fromTracerofelasticapm.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"
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez dans elasticapm/contrib/opentelemetry/trace.py, au niveau de Tracer.start_span, et suivez la construction de Span jusqu’à elasticapm/contrib/opentelemetry/span.py. Reproduisez l’échec avec ELASTIC_APM_ENABLED défini sur false et examinez pourquoi le chemin désactivé fournit None. Le travail est terminé lorsque start_span et start_as_current_span s’exécutent sans exception dans cette configuration.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend, observability-sre
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 48/100