Skip to content

Conversation

@vasantteja
Copy link

@vasantteja vasantteja commented Nov 17, 2025

Description

swaps service_tier attributes for request and response objects and fixes #3920

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

How Has This Been Tested?

ran all the unit tests.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

You need to update tests and add a changelog entry

@xrmx xrmx moved this to Reviewed PRs that need fixes in @xrmx's Python PR digest Nov 18, 2025
@xrmx xrmx changed the title fix: Fix service tier attribute names in openai-v2 instrumentation openai-v2: Fix service tier attribute names Nov 18, 2025
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.
@vasantteja
Copy link
Author

You need to update tests and add a changelog entry

@xrmx sorry, fixed it.

Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

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"""

@vasantteja
Copy link
Author

@xrmx I pushed the changes you suggested. can you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

openai-v2: setting GEN_AI_OPENAI_RESPONSE_SERVICE_TIER instead of GEN_AI_OPENAI_REQUEST_SERVICE_TIER

6 participants