mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: add usage span attributes to telemetry (#356)
Merge https://github.com/google/adk-python/pull/1079 Fixes part of #356 Add usage attributes to span. Note: Since the handling of GenAI event bodies in OpenTelemetry has not yet been determined, I have temporarily added only attributes related to usage. COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1079 from soundTricker:feature/356-support-more-opentelemetry-semantics 99a9d0352b4bca165baa645440e39ce7199f072b PiperOrigin-RevId: 774834279
This commit is contained in:
committed by
Copybara-Service
parent
f033e405c1
commit
ea69c9093a
@@ -195,6 +195,16 @@ def trace_call_llm(
|
||||
llm_response_json,
|
||||
)
|
||||
|
||||
if llm_response.usage_metadata is not None:
|
||||
span.set_attribute(
|
||||
'gen_ai.usage.input_tokens',
|
||||
llm_response.usage_metadata.prompt_token_count,
|
||||
)
|
||||
span.set_attribute(
|
||||
'gen_ai.usage.output_tokens',
|
||||
llm_response.usage_metadata.total_token_count,
|
||||
)
|
||||
|
||||
|
||||
def trace_send_data(
|
||||
invocation_context: InvocationContext,
|
||||
|
||||
Reference in New Issue
Block a user