Skip to content

[Core OTel] Add schema version support to OTel plugin#40161

Merged
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:otel-plugin-schema-version
Mar 20, 2025
Merged

[Core OTel] Add schema version support to OTel plugin#40161
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:otel-plugin-schema-version

Conversation

@pvaneck
Copy link
Copy Markdown
Member

@pvaneck pvaneck commented Mar 20, 2025

This is to support cases where a user might be using the plugin span and wants to set attributes defined in a later version of the OTel schema. This allows passing in a specific version and setting the corresponding schema URL on the tracer instrumentation scope.

For example, someone wanting to make a generative AI span might want to specify a different schema version than the one the plugin defaults to.

Related: #39181

@azure-sdk
Copy link
Copy Markdown
Collaborator

API change check

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

azure-core-tracing-opentelemetry

@pvaneck pvaneck force-pushed the otel-plugin-schema-version branch from 76e8f74 to f7b408f Compare March 20, 2025 20:32
This is to support cases where a user might be using the plugin span and
wants to set attributes defined in a later version of the OTel schema.
This allows passing in a specific version and setting the corresponding
schema URL on the tracer instrumentation scope.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck force-pushed the otel-plugin-schema-version branch from f7b408f to b74d32b Compare March 20, 2025 20:37
@pvaneck pvaneck marked this pull request as ready for review March 20, 2025 21:27
Copilot AI review requested due to automatic review settings March 20, 2025 21:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for specifying a schema version in the OpenTelemetry plugin, enabling users to use attribute mappings per the desired OTel schema. Key changes include:

  • Updating test cases in test_schema.py and test_tracing_implementations.py to validate the new schema_version argument.
  • Changing the default behavior in the OpenTelemetrySpan init to use a specified default version instead of the latest version.
  • Updating the changelog and schema mapping implementation to accommodate the schema version support.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sdk/core/azure-core-tracing-opentelemetry/tests/test_schema.py Updates tests to use the schema_version from the wrapped span and adds tests for various schema formats.
sdk/core/azure-core-tracing-opentelemetry/tests/test_tracing_implementations.py Adds new tests for HTTP attribute setting with explicit schema versions.
sdk/core/azure-core-tracing-opentelemetry/azure/core/tracing/ext/opentelemetry_span/init.py Changes default schema_version handling and imports to support version specification.
sdk/core/azure-core-tracing-opentelemetry/CHANGELOG.md Documents the new schema version support feature.
sdk/core/azure-core-tracing-opentelemetry/azure/core/tracing/ext/opentelemetry_span/_schema.py Updates the attribute mappings retrieval to use a safe lookup with a fallback.
Comments suppressed due to low confidence (2)

sdk/core/azure-core-tracing-opentelemetry/tests/test_schema.py:57

  • Passing a schema version as a string instead of the expected OpenTelemetrySchemaVersion enum may lead to inconsistent behavior. Consider adding conversion or validation to ensure the input is of the correct type.
assert OpenTelemetrySchema.get_attribute_mappings("1.19.0")

sdk/core/azure-core-tracing-opentelemetry/azure/core/tracing/ext/opentelemetry_span/init.py:130

  • The default schema version is now hard-coded to V1_23_1, which is a change from using get_latest_version(). Please verify this change aligns with user expectations for future schema updates.
self._schema_version = kwargs.pop("schema_version", _OpenTelemetrySchemaVersion.V1_23_1)

@pvaneck
Copy link
Copy Markdown
Member Author

pvaneck commented Mar 20, 2025

/check-enforcer override

@pvaneck pvaneck merged commit e3a5c9d into Azure:main Mar 20, 2025
55 of 57 checks passed
@pvaneck pvaneck deleted the otel-plugin-schema-version branch March 20, 2025 22:39
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.

4 participants