diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86cba0c767..3d17ae2ca2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -269,6 +269,21 @@ jobs: CXX_STANDARD: '20' run: ./ci/do_ci.ps1 cmake.maintainer.cxx20.stl.test + cmake_msvc_maintainer_abiv2_test: + name: CMake msvc (maintainer mode, abiv2) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: setup + run: | + ./ci/setup_windows_ci_environment.ps1 + - name: run tests + env: + CXX_STANDARD: '20' + run: ./ci/do_ci.ps1 cmake.maintainer.abiv2.test + cmake_with_async_export_test: name: CMake test (without otlp-exporter and with async export) runs-on: ubuntu-latest diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index 72d80402b2..66f983065f 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -184,6 +184,33 @@ switch ($action) { exit $exit } } + "cmake.maintainer.abiv2.test" { + cd "$BUILD_DIR" + cmake $SRC_DIR ` + -DWITH_OTLP_GRPC=ON ` + -DWITH_OTLP_HTTP=ON ` + -DWITH_OTLP_RETRY_PREVIEW=ON ` + -DOTELCPP_MAINTAINER_MODE=ON ` + -DWITH_NO_DEPRECATED_CODE=ON ` + -DWITH_ABI_VERSION_1=OFF ` + -DWITH_ABI_VERSION_2=ON ` + -DVCPKG_TARGET_TRIPLET=x64-windows ` + "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + cmake --build . -j $nproc + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + ctest -C Debug + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + } "cmake.with_async_export.test" { cd "$BUILD_DIR" cmake $SRC_DIR ` diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 272558cead..5d0603454e 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -590,6 +590,7 @@ class Tracer : public opentelemetry::trace::Tracer, return result; } +#if OPENTELEMETRY_ABI_VERSION_NO == 1 /** * @brief Force flush data to Tracer, spending up to given amount of microseconds to flush. * NOTE: this method has no effect for the realtime streaming Tracer. @@ -615,6 +616,7 @@ class Tracer : public opentelemetry::trace::Tracer, etwProvider().close(provHandle); } } +#endif /** * @brief Add event data to span associated with tracer. @@ -736,7 +738,18 @@ class Tracer : public opentelemetry::trace::Tracer, /** * @brief Tracer destructor. */ - virtual ~Tracer() { CloseWithMicroseconds(0); } + virtual ~Tracer() + { +#if OPENTELEMETRY_ABI_VERSION_NO == 1 + CloseWithMicroseconds(0); +#else + // Close once only + if (!isClosed_.exchange(true)) + { + etwProvider().close(provHandle); + } +#endif + } }; /** @@ -893,6 +906,34 @@ class Span : public opentelemetry::trace::Span owner_.AddEvent(*this, name, timestamp, attributes); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + + /** + * Add link (ABI). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + void AddLink(const trace::SpanContext & /*target*/, + const common::KeyValueIterable & /*attrs*/) noexcept override + { + // FIXME: What to do with links? + } + + /** + * Add links (ABI). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + void AddLinks(const trace::SpanContextKeyValueIterable & /*links*/) noexcept override + { + // FIXME: What to do with links? + } +#endif + /** * @brief Set Span status * @param code Span status code. @@ -1116,7 +1157,13 @@ class TracerProvider : public opentelemetry::trace::TracerProvider nostd::shared_ptr GetTracer( nostd::string_view name, nostd::string_view args = "", - nostd::string_view schema_url = "") noexcept override + nostd::string_view schema_url = "" +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + , + // FIXME: This is a temporary workaround to avoid breaking compiling. + const common::KeyValueIterable * /*attributes*/ = nullptr +#endif + ) noexcept override { UNREFERENCED_PARAMETER(args); UNREFERENCED_PARAMETER(schema_url); diff --git a/exporters/etw/test/etw_perf_test.cc b/exporters/etw/test/etw_perf_test.cc index 06af94a5af..0c54aa1e9e 100644 --- a/exporters/etw/test/etw_perf_test.cc +++ b/exporters/etw/test/etw_perf_test.cc @@ -116,7 +116,9 @@ class ETWProviderStressTest void Teardown() { span_->End(); +# if OPENTELEMETRY_ABI_VERSION_NO == 1 tracer_->CloseWithMicroseconds(0); +# endif } }; diff --git a/exporters/etw/test/etw_tracer_test.cc b/exporters/etw/test/etw_tracer_test.cc index a546309b84..5833b6a733 100644 --- a/exporters/etw/test/etw_tracer_test.cc +++ b/exporters/etw/test/etw_tracer_test.cc @@ -183,8 +183,9 @@ TEST(ETWTracer, TracerCheck) } EXPECT_NO_THROW(topSpan->End()); } - +# if OPENTELEMETRY_ABI_VERSION_NO == 1 EXPECT_NO_THROW(tracer->CloseWithMicroseconds(0)); +# endif } // Lowest decoration level -> smaller ETW event size. @@ -233,7 +234,9 @@ TEST(ETWTracer, TracerCheckMinDecoration) } EXPECT_NO_THROW(aSpan->End()); } +# if OPENTELEMETRY_ABI_VERSION_NO == 1 tracer->CloseWithMicroseconds(0); +# endif } // Highest decoration level -> larger ETW event size @@ -284,7 +287,9 @@ TEST(ETWTracer, TracerCheckMaxDecoration) } EXPECT_NO_THROW(aSpan->End()); } +# if OPENTELEMETRY_ABI_VERSION_NO == 1 tracer->CloseWithMicroseconds(0); +# endif } TEST(ETWTracer, TracerCheckMsgPack) @@ -322,7 +327,9 @@ TEST(ETWTracer, TracerCheckMsgPack) } EXPECT_NO_THROW(aSpan->End()); } +# if OPENTELEMETRY_ABI_VERSION_NO == 1 tracer->CloseWithMicroseconds(0); +# endif } /** @@ -451,8 +458,10 @@ TEST(ETWTracer, GlobalSingletonTracer) EXPECT_NE(traceId1, traceId2); EXPECT_EQ(traceId1, traceId3); +# if OPENTELEMETRY_ABI_VERSION_NO == 1 localTracer->CloseWithMicroseconds(0); globalTracer.CloseWithMicroseconds(0); +# endif } TEST(ETWTracer, AlwayOffSampler)