openllmetry
openllmetry copied to clipboard
Feature: Support Prompt Caching
This PR supports tracking and logging prompt caching(#1838) metrics in the OpenTelemetry Anthropic instrumentation.
Specifically, it captures and logs the cache_creation_input_tokens and cache_read_input_tokens fields from the API response. This enhancement allows users to monitor the effectiveness of their prompt caching strategy, providing insights into cache utilization and efficiency.
Changes include:
- Updated
_set_token_usageand_aset_token_usagefunctions to log caching metrics. - Added new span attributes for
cache_creation_input_tokensandcache_read_input_tokens. - Updated
streaming.pyto support prompt caching metrics in streaming responses.
@kowshik24 note that you still have lint / test errors. LMK once you want me to re-review
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.
:white_check_mark: kowshik24
:x: kowshik
kowshik seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.
@nirga @kowshik24 What is the status of the changes here? If this is stale, we are happy to contribute!
Would love for you to contribute @dinmukhamedm! I think @kowshik24 is no longer working on this
@nirga thanks, and sorry about the delayed response. This is requiring a little bit more work with counting tokens (and testing that) than I've expected, and I was out for a day. I'm still on this though