Skip to content

[opentelemetry-instrumentation-genai-openai] Correct base64 embedding dimensions - #981

Open
rads-1996 wants to merge 2 commits into
open-telemetry:mainfrom
rads-1996:openai-base64-embedding-dimensions
Open

rads-1996 wants to merge 2 commits into
open-telemetry:mainfrom
rads-1996:openai-base64-embedding-dimensions

Conversation

@rads-1996

Copy link
Copy Markdown
Contributor

Description

Fix incorrect OpenAI embedding dimension counts for base64 responses by counting decoded float32 elements instead of encoded characters, without modifying the SDK response.

Updated existing sync and async tests to derive expected dimensions from the returned embeddings.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. List any relevant details for your test
configuration.

  • tox -e py312-test-instrumentation-genai-openai-latest
  • tox -e py310-test-instrumentation-genai-openai-oldest
  • tox -e precommit and tox -e typecheck

Checklist

See CONTRIBUTING.md
for the style guide, changelog guidance, and more.

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-10-24 03:45 UTC

Merge when ready.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The localized fix preserves SDK responses, includes sync and async regression assertions, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

Corrects OpenAI embedding dimension telemetry for base64 responses by counting decoded float32 elements rather than encoded characters, while preserving the SDK response.

Changes:

  • Decodes base64 embeddings locally to calculate their dimensions.
  • Updates shared assertions and sync/async tests to verify dimensions and unchanged response types.
  • Adds a changelog entry for the fix.
File Description
instrumentation/​opentelemetry-instrumentation-genai-openai/​tests/​test_utils.py Calculates expected dimensions from decoded base64 data.
instrumentation/​opentelemetry-instrumentation-genai-openai/​tests/​test_embeddings.py Checks dimension reporting and preserved string responses for sync calls.
instrumentation/​opentelemetry-instrumentation-genai-openai/​tests/​test_async_embeddings.py Adds equivalent checks for async calls.
instrumentation/​opentelemetry-instrumentation-genai-openai/​src/​opentelemetry/​instrumentation/​genai/​openai/​patch.py Counts decoded float32 elements without modifying returned embeddings.
instrumentation/​opentelemetry-instrumentation-genai-openai/​.changelog/​981.fixed Documents the corrected dimension counts.

Review effort: Balanced

@rads-1996 rads-1996 changed the title Correct base64 embedding dimensions [opentelemetry-instrumentation-genai-openai] Correct base64 embedding dimensions Oct 23, 2026
@rads-1996
rads-1996 marked this pull request as ready for review October 23, 2026 22:01
@rads-1996
rads-1996 requested a review from a team as a code owner October 23, 2026 22:01

This branch has not been deployed

No deployments
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.

3 participants