-
Notifications
You must be signed in to change notification settings - Fork 510
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
AI tracking does not work properly in Python's asynchronous generator scenarios. #3823
Comments
Assigning to @getsentry/support for routing ⏲️ |
Hi @uraurora, thank you for opening this issue. I am having trouble understanding what you are trying to do, and what the problem is. Could you please provide specific steps on how to reproduce the problem? If possible, please provide a code snippet that we can run, so that we can see what you are trying to do. |
Hi, In simple terms, I use FastAPI as the backend, and at the same time, I want to record token consumption in the LLM interface with streaming responses, but after calling the interface, it seems that there are no related displays in the Sentry dashboard(Insights-AI-LLM Monitoring). The code is as follows:
|
Can you link us a transaction that is in the "Performance" tab on Sentry.io that contains the spans In general the spans you create must contain the data described here: https://develop.sentry.dev/sdk/telemetry/traces/modules/llm-monitoring/ If we have a link to a transaction, we can see if the spans in this transaction have the correct format. |
yes, here it is, Indeed, I suspect that I used incorrect span information. |
Hey @uraurora ! Yes, some of the span data is not correct. I have created a small sample script that creates correct spans: https://github.com/antonpirker/testing-sentry/blob/main/test-llm-manual-instrumentation/main.py One bigger thing is that Also notice that the If you also want to have the dollar amount spent than it is important to set the Hope this helps! |
Great! thank you for your assistance. Now the token consumption can display well |
Environment
SaaS (https://sentry.io/)
Steps to Reproduce
sentry_sdk.start_span(op="ai.chat_completions.create.xxx", name="xxx") as span
, and I'm not sure if the op value is set correctly.Expected Result
I hope the LLM Monitoring works well, but seems only no-stream api does
Actual Result
The stream api does not show anything. I'm not sure whether there's an issue with my configuration or if this method of invocation is not currently supported.
Product Area
Insights
Link
https://moflow.sentry.io/insights/ai/llm-monitoring/?project=4508239351447552&statsPeriod=24h
DSN
No response
Version
2.19.0
The text was updated successfully, but these errors were encountered: