Skip to content

Conversation

@umaannamalai
Copy link
Contributor

This PR adds new logic to capture token counts directly from LLM response objects in OpenAI, Bedrock, and Gemini.

umaannamalai and others added 7 commits October 7, 2025 10:57
* Add response token count logic to Gemini instrumentation.

* Update token counting util functions.

* Linting

* Add response token count logic to Gemini instrumentation.

* Update token counting util functions.

* [MegaLinter] Apply linters fixes

* Bump tests.

---------

Co-authored-by: Tim Pansino <[email protected]>
* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* Linting

* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: Tim Pansino <[email protected]>
* Add bedrock token counting.

* [MegaLinter] Apply linters fixes

* Add bedrock token counting.

* Add safeguards when grabbing token counts.

* Remove extra None defaults.

* Cleanup default None checks.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Add response token count logic to Gemini instrumentation.

* Update token counting util functions.

* Linting

* Add response token count logic to Gemini instrumentation.

* Update token counting util functions.

* [MegaLinter] Apply linters fixes

* Bump tests.

---------

Co-authored-by: Tim Pansino <[email protected]>
* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* Linting

* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: Tim Pansino <[email protected]>
…ic-python-agent into feature-llm-token-counts
@github-actions
Copy link

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 0.88s
✅ MARKDOWN markdownlint 7 0 0 0 1.32s
✅ PYTHON ruff 948 0 0 0 0.98s
✅ PYTHON ruff-format 948 0 0 0 0.39s
✅ YAML prettier 15 0 0 0 1.51s
✅ YAML v8r 15 0 0 5.32s
✅ YAML yamllint 15 0 0 0.68s

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security

@mergify mergify bot added the tests-failing Tests failing in CI. label Nov 17, 2025
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 90.21739% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.89%. Comparing base (8d18c0a) to head (1245264).

Files with missing lines Patch % Lines
newrelic/hooks/mlmodel_gemini.py 67.39% 7 Missing and 8 partials ⚠️
newrelic/hooks/external_botocore.py 97.27% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1583      +/-   ##
==========================================
+ Coverage   81.82%   81.89%   +0.06%     
==========================================
  Files         207      207              
  Lines       23953    24081     +128     
  Branches     3799     3812      +13     
==========================================
+ Hits        19599    19720     +121     
- Misses       3086     3088       +2     
- Partials     1268     1273       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot added the merge-conflicts Merge conflicts detected. label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflicts Merge conflicts detected. tests-failing Tests failing in CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants