-
Notifications
You must be signed in to change notification settings - Fork 170
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
RFI: How to close all open spans and scopes #1139
Comments
That's pretty much the pattern I would use, and I don't think there is a more elegant way. It doesn't look quite right visually, though. You detach a scope, not a context. This (untested) snippet might be closer to what you want (which is based on how our auto-instrumentation packages do it): while ($scope = Context::storage()->scope()) {
$scope->detach();
$span = Span::fromContext($scope->context());
$span->end();
} One thing that you might also need to check for is that if you have started any spans but not activated them, I think they would be lost. |
Thank you so much for the fast and helpful response! Will try that out / looking at the auto-instrumentation. |
A few notes, I made a contract test for this to ensure the behavior remains stable:
Given that a bunch of these things are internal it may be better to add this to the SDK for folks that need it. A few notes:
|
I made PR #1140 let me know what you think. |
@huggsboson DebugScope can now be disabled entirely, since #1205 so with that turned off you won't get the notices. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Thanks for the wonderfully updated library. We were using a very old version with memory leaks and tons of bugs, it's great to see this getting love and adhereing to the specs.
We have a pattern in our application where it will randomly redirect and exit within certain requests. For those cases with the old lib we had a pattern in the exit handler where we would end() any live spans up the tree so the spans would get sent out but with the new library it's much less clear how to do that. Additionally the new DebugScope will trigger_error all over the place for the left open scopes.
The thing I was thinking about doing is (I haven't tested this, wanted to get feedback first in case I was missing anything obvious):
Is there a more elegant way to do what I'm trying to do than this for this ugly situation that is out of my control?
The text was updated successfully, but these errors were encountered: