Added feature flag for asynchronous export - #1295
Conversation
|
LGTM in general, @owent may want to have a look into this, specifically the batch span/log processor part. Also, we should add a CI action to test the async feature ( e.g, add another test similar to bazel_test which builds using ENABLE_ASYNC_EXPORT macro). |
Agree, I think we can just add |
| const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans) noexcept | ||
| override; | ||
|
|
||
| #ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
Could you please also put max_concurrent_requests in OtlpHttpExporterOptions into ENABLE_ASYNC_EXPORT ? It's useless when async exporting is disabled.
| const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &records) noexcept | ||
| override; | ||
|
|
||
| # ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
Could you please also remove max_concurrent_requests in OtlpHttpExporterOptions and OtlpHttpLogExporterOptions when we do not decalre ENABLE_ASYNC_EXPORT ? It's useless when async exporting is disabled.
|
|
||
| option(WITH_ASYNC_EXPORT_PREVIEW "Whether enable async export" OFF) | ||
|
|
||
| if(WITH_ASYNC_EXPORT_PREVIEW) |
There was a problem hiding this comment.
We should also add INTERFACE definitions into api/CMakeLists.txt.
if(WITH_LOGS_PREVIEW)
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT)
endif()So that when we use optentelemetry-cpp as a cmake module(find_package(opentelemetry-cpp CONFIG)) , this definition can be auto added into all targets that direct or indirectly depend on opentelemetry-cpp.
I find there are severval missing definitions in api/CMakeLists.txt and be add by add_definitions(). All definitions should be added by target_compile_definitions(opentelemetry_api INTERFACE ...) to be expoted by cmake.
We should avoid to use add_definitions(...) unless the definitions is only used by unit tests, should I create another issue to fix it? @lalitb @ThomsonTan
| * logged in this case. */ | ||
| } | ||
| } | ||
| #ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
Should if (is_export_async_ == false) only be checked when ENABLE_ASYNC_EXPORT is defined?
| bool is_export_async = false) noexcept | ||
| : exporter_(std::move(exporter)), is_export_async_(is_export_async) | ||
| : exporter_(std::move(exporter)), | ||
| #ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
is_export_async will not be declared without ENABLE_ASYNC_EXPORT in BatchSpanProcessorOptions. I think we should keep the same behaviour with SimpleSpanProcessor and just remove is_export_async_.
| max_queue_size_(max_queue_size), | ||
| scheduled_delay_millis_(scheduled_delay_millis), | ||
| max_export_batch_size_(max_export_batch_size), | ||
| # ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
is_export_async will not be declared without ENABLE_ASYNC_EXPORT in BatchSpanProcessorOptions. I think we should also remove is_export_async_ here.
| * Determines whether the export happens asynchronously. | ||
| * Default implementation is synchronous. | ||
| */ | ||
| bool is_export_async = false; |
There was a problem hiding this comment.
Should we also remove is_export_async_ in BatchLogProcessor and BatchSpanProcessor ?
| /* Alert user of the failed export */ | ||
| } | ||
| } | ||
| # ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
Just like in SimpleSpanProcessor, if (is_export_async_ == false) should only be checked when ENABLE_ASYNC_EXPORT is defined, or we should always call sync Export.
| nostd::span<std::unique_ptr<Recordable>>(spans_arr.data(), spans_arr.size())); | ||
| NotifyCompletion(notify_force_flush, synchronization_data_); | ||
| } | ||
| #ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
Just like in SimpleSpanProcessor, if (is_export_async_ == false) should only be checked when ENABLE_ASYNC_EXPORT is defined, or we should always call sync Export.
| nostd::span<std::unique_ptr<Recordable>>(records_arr.data(), records_arr.size())); | ||
| NotifyCompletion(notify_force_flush, synchronization_data_); | ||
| } | ||
| # ifdef ENABLE_ASYNC_EXPORT |
There was a problem hiding this comment.
Just like in SimpleSpanProcessor, if (is_export_async_ == false) should only be checked when ENABLE_ASYNC_EXPORT is defined, or we should always call sync Export.
owent
left a comment
There was a problem hiding this comment.
LGTM.
The rest of the things is adding CI actions to test the async feature.(with and without)
|
Could this PR be merged? I would add max export changes once this is merged. |
|
@lalitb I think this PR can be merged right now. I'm not in @open-telemetry/cpp-approvers right now, my approval can not let the process continue. |
Good point. Yes please create a issue to fix it @owent |
Thanks, Have added you to approvers now. Seems got missed somehow. |
|
@DebajitDas - Merging this, the CI test and max_export can be added in separate PR. |
Fixes # Adds feature flag for asynchronous export.
Changes for max export and wait on async export not triggered by shutdown/force-flush are pending
Changes
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes