-
Notifications
You must be signed in to change notification settings - Fork 415
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
[EXPORTER] Fix OTLP HTTP exporting in sync mode. #2193
Conversation
Signed-off-by: owent <[email protected]>
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.
Thanks for the fix.
From the bug report,
the lambda capture [&session_result]
causes a capture of a reference to a local variable, causing the bug.
From the fix,
the lambda capture [session_result]
now captures a shared pointer, presumably incrementing the reference counter upon capture.
From existing code,
the callback function in OtlpHttpClient::Export can be given to a session, with
auto session = createSession(message, std::move(result_callback));
and then the session, which owns the callback, is stored in running_sessions_
by:
addSession(std::move(opentelemetry::nostd::get<HttpSessionData>(session)));
So, when some code paths return from ::Export() on timeout, the callback is kept elsewhere already, and local variables (in the old code) are destroyed.
Please:
-
Confirm my understanding is correct
-
Detail where / when is the destructor called for the lambda capture
[session_result]
, that would decrement the last reference to the session_result, and destroy the object created by make_shared in the fix ... I don't understand this part.
|
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.
LGTM, thanks for the fix and clarifications.
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.
Looks good. Thanks for the fix. This part of code has lots of edge scenarios, would be good to extend the unit-tests to cover them sometime later.
/easycla |
Seems this current fix requires a heap allocation, even this is sync Export. And the heap allocation is only for the edge case (timeout). Wondering is it possible to avoid the heap allocation on ExportResult here? |
By now, I have no idea without break the behaviour of return value. |
Fixes #2191
Changes
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes