Skip to content

Incorrect mapping in telemetry usage attributes #2105

Closed

Description

@tl-nguyen

Incorrect mapping in telemetry usage attributes. The gen_ai.usage.output_tokens was
incorrectly mapped to llm_response.usage_metadata.total_token_count instead of
llm_response.usage_metadata.candidates_token_count, leading to wrong output token counts in
Langfuse integration.

To Reproduce

Steps to reproduce the behavior:

  1. Install ADK with Langfuse integration
  2. Run ADK agents with any LLM model
  3. Open Langfuse dashboard
  4. Check usage details - observe incorrect output token counts

Expected behavior

gen_ai.usage.output_tokens should correctly map to candidates_token_count for accurate
output token tracking in Langfuse.

Screenshots
Image
shows incorrect output token counts in Langfuse usage details due to wrong
attribute mapping.

Desktop (please complete the following information):

  • OS: Linux Ubuntu 22.04
  • Python version: 3.12.3
  • ADK version: 1.7.0

Model Information:

Affects all models integrated with Langfuse

Additional context

Can be fixed by changing the mapping from llm_response.usage_metadata.total_token_count to
llm_response.usage_metadata.candidates_token_count for the gen_ai.usage.output_tokens
attribute in telemetry.py

Activity

  1. added
    tracing
    on Jul 22, 2025
  2. added theissue type on Jul 22, 2025
  3. added a commit that references this issue on Jul 24, 2025
    c8f8b4a
  4. added a commit that references this issue on Jul 28, 2025
    0300929
  5. added a commit that references this issue on Aug 16, 2025
    dd59232
  6. added a commit that references this issue on Aug 11, 2026
    ed4da70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

tracing

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions