Skip to content

Commit aa4a469

Browse files
authored
fix(vertexai): emit cache tokens (#4263)
1 parent fc75bbb commit aa4a469

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

  • packages/opentelemetry-instrumentation-vertexai

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,13 @@ def set_model_response_attributes(span, llm_model, token_usage):
311311
GenAIAttributes.GEN_AI_USAGE_INPUT_TOKENS,
312312
token_usage.prompt_token_count,
313313
)
314+
315+
cached_content_token_count = getattr(
316+
token_usage, "cached_content_token_count", None
317+
)
318+
if cached_content_token_count is not None:
319+
_set_span_attribute(
320+
span,
321+
GenAIAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
322+
cached_content_token_count,
323+
)

packages/opentelemetry-instrumentation-vertexai/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)