Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update usage of ABI 2 to match breaking changes in opentelemetry-cpp v1.16.0 release #466

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions exporters/fluentd/test/trace/fluentd_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,12 @@ TEST(FluentdExporter, SendTraceEvents) {
auto processor = std::unique_ptr<SpanProcessor>(
new sdktrace::SimpleSpanProcessor(std::move(exporter)));

auto provider = nostd::shared_ptr<trace::TracerProvider>(
auto provider = std::shared_ptr<sdktrace::TracerProvider>(
new TracerProvider(std::move(processor)));

std::shared_ptr<trace::TracerProvider> api_provider = provider;
// Set the global trace provider
opentelemetry::trace::Provider::SetTracerProvider(provider);
opentelemetry::trace::Provider::SetTracerProvider(api_provider);

std::string providerName = "MyInstrumentationName";
auto tracer = provider->GetTracer(providerName);
Expand Down Expand Up @@ -426,8 +427,16 @@ TEST(FluentdExporter, SendTraceEvents) {
}
span1->End(); // end MySpanL1

#if OPENTELEMETRY_ABI_VERSION_NO == 1
tracer->ForceFlushWithMicroseconds(1000);
tracer->CloseWithMicroseconds(0);
#else
/* In ABI 2 >= otel-cpp v1.16.0, only the sdk Tracer objects
* have the ForceFlush...() and Close...() methods. The Close()
* method simply calls ForceFlush(). Use the SDK provider ForceFlush() instead.
*/
provider->ForceFlush();
#endif /* OPENTELEMETRY_ABI_VERSION_NO == 1 */

testServer.WaitForEvents(6, 200); // 6 batches must arrive in 200ms
testServer.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ class MockTracer : public opentelemetry::trace::Tracer
MOCK_METHOD(nostd::shared_ptr<trace::Span>, StartSpanInternal,
(nostd::string_view name, trace::SpanKind kind));

#if OPENTELEMETRY_ABI_VERSION_NO == 1
MOCK_METHOD(void, ForceFlushWithMicroseconds, (uint64_t timeout), (noexcept));
MOCK_METHOD(void, CloseWithMicroseconds, (uint64_t timeout), (noexcept));
#endif /* OPENTELEMETRY_ABI_VERSION_NO == 1 */
};

class MockSpan : public opentelemetry::trace::Span
Expand Down Expand Up @@ -100,10 +102,10 @@ class MockPropagator : public context::propagation::TextMapPropagator
const context::Context &context) noexcept override {
InjectImpl(carrier);
}

MOCK_METHOD(void, ExtractImpl, (const context::propagation::TextMapCarrier &carrier));
MOCK_METHOD(void, InjectImpl, (context::propagation::TextMapCarrier &carrier));
MOCK_METHOD(bool, Fields, (nostd::function_ref<bool(nostd::string_view)> callback),
MOCK_METHOD(bool, Fields, (nostd::function_ref<bool(nostd::string_view)> callback),
(const, noexcept, override));
};

Expand Down
Loading