Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ jobs:
sudo ./ci/setup_thrift.sh
./ci/do_ci.sh cmake.test

cmake_with_async_export_test:
name: CMake test (without otlp-exporter and with async export)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
- name: run cmake tests (without otlp-exporter)
run: |
sudo ./ci/setup_thrift.sh
./ci/do_ci.sh cmake.with_async_export.test

cmake_absel_stl_test:
name: CMake test (with abseil)
runs-on: ubuntu-latest
Expand Down Expand Up @@ -150,6 +166,28 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh bazel.test

bazel_test_async:
name: Bazel with async export
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v3
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_test
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
run: ./ci/do_ci.sh bazel.with_async_export.test

bazel_with_abseil:
name: Bazel with external abseil
runs-on: ubuntu-latest
Expand Down Expand Up @@ -355,6 +393,23 @@ jobs:
- name: run otprotocol test
run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.test

windows_with_async_export:
name: CMake (With async export) -> exporter proto
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: setup
run: |
./ci/setup_windows_cmake.ps1
./ci/setup_windows_ci_environment.ps1
./ci/install_windows_protobuf.ps1
- name: run cmake test
run: ./ci/do_ci.ps1 cmake.with_async_export.test
- name: run otprotocol test
run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.with_async_export.test

windows_bazel:
name: Bazel Windows
runs-on: windows-2019
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: 'Mark and close stale issues'
name: "Mark and close stale issues"
Comment thread
ThomsonTan marked this conversation as resolved.
on:
schedule:
- cron: '30 1 * * *'
- cron: "30 1 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5
with:
stale-issue-message: 'This issue was marked as stale due to lack of activity.'
stale-issue-message: "This issue was marked as stale due to lack of activity."
days-before-issue-stale: 60
exempt-issue-labels: 'do-not-stale'
exempt-issue-labels: "do-not-stale"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Increment the:

## [Unreleased]

* [EXPORTER] OTLP http exporter allow concurrency session ([#1209](https://github.com/open-telemetry/opentelemetry-cpp/pull/1209))
* [EXT] `curl::HttpClient` use `curl_multi_handle` instead of creating a thread
for every request and it's able to reuse connections now. ([#1317](https://github.com/open-telemetry/opentelemetry-cpp/pull/1317))

## [1.4.1] 2022-06-19

* [METRICS SDK] Fix variables inizialization [#1430](https://github.com/open-telemetry/opentelemetry-cpp/pull/1430)
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ option(WITH_EXAMPLES "Whether to build examples" ON)

option(WITH_METRICS_PREVIEW "Whether to build metrics preview" OFF)
option(WITH_LOGS_PREVIEW "Whether to build logs preview" OFF)
option(WITH_ASYNC_EXPORT_PREVIEW "Whether enable async export" OFF)

find_package(Threads)

Expand Down
4 changes: 4 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@ if(WIN32)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_MSGPACK)
endif()
endif()

if(WITH_ASYNC_EXPORT_PREVIEW)
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT)
endif()
33 changes: 19 additions & 14 deletions api/include/opentelemetry/common/spin_lock_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ class SpinLockMutex
SpinLockMutex &operator=(const SpinLockMutex &) = delete;
SpinLockMutex &operator=(const SpinLockMutex &) volatile = delete;

static inline void fast_yield() noexcept
{
// Issue a Pause/Yield instruction while spinning.
#if defined(_MSC_VER)
YieldProcessor();
#elif defined(__i386__) || defined(__x86_64__)
# if defined(__clang__)
_mm_pause();
# else
__builtin_ia32_pause();
# endif
#elif defined(__arm__)
__asm__ volatile("yield" ::: "memory");
#else
// TODO: Issue PAGE/YIELD on other architectures.
#endif
}

/**
* Attempts to lock the mutex. Return immediately with `true` (success) or `false` (failure).
*/
Expand Down Expand Up @@ -91,20 +109,7 @@ class SpinLockMutex
{
return;
}
// Issue a Pause/Yield instruction while spinning.
#if defined(_MSC_VER)
YieldProcessor();
#elif defined(__i386__) || defined(__x86_64__)
# if defined(__clang__)
_mm_pause();
# else
__builtin_ia32_pause();
# endif
#elif defined(__arm__)
__asm__ volatile("yield" ::: "memory");
#else
// TODO: Issue PAGE/YIELD on other architectures.
#endif
fast_yield();
}
// Yield then try again (goal ~100ns)
std::this_thread::yield();
Expand Down
34 changes: 34 additions & 0 deletions api/include/opentelemetry/common/timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,39 @@ class SteadyTimestamp
private:
int64_t nanos_since_epoch_;
};

class DurationUtil
{
public:
template <class Rep, class Period>
static std::chrono::duration<Rep, Period> AdjustWaitForTimeout(
std::chrono::duration<Rep, Period> timeout,
std::chrono::duration<Rep, Period> indefinite_value) noexcept
{
// Do not call now() when this duration is max value, now() may have a expensive cost.
if (timeout == std::chrono::duration<Rep, Period>::max())
{
return indefinite_value;
}

// std::future<T>::wait_for, std::this_thread::sleep_for, and std::condition_variable::wait_for
// may use steady_clock or system_clock.We need make sure now() + timeout do not overflow.
auto max_timeout = std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(
std::chrono::steady_clock::time_point::max() - std::chrono::steady_clock::now());
if (timeout >= max_timeout)
{
return indefinite_value;
}
max_timeout = std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(
std::chrono::system_clock::time_point::max() - std::chrono::system_clock::now());
if (timeout >= max_timeout)
{
return indefinite_value;
}

return timeout;
}
};

} // namespace common
OPENTELEMETRY_END_NAMESPACE
47 changes: 46 additions & 1 deletion ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $action = $args[0]

$SRC_DIR = (Get-Item -Path ".\").FullName

$BAZEL_OPTIONS = "--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW"
$BAZEL_OPTIONS = "--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW --copt=-DENABLE_ASYNC_EXPORT"
$BAZEL_TEST_OPTIONS = "$BAZEL_OPTIONS --test_output=errors"

if (!(test-path build)) {
Expand Down Expand Up @@ -48,6 +48,27 @@ switch ($action) {
exit $exit
}
}
"cmake.with_async_export.test" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DWITH_ASYNC_EXPORT_PREVIEW=ON `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
cmake --build .
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
ctest -C Debug
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
}
"cmake.exporter.otprotocol.test" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
Expand All @@ -69,10 +90,33 @@ switch ($action) {
exit $exit
}
}
"cmake.exporter.otprotocol.with_async_export.test" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DWITH_ASYNC_EXPORT_PREVIEW=ON `
-DWITH_OTPROTCOL=ON `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
cmake --build .
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
ctest -C Debug
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
}
"cmake.build_example_plugin" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DWITH_ASYNC_EXPORT_PREVIEW=ON `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
Expand All @@ -89,6 +133,7 @@ switch ($action) {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DWITH_ASYNC_EXPORT_PREVIEW=ON `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
Expand Down
Loading