elastic / elastic/apm-agent-python
[Azure Python SDK] Implement tracing of Azure Python SDK using azure-core-tracing
- Dominant language
- Python
- Stars
- 431
- Forks
- 239
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 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.
Contributor guide
Assessment
This issue has not been assessed yet.