Skip to content

Commit efe1859

Browse files
authored
Merge branch 'main' into add-meter-scope-config
2 parents 60db25b + 4b56f63 commit efe1859

File tree

8 files changed

+112
-4
lines changed

8 files changed

+112
-4
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,21 @@ jobs:
269269
CXX_STANDARD: '20'
270270
run: ./ci/do_ci.ps1 cmake.maintainer.cxx20.stl.test
271271

272+
cmake_msvc_maintainer_abiv2_test:
273+
name: CMake msvc (maintainer mode, abiv2)
274+
runs-on: windows-latest
275+
steps:
276+
- uses: actions/checkout@v4
277+
with:
278+
submodules: 'recursive'
279+
- name: setup
280+
run: |
281+
./ci/setup_windows_ci_environment.ps1
282+
- name: run tests
283+
env:
284+
CXX_STANDARD: '20'
285+
run: ./ci/do_ci.ps1 cmake.maintainer.abiv2.test
286+
272287
cmake_with_async_export_test:
273288
name: CMake test (without otlp-exporter and with async export)
274289
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ if(POLICY CMP0091)
1919
cmake_policy(SET CMP0091 NEW)
2020
endif()
2121

22+
if(POLICY CMP0092)
23+
# https://cmake.org/cmake/help/latest/policy/CMP0092.html#policy:CMP0092 Make
24+
# sure the /W3 is not removed from CMAKE_CXX_FLAGS since CMake 3.15
25+
cmake_policy(SET CMP0092 OLD)
26+
endif()
27+
2228
# MSVC RTTI flag /GR should not be not added to CMAKE_CXX_FLAGS by default. @see
2329
# https://cmake.org/cmake/help/latest/policy/CMP0117.html
2430
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0")

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
[![Build
66
Status](https://github.com/open-telemetry/opentelemetry-cpp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-cpp/actions)
77
[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-cpp?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-cpp/releases/)
8+
[![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)
9+
[![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)
810

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

ci/do_ci.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,33 @@ switch ($action) {
184184
exit $exit
185185
}
186186
}
187+
"cmake.maintainer.abiv2.test" {
188+
cd "$BUILD_DIR"
189+
cmake $SRC_DIR `
190+
-DWITH_OTLP_GRPC=ON `
191+
-DWITH_OTLP_HTTP=ON `
192+
-DWITH_OTLP_RETRY_PREVIEW=ON `
193+
-DOTELCPP_MAINTAINER_MODE=ON `
194+
-DWITH_NO_DEPRECATED_CODE=ON `
195+
-DWITH_ABI_VERSION_1=OFF `
196+
-DWITH_ABI_VERSION_2=ON `
197+
-DVCPKG_TARGET_TRIPLET=x64-windows `
198+
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
199+
$exit = $LASTEXITCODE
200+
if ($exit -ne 0) {
201+
exit $exit
202+
}
203+
cmake --build . -j $nproc
204+
$exit = $LASTEXITCODE
205+
if ($exit -ne 0) {
206+
exit $exit
207+
}
208+
ctest -C Debug
209+
$exit = $LASTEXITCODE
210+
if ($exit -ne 0) {
211+
exit $exit
212+
}
213+
}
187214
"cmake.with_async_export.test" {
188215
cd "$BUILD_DIR"
189216
cmake $SRC_DIR `

exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ namespace tld
21412141

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

21472147
UINT8 inMeta = arity | static_cast<UINT8>(type);

exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ class Tracer : public opentelemetry::trace::Tracer,
590590
return result;
591591
}
592592

593+
#if OPENTELEMETRY_ABI_VERSION_NO == 1
593594
/**
594595
* @brief Force flush data to Tracer, spending up to given amount of microseconds to flush.
595596
* NOTE: this method has no effect for the realtime streaming Tracer.
@@ -615,6 +616,7 @@ class Tracer : public opentelemetry::trace::Tracer,
615616
etwProvider().close(provHandle);
616617
}
617618
}
619+
#endif
618620

619621
/**
620622
* @brief Add event data to span associated with tracer.
@@ -736,7 +738,18 @@ class Tracer : public opentelemetry::trace::Tracer,
736738
/**
737739
* @brief Tracer destructor.
738740
*/
739-
virtual ~Tracer() { CloseWithMicroseconds(0); }
741+
virtual ~Tracer()
742+
{
743+
#if OPENTELEMETRY_ABI_VERSION_NO == 1
744+
CloseWithMicroseconds(0);
745+
#else
746+
// Close once only
747+
if (!isClosed_.exchange(true))
748+
{
749+
etwProvider().close(provHandle);
750+
}
751+
#endif
752+
}
740753
};
741754

742755
/**
@@ -893,6 +906,34 @@ class Span : public opentelemetry::trace::Span
893906
owner_.AddEvent(*this, name, timestamp, attributes);
894907
}
895908

909+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
910+
911+
/**
912+
* Add link (ABI).
913+
*
914+
* See comments about sampling in @ref opentelemetry::trace::Span
915+
*
916+
* @since ABI_VERSION 2
917+
*/
918+
void AddLink(const trace::SpanContext & /*target*/,
919+
const common::KeyValueIterable & /*attrs*/) noexcept override
920+
{
921+
// FIXME: What to do with links?
922+
}
923+
924+
/**
925+
* Add links (ABI).
926+
*
927+
* See comments about sampling in @ref opentelemetry::trace::Span
928+
*
929+
* @since ABI_VERSION 2
930+
*/
931+
void AddLinks(const trace::SpanContextKeyValueIterable & /*links*/) noexcept override
932+
{
933+
// FIXME: What to do with links?
934+
}
935+
#endif
936+
896937
/**
897938
* @brief Set Span status
898939
* @param code Span status code.
@@ -1116,7 +1157,13 @@ class TracerProvider : public opentelemetry::trace::TracerProvider
11161157
nostd::shared_ptr<opentelemetry::trace::Tracer> GetTracer(
11171158
nostd::string_view name,
11181159
nostd::string_view args = "",
1119-
nostd::string_view schema_url = "") noexcept override
1160+
nostd::string_view schema_url = ""
1161+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
1162+
,
1163+
// FIXME: This is a temporary workaround to avoid breaking compiling.
1164+
const common::KeyValueIterable * /*attributes*/ = nullptr
1165+
#endif
1166+
) noexcept override
11201167
{
11211168
UNREFERENCED_PARAMETER(args);
11221169
UNREFERENCED_PARAMETER(schema_url);

exporters/etw/test/etw_perf_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ class ETWProviderStressTest
116116
void Teardown()
117117
{
118118
span_->End();
119+
# if OPENTELEMETRY_ABI_VERSION_NO == 1
119120
tracer_->CloseWithMicroseconds(0);
121+
# endif
120122
}
121123
};
122124

exporters/etw/test/etw_tracer_test.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ TEST(ETWTracer, TracerCheck)
183183
}
184184
EXPECT_NO_THROW(topSpan->End());
185185
}
186-
186+
# if OPENTELEMETRY_ABI_VERSION_NO == 1
187187
EXPECT_NO_THROW(tracer->CloseWithMicroseconds(0));
188+
# endif
188189
}
189190

190191
// Lowest decoration level -> smaller ETW event size.
@@ -233,7 +234,9 @@ TEST(ETWTracer, TracerCheckMinDecoration)
233234
}
234235
EXPECT_NO_THROW(aSpan->End());
235236
}
237+
# if OPENTELEMETRY_ABI_VERSION_NO == 1
236238
tracer->CloseWithMicroseconds(0);
239+
# endif
237240
}
238241

239242
// Highest decoration level -> larger ETW event size
@@ -284,7 +287,9 @@ TEST(ETWTracer, TracerCheckMaxDecoration)
284287
}
285288
EXPECT_NO_THROW(aSpan->End());
286289
}
290+
# if OPENTELEMETRY_ABI_VERSION_NO == 1
287291
tracer->CloseWithMicroseconds(0);
292+
# endif
288293
}
289294

290295
TEST(ETWTracer, TracerCheckMsgPack)
@@ -322,7 +327,9 @@ TEST(ETWTracer, TracerCheckMsgPack)
322327
}
323328
EXPECT_NO_THROW(aSpan->End());
324329
}
330+
# if OPENTELEMETRY_ABI_VERSION_NO == 1
325331
tracer->CloseWithMicroseconds(0);
332+
# endif
326333
}
327334

328335
/**
@@ -451,8 +458,10 @@ TEST(ETWTracer, GlobalSingletonTracer)
451458
EXPECT_NE(traceId1, traceId2);
452459
EXPECT_EQ(traceId1, traceId3);
453460

461+
# if OPENTELEMETRY_ABI_VERSION_NO == 1
454462
localTracer->CloseWithMicroseconds(0);
455463
globalTracer.CloseWithMicroseconds(0);
464+
# endif
456465
}
457466

458467
TEST(ETWTracer, AlwayOffSampler)

0 commit comments

Comments
 (0)