Skip to content

Commit d9a0d7d

Browse files
hayke102claudenirga
authored
fix(openai): use SpanAttributes instead of GenAIAttributes for cache token attributes (#3442)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
1 parent 2176fca commit d9a0d7d

File tree

2 files changed

+5
-5
lines changed
  • packages
    • opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic
    • opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain

2 files changed

+5
-5
lines changed

packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ async def _aset_token_usage(
283283
set_span_attribute(span, SpanAttributes.LLM_USAGE_TOTAL_TOKENS, total_tokens)
284284

285285
set_span_attribute(
286-
span, GenAIAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cache_read_tokens
286+
span, SpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cache_read_tokens
287287
)
288288
set_span_attribute(
289289
span,
290-
GenAIAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
290+
SpanAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
291291
cache_creation_tokens,
292292
)
293293

@@ -397,11 +397,11 @@ def _set_token_usage(
397397
set_span_attribute(span, SpanAttributes.LLM_USAGE_TOTAL_TOKENS, total_tokens)
398398

399399
set_span_attribute(
400-
span, GenAIAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cache_read_tokens
400+
span, SpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cache_read_tokens
401401
)
402402
set_span_attribute(
403403
span,
404-
GenAIAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
404+
SpanAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
405405
cache_creation_tokens,
406406
)
407407

packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/span_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def set_chat_response_usage(
346346
)
347347
_set_span_attribute(
348348
span,
349-
GenAIAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
349+
SpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
350350
cache_read_tokens,
351351
)
352352
if record_token_usage:

0 commit comments

Comments
 (0)