Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Tracing updates #39563

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

pvaneck
Copy link
Member

@pvaneck pvaneck commented Feb 5, 2025

This introduces native OpenTelemetry tracing to Azure Core. This is intended to be an alternative/replacement to the azure-core-tracing-opentelemetry plugin.

  • opentelemetry-api is added as an optional dependency, and is needed to enable native tracing.
  • A new TracerProvider class was added, and SDK developers can use this to set tracer metadata for their libraries.
    from azure.core.tracing import TracerProvider
    
    sdk_tracer_provider = TracerProvider(
        library_name="my-library",
        library_version="1.0.0",
       schema_url="https://opentelemetry.io/schemas/1.23.1",
       attributes={"namespace": "Sample.Namespace"},
    )
    • Instances of TracerProvider can be passed to the distributed_trace decorators and DistributedTracingPolicy.
  • Added OpenTelemetryTracer and OpenTelemetrySpan classes to the azure.core.tracing namespace.
  • settings.tracing_enabled is now the global setting for enabling/disabling tracing.
    • If settings.tracing_implementation is set, it will take precedence over the native core tracing.
  • DistributedTracingPolicy updates
    • Now uses stable HTTP semantic conventions.
    • Span name updated to just be the HTTP method without the URL path (per OTel Semconv guidelines).
  • A TracingOptions TypedDict was added for containing possible per-operation tracing configurations.
    • This includes enabled, attributes, and record_exception.
    • Sample usage: client.method(..., tracing_options={'enabled': True, 'attributes': {'key': 'value'}})
    • These will be propagated to both the distributed_trace decorators and DistributedTracingPolicy.

Signed-off-by: Paul Van Eck <[email protected]>
@pvaneck pvaneck force-pushed the core-tracing-update branch from 4072688 to 5268fb4 Compare February 5, 2025 05:43
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants