Skip to content

Commit

Permalink
Merge branch 'main' into add-meter-scope-config
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff authored Feb 21, 2025
2 parents 60db25b + 4b56f63 commit efe1859
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

if(POLICY CMP0092)
# https://cmake.org/cmake/help/latest/policy/CMP0092.html#policy:CMP0092 Make
# sure the /W3 is not removed from CMAKE_CXX_FLAGS since CMake 3.15
cmake_policy(SET CMP0092 OLD)
endif()

# MSVC RTTI flag /GR should not be not added to CMAKE_CXX_FLAGS by default. @see
# https://cmake.org/cmake/help/latest/policy/CMP0117.html
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0")
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![Build
Status](https://github.com/open-telemetry/opentelemetry-cpp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-cpp/actions)
[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-cpp?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-cpp/releases/)
[![FOSSA License Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp.svg?type=shield&issueType=license)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp?ref=badge_shield&issueType=license)
[![FOSSA Security Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp.svg?type=shield&issueType=security)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp?ref=badge_shield&issueType=security)

The C++ [OpenTelemetry](https://opentelemetry.io/) client.

Expand Down
27 changes: 27 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,7 @@ namespace tld

void AddFieldInfo(UINT8 arity, Type type, UINT32 tags)
{
_tld_ASSERT((type & InTypeMask) == (type & 0xff), "InType out of range");
_tld_ASSERT((type & (Type)InTypeMask) == (type & 0xff), "InType out of range");
_tld_ASSERT((type & _tld_MAKE_TYPE(0, OutTypeMask)) == (Type)(type & 0xffffff00), "OutType out of range");

UINT8 inMeta = arity | static_cast<UINT8>(type);
Expand Down
51 changes: 49 additions & 2 deletions exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -615,6 +616,7 @@ class Tracer : public opentelemetry::trace::Tracer,
etwProvider().close(provHandle);
}
}
#endif

/**
* @brief Add event data to span associated with tracer.
Expand Down Expand Up @@ -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
}
};

/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1116,7 +1157,13 @@ class TracerProvider : public opentelemetry::trace::TracerProvider
nostd::shared_ptr<opentelemetry::trace::Tracer> 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);
Expand Down
2 changes: 2 additions & 0 deletions exporters/etw/test/etw_perf_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class ETWProviderStressTest
void Teardown()
{
span_->End();
# if OPENTELEMETRY_ABI_VERSION_NO == 1
tracer_->CloseWithMicroseconds(0);
# endif
}
};

Expand Down
11 changes: 10 additions & 1 deletion exporters/etw/test/etw_tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -322,7 +327,9 @@ TEST(ETWTracer, TracerCheckMsgPack)
}
EXPECT_NO_THROW(aSpan->End());
}
# if OPENTELEMETRY_ABI_VERSION_NO == 1
tracer->CloseWithMicroseconds(0);
# endif
}

/**
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit efe1859

Please sign in to comment.