openllmetry icon indicating copy to clipboard operation
openllmetry copied to clipboard

Feature: Support Prompt Caching

Open kowshik24 opened this issue 1 year ago • 2 comments
trafficstars

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_usage and _aset_token_usage functions to log caching metrics.
  • Added new span attributes for cache_creation_input_tokens and cache_read_input_tokens.
  • Updated streaming.py to support prompt caching metrics in streaming responses.

kowshik24 avatar Aug 16 '24 23:08 kowshik24

@kowshik24 note that you still have lint / test errors. LMK once you want me to re-review

nirga avatar Aug 25 '24 15:08 nirga

CLA assistant check
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.

CLAassistant avatar Aug 31 '24 16:08 CLAassistant

@nirga @kowshik24 What is the status of the changes here? If this is stale, we are happy to contribute!

dinmukhamedm avatar Oct 19 '24 03:10 dinmukhamedm

Would love for you to contribute @dinmukhamedm! I think @kowshik24 is no longer working on this

nirga avatar Oct 19 '24 05:10 nirga

@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

dinmukhamedm avatar Oct 20 '24 18:10 dinmukhamedm