[Core OTel] Add schema version support to OTel plugin#40161
Merged
pvaneck merged 1 commit intoAzure:mainfrom Mar 20, 2025
Merged
[Core OTel] Add schema version support to OTel plugin#40161pvaneck merged 1 commit intoAzure:mainfrom
pvaneck merged 1 commit intoAzure:mainfrom
Conversation
Collaborator
|
API change check APIView has identified API level changes in this PR and created following API reviews. |
76e8f74 to
f7b408f
Compare
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>
f7b408f to
b74d32b
Compare
Contributor
There was a problem hiding this comment.
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)
kashifkhan
approved these changes
Mar 20, 2025
Member
Author
|
/check-enforcer override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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