traceloop / traceloop/openllmetry
๐ Bug Report: NotGiven sentinel leak in Anthropic instrumentation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.4k
- Forks
- 1.1k
- Avg merge
- 8d 14h
- Merged PRs (30d)
- 2
Description
Which component is this bug for?
Anthropic Instrumentation
๐ Description
set_span_attribute() in \traceloop\openllmetry\tree\main\packages\opentelemetry-instrumentation-anthropic\opentelemetry\instrumentation\anthropic\utils.py filters None and empty strings but not the Anthropic SDK's NOT_GIVEN sentinel (type Omit / NotGiven). When optional parameters like temperature or top_p are not explicitly set, the sentinel leaks into span.set_attribute(), producing OTel type warnings:
Invalid type Omit for attribute 'gen_ai.request.temperature' value.
Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
Same pattern as #4230(log Body) and #3472(OpenAI Omit), but in Anthropic span attributes.
๐ Reproduction steps
- Install opentelemetry-instrumentation-anthropic and anthropic SDK (0.52+)
- Call client.messages.create(model="...", max_tokens=1024, messages=[...]) without setting temperature or top_p
- Observe warning: Invalid type Omit for attribute 'gen_ai.request.temperature'
๐ Expected behavior
set_span_attribute() should silently skip NOT_GIVEN / Omit sentinel values, same as it skips None and "".
๐ Actual Behavior with Screenshots
The sentinel passes through to span.set_attribute(), which rejects non-primitive types and logs a warning per attribute.
๐ค Python Version
3.11 / 3.13 (reproducible on both)
๐ Provide any additional context for the Bug.
The OpenAI instrumentation already handles this in two places:
ใป_set_span_attribute checks value == openai.NOT_GIVEN
ใป_sanitize_sentinel_values() strips sentinels from kwargs(#3472)
๐ Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
Yes I am willing to submit a PR!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up โ it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/utils.py and inspect set_span_attribute(), comparing its filtering with the OpenAI instrumentation references described in the issue. Reproduce the messages.create() call without temperature or top_p, then verify that Anthropic NOT_GIVEN/Omit values are skipped and no invalid OTel attribute warnings are emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100