diff --git a/google/cloud/opentelemetry/samples/samples.cc b/google/cloud/opentelemetry/samples/samples.cc index 5ec41c4bb32aa..db18dcf4d3778 100644 --- a/google/cloud/opentelemetry/samples/samples.cc +++ b/google/cloud/opentelemetry/samples/samples.cc @@ -142,11 +142,12 @@ void CustomTracerProvider(std::vector const& argv) { auto processor = opentelemetry::sdk::trace::BatchSpanProcessorFactory::Create( std::move(exporter), options); - auto provider = opentelemetry::sdk::trace::TracerProviderFactory::Create( - std::move(processor)); - // Set the global trace provider - opentelemetry::trace::Provider::SetTracerProvider(std::move(provider)); + // Create a tracer provider and set it as the global trace provider + opentelemetry::trace::Provider::SetTracerProvider( + std::shared_ptr( + opentelemetry::sdk::trace::TracerProviderFactory::Create( + std::move(processor)))); MyApplicationCode(); diff --git a/google/cloud/testing_util/opentelemetry_matchers.cc b/google/cloud/testing_util/opentelemetry_matchers.cc index e36b3034bcc44..86bcdaa2afa82 100644 --- a/google/cloud/testing_util/opentelemetry_matchers.cc +++ b/google/cloud/testing_util/opentelemetry_matchers.cc @@ -25,6 +25,7 @@ #include namespace { + void AttributeFormatter( std::string* out, std::pair( std::move(exporter)); - std::shared_ptr provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create( - std::move(processor)); - opentelemetry::trace::Provider::SetTracerProvider(std::move(provider)); + opentelemetry::trace::Provider::SetTracerProvider( + std::shared_ptr( + opentelemetry::sdk::trace::TracerProviderFactory::Create( + std::move(processor)))); } SpanCatcher::~SpanCatcher() {