pydantic / logfire

Uncomplicated Observability for Python and beyond! 🪵🔥
https://docs.pydantic.dev/logfire/
MIT License
1.62k stars 46 forks source link

Don't configure automatically #219

Closed alexmojaki closed 3 weeks ago

alexmojaki commented 4 weeks ago

Closes https://github.com/pydantic/logfire/issues/194

Step 2 there isn't done but I realize now that it's not really a blocker, and there's strong demand for this change.

The implementation here is simple but not ideal. In particular logfire.span etc will still do a lot of processing which will slow things down and maybe even raise errors, it's just that the actual OTEL span will be a no-op. But making logfire.span a proper no-op is nontrivial since it still needs to return a context manager with methods, and that work overlaps with https://github.com/pydantic/logfire/pull/146. Optimizing this can be done later, and the same strategy can also be applied to checking if the span/log will be sampled out or if instrumentation is currently suppressed.

logfire.instrument_<module> will also apply instrumentation including patching, but (1) that's necessary to allow calling configure later and having it all just work and (2) that's how OTEL works anyway.

codecov[bot] commented 4 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:loudspeaker: Thoughts on this report? Let us know!

alexmojaki commented 4 weeks ago

I just want to confirm that none of the behaviour actually changes with this PR?

No, the behaviour does actually change. We can have a deprecation period (1 week?) if you want but I'm not sure it's worth it.

cloudflare-pages[bot] commented 3 weeks ago

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 172a742
Status: âœ…  Deploy successful!
Preview URL: https://d34b3a64.logfire-docs.pages.dev
Branch Preview URL: https://alex-no-auto-configure.logfire-docs.pages.dev

View logs