Skip to content

Commit

Permalink
extract tokens from apm span metrics instead of meta
Browse files Browse the repository at this point in the history
  • Loading branch information
ncybul committed Feb 4, 2025
1 parent 2bf6bad commit 5b770cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ddtrace/llmobs/_integrations/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def _llmobs_set_tags(
def _llmobs_metrics(span: Span, response: Optional[Dict[str, Any]]) -> Dict[str, Any]:
metrics = {}
if response and response.get("text"):
prompt_tokens = int(span.get_tag("bedrock.usage.prompt_tokens") or 0)
completion_tokens = int(span.get_tag("bedrock.usage.completion_tokens") or 0)
prompt_tokens = int(span.get_metric("bedrock.usage.prompt_tokens") or 0)
completion_tokens = int(span.get_metric("bedrock.usage.completion_tokens") or 0)
metrics[INPUT_TOKENS_METRIC_KEY] = prompt_tokens
metrics[OUTPUT_TOKENS_METRIC_KEY] = completion_tokens
metrics[TOTAL_TOKENS_METRIC_KEY] = prompt_tokens + completion_tokens
Expand Down

0 comments on commit 5b770cf

Please sign in to comment.