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

API access to the span generated by the @logfire.instrument() decorator #674

Open
milest opened this issue Dec 13, 2024 · 0 comments
Open
Assignees

Comments

@milest
Copy link

milest commented Dec 13, 2024

Description

(as discussed on Slack)

I'd like to have access to the span generated by the decorator. eg of how I'm hoping to use it:

@logfire.instrument()
def lf_example():
    result = do_some_things()
    if result:
        # Set an attribute on the current logfire span from the decorator
        logfire.set_attribute(status='OK')
    else:
        logfire.set_attribute(status='ERROR')

An idea explored on Slack was to use otel apis:

from opentelemetry.trace.propagation import get_current_span
get_current_span().set_attribute(...)

But it seems that the otel apis don't work with non-primatives.

An idea was to add a logfire.get_current_span api that would get the LogfireSpan instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants