openai-v2: Fix service tier attribute names#3952
Merged
xrmx merged 12 commits intoopen-telemetry:mainfrom Nov 24, 2025
Merged
Conversation
xrmx
reviewed
Nov 18, 2025
Contributor
xrmx
left a comment
There was a problem hiding this comment.
You need to update tests and add a changelog entry
In OpenAI SDK 1.26.0, service_tier is passed via extra_body. Update get_llm_request_attributes to check both kwargs and extra_body for service_tier to support both ways of passing it.
Fix open-telemetry#3920: Add changelog entry documenting the fix for service tier attribute names.
…s://github.com/vasantteja/opentelemetry-python-contrib into fix/openai-v2-fix-service-tier-attribute-names
Contributor
Author
@xrmx sorry, fixed it. |
xrmx
reviewed
Nov 19, 2025
Contributor
xrmx
left a comment
There was a problem hiding this comment.
I haven't checked if the service_tier should be made optional but I think we are missing something like the following:
diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_utils.py b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_utils.py
index eb66eb7c7..1f635305d 100644
--- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_utils.py
+++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_utils.py
@@ -35,6 +35,7 @@ def assert_all_attributes(
operation_name: str = "chat",
server_address: str = "api.openai.com",
server_port: int = 443,
+ service_tier: str = "auto",
):
assert span.name == f"{operation_name} {request_model}"
assert (
@@ -87,6 +88,8 @@ def assert_all_attributes(
if server_port != 443 and server_port > 0:
assert server_port == span.attributes[ServerAttributes.SERVER_PORT]
+ assert service_tier == span.attributes[GenAIAttributes.GEN_AI_OPENAI_RESPONSE_SERVICE_TIER]
+
def assert_log_parent(log, span):
"""Assert that the log record has the correct parent span context"""
Contributor
Author
|
@xrmx I pushed the changes you suggested. can you please take a look? |
xrmx
approved these changes
Nov 20, 2025
sightseeker
added a commit
to sightseeker/opentelemetry-python-contrib
that referenced
this pull request
Mar 11, 2026
* fix: Fix service tier attribute names in openai-v2 instrumentation * polish: extracting service_tier from extra_body. * Extract service_tier from extra_body when not in kwargs In OpenAI SDK 1.26.0, service_tier is passed via extra_body. Update get_llm_request_attributes to check both kwargs and extra_body for service_tier to support both ways of passing it. * Add changelog entry for service tier attribute fix Fix open-telemetry#3920: Add changelog entry documenting the fix for service tier attribute names. * wip: adding checks for service_tier. * wip: fix linting errors. --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
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.
Description
swaps service_tier attributes for request and response objects and fixes #3920
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
ran all the unit tests.
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.