traceloop / traceloop/openllmetry

๐Ÿ› Bug Report: NotGiven sentinel leak in Anthropic instrumentation

Open Beginner friendly
#4,431 1 comment 0 reactions 0 assignees View on GitHub

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
  1. Install opentelemetry-instrumentation-anthropic and anthropic SDK (0.52+)
  2. Call client.messages.create(model="...", max_tokens=1024, messages=[...]) without setting temperature or top_p
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up โ€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.