Skip to content

Commit

Permalink
fix minor bug by making sure token counts are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ncybul committed Feb 4, 2025
1 parent 7baffdf commit 2bf6bad
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion ddtrace/_trace/trace_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def _on_botocore_bedrock_process_response(
integration = ctx["bedrock_integration"]
if metadata is not None:
for k, v in metadata.items():
if k in ["usage.completion_tokens", "usage.prompt_tokens"]:
if k in ["usage.completion_tokens", "usage.prompt_tokens"] and v:
span.set_metric("bedrock.{}".format(k), int(v))
else:
span.set_tag_str("bedrock.{}".format(k), str(v))
Expand Down
1 change: 0 additions & 1 deletion tests/contrib/botocore/test_bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ def test_span_finishes_after_generator_exit(bedrock_client, request_vcr, mock_tr
if i >= 6:
raise GeneratorExit
i += 1
breakpoint()
span = mock_tracer.pop_traces()[0][0]
assert span is not None
assert span.name == "bedrock-runtime.command"
Expand Down

0 comments on commit 2bf6bad

Please sign in to comment.