-
Notifications
You must be signed in to change notification settings - Fork 423
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
Scope should be default constructable #1889
Comments
|
I logged similar issue in the past, with possible workaround: #1298 |
@sirzooro - thank you, I just added the default constructor and recompiled. @lalitb - Let's say we are wrapping an global 'active span' for a application within a class, and provide a startSpan api, which sets the ActiveSpan in trace::tracer as well,
We need to keep track of the scopes as well, but scope can't be made a member variable since it's not default constructible. |
@lalitb - unfortunately, default constructed Scopes crash! (gdb) bt Any idea how I can fix this?? |
I mentioned different solution in that issue - use unique_ptr to store Scope object. It looks that implicit move constructor works fine. Here is code snipped copied from that issue std::unique_ptr<opentelemetry::trace::Scope> scope;
if (...)
scope = std::unique_ptr<opentelemetry::trace::Scope>(new opentelemetry::trace::Scope(tracer->WithActiveSpan(span))); |
@sirzooro - that doesn't help... still get the destructor crash as above. |
@VivekSubr maybe that default constructor which you added breaks something? I use Scope move constructor when I put it into unique_ptr like in code above, and this works fine for me. |
@sirzooro - Crash happened without the default constructor... I have a deque as a member variable of a wrapper class, and it crashes with the above trace on destruction of the wrapper class. Commenting out the 'Detach' in Token destructor makes this crash go away. |
@VivekSubr - Sorry, I haven't been following up with this issue. Is this issue still relevant ? |
Closing. please reopen if the issue is still relevant. |
Is your feature request related to a problem?
Wrapping a span in a class so that'll be a global object necessitates keeping track of scopes as members... but making a scope as a member variable is difficult as it is not default constructible.
Describe the solution you'd like
Make Scope default constructible, ie add 'Scope() = default' to the class.
The text was updated successfully, but these errors were encountered: