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

logfire-noop #121

Open
samuelcolvin opened this issue May 5, 2024 · 4 comments · May be fixed by #146
Open

logfire-noop #121

samuelcolvin opened this issue May 5, 2024 · 4 comments · May be fixed by #146
Assignees

Comments

@samuelcolvin
Copy link
Member

samuelcolvin commented May 5, 2024

Description

My idea is that we release logfire-noop, this package has no dependencies and allows third-party libraries to integrate with logfire while still giving their users complete choice over whether to actually use Logfire.

The idea is that logfire-noop would contain two modules: logfire_noop and logfire_if_installed (name TBC)

logfire_noop exports types matching logfire but that do nothing, or do the minimum required for code to run, e.g. logfire.span() needs to return a context manager.

logfire_if_installed behaves like this:

  • when logfire is installed, it just the contents of logfire
  • when logfire is not installed, it just the contents of logfire_noop

Third party libraries would wuite code like this:

import logfire_if_installed

...

def my_library_method(...):
    ...
    with logfire.span('doing a thing {sniffle=}', sniffle=rofl):
        ...
@samuelcolvin
Copy link
Member Author

@willbakst might want to use this in https://github.com/Mirascope/mirascope.

@Kludex
Copy link
Member

Kludex commented May 6, 2024

I think we should use the same namespace for logfire-noop and logfire i.e. if you install logfire-noop, you'll be able to access the same methods as logfire.

We should probably create the package within this repository, and have a job that checks that everything you can use on logfire can be used on logfire_noop.

@Kludex Kludex self-assigned this May 6, 2024
@jackmpcollins
Copy link

Would it be possible for logfire-noop to have the same effect as instrumenting with opentelemetry-api? So that packages instrumented this way become compatible with both opentelemetry and logfire. I would definitely use this in https://github.com/jackmpcollins/magentic Relevant issue there jackmpcollins/magentic#136

@adriangb
Copy link
Member

adriangb commented May 6, 2024

@jackmpcollins I agree, I think that's where this is headed

@Kludex Kludex linked a pull request May 7, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants