Azure / Azure/azure-sdk-for-python

Tracing: allow setting schemaUrl when creating OTel tracer

Open
#39,181 1 comment 0 reactions 1 assignee Claimed by @pvaneck View on GitHub
Azure.Core Client OpenTelemetry
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

OTel allows setting SchemaURL (something that looks like https://opentelemetry.io/schemas/1.40.0) when creating a tracer - e.g. like in [this](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/52871b82b6afc3545609d3740620a6c4d4edf7ab/instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py#L75) example.

This information is exported along with the telemetry and
1. allows users to understand the format and version of traces library emits
2. allows a backend like Azure Monitor to interpret telemetry depending on this schema version

Essentially it's a versioning mechanism similar to API version.

We need to support it to allow:
- Azure AI Inference/Agents to proceed with their telemetry story and support users minimizing breaking changes on telemetry
- ServiceBus/EventHubs/CosmosDB and other SDKs that emit traces to express their own version of telemetry

This needs a similar approach as #34810 and #9256.

Here's how Java does it (full details in https://github.com/Azure/azure-sdk-for-java/pull/41789)

```java
LibraryTelemetryOptions libraryOptions = new LibraryTelemetryOptions("azure-storage-blobs")
.setLibraryVersion("12.20.0")
.setResourceProviderNamespace("Microsoft.Storage")
.setSchemaUrl("https://opentelemetry.io/schemas/1.23.1");

Tracer tracer = TracerProvider.getDefaultProvider()
.createTracer(libraryOptions, clientOptions.getTracingOptions());
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.