-
Notifications
You must be signed in to change notification settings - Fork 175
Add new_context to instrumentation #1499
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
tests/test_logfire.py
Outdated
| tagged = logfire.with_tags('test_instrument') | ||
|
|
||
| def context_factory(): | ||
| return {'new_contex': 123} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't discuss this context factory API, I'm not sure if I like it or understand the point. It's certainly not being tested here, new_contex doesn't do anything or appear in the exported spans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mention it in the original issue because it wasn't something I'd considered. But when I realized I'd just be using attach_context behind the scenes, it seemed preferable to allow users the option to provide input for attach_context.
If you're against it, it's not that useful for me and I don't mind cutting it. But if it's worth keeping I'll add better testing for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feature isn't really compelling enough without the span link
I'll look at adding it, just trying to determine the best approach. |
As per #1493, it's current a bit awkward to remove context from instrumentation. This PR adds the "new_context" keyword to ensure designated function calls do not inherit from parent spans.
Here is an example from the new test:
Alternatively, new_context can be set to
True, which is the same asnew_context=dict.