1.33.0 (2025-04-03)
Features Added
- Added native OpenTelemetry tracing to Azure Core which enables users to use OpenTelemetry to trace Azure SDK operations without needing to install a plugin. #39563
- To enable native OpenTelemetry tracing, users need to:
- Have
opentelemetry-apiinstalled. - Ensure that
settings.tracing_implementationis not set. - Ensure that
settings.tracing_enabledis set toTrue.
- Have
- If
setting.tracing_implementationis set, the tracing plugin will be used instead of the native tracing. - If
settings.tracing_enabledis set toFalse, tracing will be disabled. - The
OpenTelemetryTracerclass was added to theazure.core.tracing.opentelemetrymodule. This is a wrapper around the OpenTelemetry tracer that is used to create spans for Azure SDK operations. - Added a
get_tracermethod to the newazure.core.instrumentationmodule. This method returns an instance of theOpenTelemetryTracerclass if OpenTelemetry is available. - A
TracingOptionsTypedDict class was added to define the options that SDK users can use to configure tracing per-operation. These options include the ability to enable or disable tracing and set additional attributes on spans.- Example usage:
client.method(tracing_options={"enabled": True, "attributes": {"foo": "bar"}})
- Example usage:
- The
DistributedTracingPolicyanddistributed_trace/distributed_trace_asyncdecorators now uses the OpenTelemetry tracer if it is available and native tracing is enabled.- SDK clients can define an
_instrumentation_configclass variable to configure the OpenTelemetry tracer used in method span creation. Possible configuration options arelibrary_name,library_version,schema_url, andattributes. DistributedTracingPolicynow accepts ainstrumentation_configkeyword argument to configure the OpenTelemetry tracer used in HTTP span creation.
- SDK clients can define an
- To enable native OpenTelemetry tracing, users need to:
Breaking Changes
- Removed automatic tracing enablement for the OpenTelemetry plugin if
opentelemetrywas imported. To enable tracing with the plugin, please importazure.core.settings.settingsand setsettings.tracing_implementationto"opentelemetry". #39563 - In
DistributedTracingPolicy, the default span name is now just the HTTP method (e.g., "GET", "POST") and no longer includes the URL path. This change was made to converge with the OpenTelemetry HTTP semantic conventions. The full URL is still included in the span attributes. - Renamed span attributes in
DistributedTracingPolicy:- "x-ms-client-request-id" is now "az.client_request_id"
- "x-ms-request-id" is now "az.service_request_id"
Bugs Fixed
- Fixed an issue where the
traceparentheader was not being set correctly in theDistributedTracingPolicy. Thetraceparentheader will now set based on the context of the HTTP client span. #40074
Other Changes
- Added
opentelemetry-apias an optional dependency for tracing. This can be installed withpip install azure-core[tracing]. #39563