-
Notifications
You must be signed in to change notification settings - Fork 417
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
Why do I need to keep track of the lifetime of the scope/span objects myself? #2249
Comments
Yes sort of. Though you can also use RunTimeStorage to avoid changing the function prototypes in some scenarios. So to create span in func1() and end in func2(), without passing scope/span objects (not tested to compile): void func1() {
auto span1 = tracer->StartSpan("span1");
tracer_api::context::RuntimeContext::GetCurrent().SetValue("myspan", span1);
func2();
}
void func2() {
.... some work
auto span1 = context::RuntimeContext::GetCurrent().GetValue("myspan");
span1->End();
tracer_api::context::RuntimeContext::GetCurrent().SetValue("myspan", NoopSpan{}); // to remove all references of span1
} |
Also, I think it is worth evaluating if the support can be added to explicitly make the
And then somewhere else:
Contributions are in-general welcome to add a proposal implementation to discuss further. |
This issue is available for anyone to work on. Make sure to reference this issue in your pull request. |
Storing in runtime context might work for me. I can activate it when needed, I just can't easily maintain a reference myself. I am using this though |
This issue was marked as stale due to lack of activity. |
I'm trying to instrument some code that's used in a library that has very specific code flow. Keeping track of the spans and scopes myself is very tricky because I can't pass the spans/scopes. I have to store them in some locally managed storage.
In other tracing libraries (not c++), I've always just been able to do the equivalent of
tracer->StartSpan()
, and then some time latertracer->CurrentSpan()->End()
or whatever. Is there advice on managing scopes if their lifetime is complicated? The only ways I see it working are global state, or polluting the types of all my functions to pass the scope around.The text was updated successfully, but these errors were encountered: