File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
ddtrace/llmobs/_integrations Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -125,9 +125,13 @@ def get_llmobs_metrics_tags(integration_name, span):
125
125
if integration_name == "bedrock" :
126
126
input_tokens = int (span .get_tag ("bedrock.usage.prompt_tokens" ) or 0 )
127
127
output_tokens = int (span .get_tag ("bedrock.usage.completion_tokens" ) or 0 )
128
- usage [INPUT_TOKENS_METRIC_KEY ] = input_tokens
129
- usage [OUTPUT_TOKENS_METRIC_KEY ] = output_tokens
130
- usage [TOTAL_TOKENS_METRIC_KEY ] = input_tokens + output_tokens
128
+ total_tokens = input_tokens + output_tokens
129
+ if input_tokens :
130
+ usage [INPUT_TOKENS_METRIC_KEY ] = input_tokens
131
+ if output_tokens :
132
+ usage [OUTPUT_TOKENS_METRIC_KEY ] = output_tokens
133
+ if total_tokens :
134
+ usage [TOTAL_TOKENS_METRIC_KEY ] = total_tokens
131
135
return usage
132
136
133
137
# check for both prompt / completion or input / output tokens
You can’t perform that action at this time.
0 commit comments