-
Notifications
You must be signed in to change notification settings - Fork 1
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
Automatically scoped span #9
Comments
This is what the I'd love to have something like This would be nice to have because using I've thought that maybe this could be done with a The alternative is something like the extremely experimental OpenTelemetry::Integration::namespace, but the interface there is very sketchy, so I wouldn't use that yet for anything but thought experiments. I'll leave this open for now to see if maybe I'm wrong and this is doable, but I'm not sure it is. |
I think you'd suggested it elsewhere (or used it in an example?), so I'll just add that for my use cases putting $span->end() in a defer seems to work fine. (Including recording errors or setting attributes). Unless there are problems with that I haven't noticed yet, I think it's cleaner than the in_span() feature. So basically I'm doing okay for the feature I was asking for; and I appreciate your work exploring "magic"! I dabbled a little with Integration::namespace, but for the project I'm instrumenting the code isn't structured well enough to get good spans. If I was doing a new project in Perl I'd try using it from the beginning and structure my code accordingly. |
I think for the more general case, the tricky part is the context management rather than ending the span on destruction. We can probably add that (although I'd have to check we're not going against the more obscure parts of the spec), but if the span has been attached to a context (which should be most cases) it won't actually go out of scope because a reference will be stored in the context, and we don't have a way to abstract away the dynamic scoping of the context without the manual call. |
This might just be another documentation request.
In my (still very limited) tests this seems like a commonly useful construct:
I don't know if it's possible, but something like
that'd do both in one would be a very useful (and Perl-ish?) feature.
The text was updated successfully, but these errors were encountered: