Skip to content

[Javascript] Add LLM monitoring support #12981

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

Closed
AbhiPrasad opened this issue Jul 18, 2024 · 4 comments
Closed

[Javascript] Add LLM monitoring support #12981

AbhiPrasad opened this issue Jul 18, 2024 · 4 comments
Assignees

Comments

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Jul 18, 2024

Problem Statement

Add support for https://docs.sentry.io/product/insights/llm-monitoring/ in JavaScript

Solution Brainstorm

Things we can support:

@colin-sentry
Copy link
Member

Currently difficult because we need to annotate the LLM spans with the pipeline span's name, and there is no nice way to pass context down in a runtime agnostic way

In python this is done with ContextVar

Maybe we can convert the pipeline span into a transaction, and pull down its name into the children that way?

@AbhiPrasad
Copy link
Member Author

In python this is done with ContextVar

In Node.js we can use AsyncLocalStorage, which is what the SDK uses to maintain parent-child relationship between spans even with async behaviour.

In fact the Sentry scope lives on-top of async local storage in the Node SDK, so you can just store stuff on the scope to use.

@mydea mydea changed the title Add LLM monitoring support for JavaScript [Javascript] Add LLM monitoring support Oct 8, 2024
@linear linear bot added the Migrated label Jan 9, 2025
@staticshock
Copy link
Contributor

Where did this net out? Can I roll it by hand using lower level primitives / patterns via the in the javascript SDK?

@AbhiPrasad
Copy link
Member Author

@staticshock we have automatic instrumentation for Vercel's ai library: https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/vercelai/

For other libraries, you have to add manual instrumentation. We documented the span conventions you can use for that here: https://develop.sentry.dev/sdk/telemetry/traces/modules/llm-monitoring/

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

3 participants