elastic / elastic/apm-agent-python
[Azure Python SDK] Implement tracing of Azure Python SDK using azure-core-tracing
- Langage dominant
- Python
- Étoiles
- 431
- Forks
- 239
- Merge moyen
- 5 j 10 h
- PR mergées (30 j)
- 7
Description
**Is your feature request related to a problem? Please describe.**
Since whole Azure Python SDK is traced using azure-core-tracing abstract tracing, an ElasticAPM Span implementation could be generated so all Azure libraries would be traced in APM "for free"
This is already done with OpenTelemetry using this code:
```python
from azure.core.settings import settings
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
settings.tracing_implementation = OpenTelemetrySpan
```
An ElasticAPMSpan class that inherits from [`HttpSpanMixin`](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/azure/core/tracing/_abstract_span.py#L231) could be implemented. This could be based in current [`OpenTelemetrySpan`](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core-tracing-opentelemetry/azure/core/tracing/ext/opentelemetry_span/__init__.py#L50)
I have seen that some Azure integrations are being done here: https://github.com/elastic/apm/issues/410. The enhancement I suggest would cover those integrations and many more, since the tracing is already implemented in the whole Azure Python SDK.
**Describe the solution you'd like**
I would like an Azure SDK tracing implementation that could allow me to do this:
```python
from azure.core.settings import settings
from elasticapm.contrib.serverless.azure import ElasticAPMSpan
settings.tracing_implementation = ElasticAPMSpan
```
So I could take advantage of the already traced Azure SDK code.
**Describe alternatives you've considered**
* I haved tried to set the [OpenTelemetry API Bridge](https://www.elastic.co/guide/en/apm/agent/python/6.x/opentelemetry-bridge.html) but it will not work in this case since OpenTelemetrySpan recovers the tracer from the global OpenTelemetry tracer which is not set in the bridge.
* Another option would be to use OpenTelemetry API and OTLP gRPC exporter to send traces to APM Server. That works and I have used it successfully in other projects, but there is no OpenTelemetry instrumentation of Azure Functions and `elasticapm.contrib.serverless.azure.ElasticAPMExtension` works best in my current use case.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par azure.core.tracing.ext.opentelemetry_span.OpenTelemetrySpan et HttpSpanMixin dans azure.core.tracing._abstract_span.py, puis examinez le point d’entrée elasticapm.contrib.serverless.azure. Comparez le comportement demandé d’ElasticAPMSpan avec celui de l’OpenTelemetrySpan existant et vérifiez que son affectation à settings.tracing_implementation permet aux opérations de l’Azure SDK de produire des spans APM.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- azure, python
- Domaine
- observability-sre
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100