Skip to content
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

[Bug]: Logfire log not wrapped in request span #4202

Closed
ionflow opened this issue Jun 14, 2024 · 9 comments
Closed

[Bug]: Logfire log not wrapped in request span #4202

ionflow opened this issue Jun 14, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@ionflow
Copy link

ionflow commented Jun 14, 2024

What happened?

When making a request using LiteLLM in a fastapi logfire project logs are not wrapped in the span where the request is logged.
Screenshot 2024-06-14 at 1 12 40 PM

When you collapse the span you can see it is outside of it.
Screenshot 2024-06-14 at 2 42 12 PM

I would expect the Chat Completion log to be part of the span like other libraries (instructor/openai client).

Relevant log output

No response

Twitter / LinkedIn details

No response

@ionflow ionflow added the bug Something isn't working label Jun 14, 2024
@ishaan-jaff
Copy link
Contributor

@elisalimli any chance you can take a look at this one / help us with this ?

@krrishdholakia
Copy link
Contributor

krrishdholakia commented Jun 15, 2024

is logfire otel compatible? wondering if we can just migrate to our native otel integration - https://docs.litellm.ai/docs/proxy/logging#logging-proxy-inputoutput-in-opentelemetry-format

Because Pydantic Logfire is built on OpenTelemetry, ...

it looks like it's otel compatible, but i can't find docs on logging to it via just otel

@elisalimli
Copy link
Contributor

@ishaan-jaff Seems like you are starting a new thread for success_handler. https://github.com/BerriAI/litellm/blob/main/litellm/utils.py#L3867

Logfire groups the spans using the context managers, I am suspicious if the cause of this issue is the threading.

@elisalimli
Copy link
Contributor

Replacing starting a new thread with calling the success_handler directly solved the issue. It looks like the started thread doesn't have the context managers.

@elisalimli
Copy link
Contributor

is logfire otel compatible? wondering if we can just migrate to our native otel integration - https://docs.litellm.ai/docs/proxy/logging#logging-proxy-inputoutput-in-opentelemetry-format

Because Pydantic Logfire is built on OpenTelemetry, ...

it looks like it's otel compatible, but i can't find docs on logging to it via just otel

Would it solve the issue of the non-nested spans?

@ionflow
Copy link
Author

ionflow commented Jun 15, 2024

@ishaan-jaff
Copy link
Contributor

Screenshot 2024-06-17 at 5 04 26 PM

Okay I can confirm our OTEL logger works with logfire, looks a lot cleaner too :)

@ishaan-jaff
Copy link
Contributor

Fix here: #4254

@ishaan-jaff
Copy link
Contributor

This should be fixed on 1.40.16 @ionflow

can you try this
litellm.callbacks = ["logfire"]

https://docs.litellm.ai/docs/observability/logfire_integration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants