sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

fix(telemetry): prevent double counting of usage metrics

Open rajib76 opened this issue 11 months ago • 1 comments

Description

This is a fix for the below bug: _[BUG] OpenTelemetry token/cost metrics double-counted in Langfuse due to duplicate reporting on parent and child spans https://github.com/strands-agents/sdk-python/issues/1267

Related Issues

https://github.com/strands-agents/sdk-python/issues/1267

Documentation PR

Type of Change

Bug fix

Bug fix New feature Breaking change Documentation update Other (please describe):

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • [x] I ran hatch run prepare

Checklist

  • [ ] I have read the CONTRIBUTING document
  • [ ] I have added any necessary tests that prove my fix is effective or my feature works
  • [ ] I have updated the documentation accordingly
  • [ ] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • [ ] My changes generate no new warnings
  • [ ] Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

rajib76 avatar Dec 13 '25 17:12 rajib76

I created a new pull request for this pull request# 1327

rajib76 avatar Dec 13 '25 17:12 rajib76

@rajib76 could you update the code based on this reply: https://github.com/strands-agents/sdk-python/issues/1267#issuecomment-3666286154

I can make the new PR too if preferred.

poshinchen avatar Dec 17 '25 17:12 poshinchen

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests.

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Dec 17 '25 19:12 codecov[bot]

Thank you very much @poshinchen for resolving this so quickly! Would love to connect with you on discord, pls share details if okay with it.

This change will go in 1.21.0, right? If yes, when can we expect the package release.

fenil210-cactus avatar Dec 19 '25 06:12 fenil210-cactus

Sorry I don't have discord account. The next release should be on next Tuesday / Wednesday.

poshinchen avatar Dec 19 '25 16:12 poshinchen