Skip to content

Fix OpenTelemetry attribute errors for NOT_GIVEN values#18

Open
ryanlewis wants to merge 1 commit intocoralogix:masterfrom
ryanlewis:fix/not-given-opentelemetry-attributes
Open

Fix OpenTelemetry attribute errors for NOT_GIVEN values#18
ryanlewis wants to merge 1 commit intocoralogix:masterfrom
ryanlewis:fix/not-given-opentelemetry-attributes

Conversation

@ryanlewis
Copy link
Contributor

Fixed OpenTelemetry attribute errors that occur when NOT_GIVEN values are passed to spans.

@ryanlewis ryanlewis requested a review from a team as a code owner September 10, 2025 14:36
Filter out OpenAI's NOT_GIVEN sentinel values from span attributes to prevent
OpenTelemetry validation errors. The library was attempting to set attributes
with NOT_GIVEN type, which OpenTelemetry doesn't accept (only supports basic
types: bool, str, bytes, int, float).

Changes:
- Update span_builder to filter NOT_GIVEN alongside None values
- Add test to verify NOT_GIVEN values are properly filtered
- Ensure backwards compatibility with existing attribute handling

Fixes errors like:
"Invalid type NotGiven for attribute 'gen_ai.request.temperature' value.
Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of
those types"
@ryanlewis ryanlewis force-pushed the fix/not-given-opentelemetry-attributes branch from bc1e700 to 592e364 Compare September 10, 2025 14:38
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.

1 participant