Skip to content

Added feature flag for asynchronous export - #1295

Merged
lalitb merged 2 commits into
open-telemetry:async-changesfrom
DebajitDas:async-changes
Mar 31, 2022
Merged

lalitb merged 2 commits into
open-telemetry:async-changesfrom
DebajitDas:async-changes

Conversation

@DebajitDas

Copy link
Copy Markdown
Member

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.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@DebajitDas
DebajitDas requested a review from a team March 29, 2022 08:59
@lalitb

lalitb commented Mar 30, 2022

Copy link
Copy Markdown
Member

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).

@owent

owent commented Mar 30, 2022

Copy link
Copy Markdown
Member

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 -DENABLE_ASYNC_EXPORT for bazel options and add -DENABLE_ASYNC_EXPORT=ON for cmake options in do_ci.sh/do_ci.ps1

const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans) noexcept
override;

#ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please also put max_concurrent_requests in OtlpHttpExporterOptions into ENABLE_ASYNC_EXPORT ? It's useless when async exporting is disabled.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &records) noexcept
override;

# ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread CMakeLists.txt

option(WITH_ASYNC_EXPORT_PREVIEW "Whether enable async export" OFF)

if(WITH_ASYNC_EXPORT_PREVIEW)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

* logged in this case. */
}
}
#ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should if (is_export_async_ == false) only be checked when ENABLE_ASYNC_EXPORT is defined?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

bool is_export_async = false) noexcept
: exporter_(std::move(exporter)), is_export_async_(is_export_async)
: exporter_(std::move(exporter)),
#ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

max_queue_size_(max_queue_size),
scheduled_delay_millis_(scheduled_delay_millis),
max_export_batch_size_(max_export_batch_size),
# ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_export_async will not be declared without ENABLE_ASYNC_EXPORT in BatchSpanProcessorOptions. I think we should also remove is_export_async_ here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* Determines whether the export happens asynchronously.
* Default implementation is synchronous.
*/
bool is_export_async = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also remove is_export_async_ in BatchLogProcessor and BatchSpanProcessor ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/* Alert user of the failed export */
}
}
# ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

nostd::span<std::unique_ptr<Recordable>>(spans_arr.data(), spans_arr.size()));
NotifyCompletion(notify_force_flush, synchronization_data_);
}
#ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

nostd::span<std::unique_ptr<Recordable>>(records_arr.data(), records_arr.size()));
NotifyCompletion(notify_force_flush, synchronization_data_);
}
# ifdef ENABLE_ASYNC_EXPORT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@owent owent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
The rest of the things is adding CI actions to test the async feature.(with and without)

@DebajitDas

Copy link
Copy Markdown
Member Author

Could this PR be merged? I would add max export changes once this is merged.

@owent

owent commented Mar 31, 2022

Copy link
Copy Markdown
Member

@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.

@lalitb

lalitb commented Mar 31, 2022

Copy link
Copy Markdown
Member

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

Good point. Yes please create a issue to fix it @owent

@lalitb

lalitb commented Mar 31, 2022

Copy link
Copy Markdown
Member

@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.

Thanks, Have added you to approvers now. Seems got missed somehow.

@lalitb

lalitb commented Mar 31, 2022

Copy link
Copy Markdown
Member

@DebajitDas - Merging this, the CI test and max_export can be added in separate PR.

@lalitb
lalitb merged commit ad3bdfe into open-telemetry:async-changes Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants