8000 Merge branch 'main' into deprecate_event_logger · open-telemetry/opentelemetry-cpp@37f6452 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37f6452

Browse files
authored
Merge branch 'main' into deprecate_event_logger
2 parents 45145f1 + 181f1e5 commit 37f6452

File tree

5 files changed

+103
-3
lines changed

5 files changed

+103
-3
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

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/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)
0