Skip to content

🚀 Feature: Callback Hooks for LLM Instrumentation Libraries #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
kujjwal02 opened this issue Apr 13, 2025 · 6 comments
Open
1 task done

🚀 Feature: Callback Hooks for LLM Instrumentation Libraries #2813

kujjwal02 opened this issue Apr 13, 2025 · 6 comments

Comments

@kujjwal02
Copy link

Which component is this feature for?

Bedrock Instrumentation

🔖 Feature description

Ability to pass a callback hook to the instrumentors which takes in the span aditiona attibutes line request and response.
The callback function can update the spans with new additiona attributes

🎤 Why is this feature needed ?

It will allow us to record more metrics and add more attributes which are not already implemeted.
This will allow us to extend the functionaly of the instrumentor using custom logic without waiting the functionality to be implemented in the core library.

Eg, I want the below 2 features asap

  • Add a metrics that directly tracks the cost of the llm
  • Bedrock converse api instrumentor does not support prompt caching tracking yet

Would love to contribute and implement these features directly, but having a callback hook will allow us to not wait for it (or any other custom attributes which does not make sense to core library, eg org_id, etc..) to be part of the core library

✌️ How do you aim to achieve this?

Not fully sure yet.
Maybe something like how Django Instrumentor does it.
Request and Response hooks

🔄️ Additional Information

No response

👀 Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

Yes I am willing to submit a PR!

@nirga
Copy link
Member

nirga commented Apr 14, 2025

@kujjwal02 sounds good - I would just add it directly in the instrumentation :)

@kujjwal02
Copy link
Author

Hi @nirga
You mean the cost tracking and prompt caching feature or the hooks?

@nirga
Copy link
Member

nirga commented Apr 14, 2025

Ah I mean just implement it directly without the hooks - we're happy to support it quickly :)

@kujjwal02
Copy link
Author

Awesome, Thanks.

Any thoughts on hooks though?
Happy to work a PR with a v0 implementation for bedrock instrumentor if you believe it will add value.

@nirga
Copy link
Member

nirga commented Apr 14, 2025

I'm fine with adding hooks but would love for an upstream contributiion to the prompt caching + cost tracking feature you mentioned :)

@kujjwal02
Copy link
Author

I can take up both prompt caching + cost tracking and hook and submit a PR asap (separately).
prioritizing the prompt caching + cost tracking

Let me know if that works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants