From c2a2ef459719e2b85f0a7a8d810e9dccb82d9339 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 9 May 2024 15:58:35 +0200 Subject: [PATCH] Fixes #2506 --- examples/otlp/file_log_main.cc | 46 ++++++++--------- examples/otlp/file_main.cc | 13 +++-- examples/otlp/grpc_log_main.cc | 40 ++++++++------- examples/otlp/grpc_main.cc | 23 ++++----- examples/otlp/http_log_main.cc | 49 ++++++++++--------- examples/otlp/http_main.cc | 14 +++--- .../sdk/logs/event_logger_provider_factory.h | 9 ++-- .../sdk/logs/logger_provider_factory.h | 16 +++--- .../sdk/metrics/meter_provider_factory.h | 45 ++--------------- sdk/src/logs/event_logger_provider_factory.cc | 4 +- sdk/src/logs/logger_provider_factory.cc | 16 +++--- sdk/src/metrics/meter_provider_factory.cc | 20 +++----- 12 files changed, 128 insertions(+), 167 deletions(-) diff --git a/examples/otlp/file_log_main.cc b/examples/otlp/file_log_main.cc index f903449c56..f716887d80 100644 --- a/examples/otlp/file_log_main.cc +++ b/examples/otlp/file_log_main.cc @@ -8,20 +8,17 @@ #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" #include "opentelemetry/logs/provider.h" #include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/logger_provider.h" #include "opentelemetry/sdk/logs/logger_provider_factory.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -// sdk::TracerProvider and sdk::LoggerProvider is just used to call ForceFlush and prevent to cancel -// running exportings when destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" - #include #include #include @@ -43,27 +40,31 @@ namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; opentelemetry::exporter::otlp::OtlpFileLogRecordExporterOptions log_opts; + +std::shared_ptr tracer_provider; +std::shared_ptr logger_provider; + void InitTracer() { // Create OTLP exporter instance - auto exporter = otlp::OtlpFileExporterFactory::Create(opts); - auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpFileExporterFactory::Create(opts); + auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); + tracer_provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr api_provider = tracer_provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast(provider.get())->ForceFlush(); + tracer_provider->ForceFlush(); } + tracer_provider.reset(); std::shared_ptr none; trace::Provider::SetTracerProvider(none); } @@ -71,24 +72,23 @@ void CleanupTracer() void InitLogger() { // Create OTLP exporter instance - auto exporter = otlp::OtlpFileLogRecordExporterFactory::Create(log_opts); - auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - nostd::shared_ptr provider( - logs_sdk::LoggerProviderFactory::Create(std::move(processor))); + auto exporter = otlp::OtlpFileLogRecordExporterFactory::Create(log_opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); + logger_provider = logs_sdk::LoggerProviderFactory::Create(std::move(processor)); - opentelemetry::logs::Provider::SetLoggerProvider(provider); + std::shared_ptr api_provider = logger_provider; + opentelemetry::logs::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast(provider.get())->ForceFlush(); + logger_provider->ForceFlush(); } + logger_provider.reset(); nostd::shared_ptr none; opentelemetry::logs::Provider::SetLoggerProvider(none); } diff --git a/examples/otlp/file_main.cc b/examples/otlp/file_main.cc index 675ad47a75..cc911e07c4 100644 --- a/examples/otlp/file_main.cc +++ b/examples/otlp/file_main.cc @@ -29,26 +29,29 @@ namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; -std::shared_ptr sdk_provider; +std::shared_ptr provider; void InitTracer() { // Create OTLP exporter instance auto exporter = otlp::OtlpFileExporterFactory::Create(opts); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - sdk_provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(sdk_provider); + std::shared_ptr api_provider = provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - if (sdk_provider) + if (provider) { - sdk_provider->ForceFlush(std::chrono::milliseconds(10000)); + provider->ForceFlush(std::chrono::milliseconds(10000)); } + provider.reset(); std::shared_ptr none; trace::Provider::SetTracerProvider(none); } diff --git a/examples/otlp/grpc_log_main.cc b/examples/otlp/grpc_log_main.cc index 9d7399dbaf..2316289999 100644 --- a/examples/otlp/grpc_log_main.cc +++ b/examples/otlp/grpc_log_main.cc @@ -40,27 +40,31 @@ namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; opentelemetry::exporter::otlp::OtlpGrpcLogRecordExporterOptions log_opts; + +std::shared_ptr tracer_provider; +std::shared_ptr logger_provider; + void InitTracer() { // Create OTLP exporter instance - auto exporter = otlp::OtlpGrpcExporterFactory::Create(opts); - auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpGrpcExporterFactory::Create(opts); + auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); + tracer_provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr api_provider = tracer_provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast(provider.get())->ForceFlush(); + tracer_provider->ForceFlush(); } + tracer_provider.reset(); std::shared_ptr none; trace::Provider::SetTracerProvider(none); } @@ -68,24 +72,24 @@ void CleanupTracer() void InitLogger() { // Create OTLP exporter instance - auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(log_opts); - auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - nostd::shared_ptr provider( - logs_sdk::LoggerProviderFactory::Create(std::move(processor))); + auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(log_opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); + logger_provider = logs_sdk::LoggerProviderFactory::Create(std::move(processor)); - opentelemetry::logs::Provider::SetLoggerProvider(provider); + // Set the global logger provider + std::shared_ptr api_provider = logger_provider; + opentelemetry::logs::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast(provider.get())->ForceFlush(); + logger_provider->ForceFlush(); } + logger_provider.reset(); nostd::shared_ptr none; opentelemetry::logs::Provider::SetLoggerProvider(none); } diff --git a/examples/otlp/grpc_main.cc b/examples/otlp/grpc_main.cc index 37a3a7987f..9b29e16edd 100644 --- a/examples/otlp/grpc_main.cc +++ b/examples/otlp/grpc_main.cc @@ -2,17 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" -#include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/sdk/trace/tracer_provider.h" -#include "opentelemetry/trace/tracer_provider.h" +#include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/nostd/shared_ptr.h" - -// sdk::TracerProvider is just used to call ForceFlush and prevent to cancel running exportings when -// destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/foo_library/foo_library.h" @@ -28,30 +24,29 @@ namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; -std::shared_ptr sdk_provider; +std::shared_ptr provider; void InitTracer() { // Create OTLP exporter instance auto exporter = otlp::OtlpGrpcExporterFactory::Create(opts); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - sdk_provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); - std::shared_ptr api_provider ( sdk_provider ); // Set the global trace provider + std::shared_ptr api_provider = provider; trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - if (sdk_provider) + if (provider) { - sdk_provider->ForceFlush(); - sdk_provider = nullptr; + provider->ForceFlush(); } + provider.reset(); std::shared_ptr none; trace::Provider::SetTracerProvider(none); } diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 7b68ad44c7..82b9e47a51 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -6,19 +6,16 @@ #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" #include "opentelemetry/logs/provider.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/logs/logger_provider.h" #include "opentelemetry/sdk/logs/logger_provider_factory.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -// sdk::TracerProvider and sdk::LoggerProvider is just used to call ForceFlush and prevent to cancel -// running exportings when destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" - #include #include @@ -40,6 +37,9 @@ namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions trace_opts; + +std::shared_ptr tracer_provider; + void InitTracer() { if (trace_opts.url.size() > 9) @@ -58,53 +58,56 @@ void InitTracer() } } std::cout << "Using " << trace_opts.url << " to export trace spans." << std::endl; + // Create OTLP exporter instance - auto exporter = otlp::OtlpHttpExporterFactory::Create(trace_opts); - auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpHttpExporterFactory::Create(trace_opts); + auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); + tracer_provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr api_provider = tracer_provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast(provider.get())->ForceFlush(); + tracer_provider->ForceFlush(); } + tracer_provider.reset(); std::shared_ptr none; trace::Provider::SetTracerProvider(none); } opentelemetry::exporter::otlp::OtlpHttpLogRecordExporterOptions logger_opts; + +std::shared_ptr logger_provider; + void InitLogger() { std::cout << "Using " << logger_opts.url << " to export log records." << std::endl; logger_opts.console_debug = true; // Create OTLP exporter instance - auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts); - auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider = - logs_sdk::LoggerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); + logger_provider = logs_sdk::LoggerProviderFactory::Create(std::move(processor)); - opentelemetry::logs::Provider::SetLoggerProvider(provider); + std::shared_ptr api_provider = logger_provider; + opentelemetry::logs::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast(provider.get())->ForceFlush(); + logger_provider->ForceFlush(); } + logger_provider.reset(); std::shared_ptr none; opentelemetry::logs::Provider::SetLoggerProvider(none); } diff --git a/examples/otlp/http_main.cc b/examples/otlp/http_main.cc index 6a0667b918..4918bf25de 100644 --- a/examples/otlp/http_main.cc +++ b/examples/otlp/http_main.cc @@ -30,27 +30,29 @@ namespace internal_log = opentelemetry::sdk::common::internal_log; namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts; + +std::shared_ptr provider; + void InitTracer() { // Create OTLP exporter instance auto exporter = otlp::OtlpHttpExporterFactory::Create(opts); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr api_provider = provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr provider = - trace::Provider::GetTracerProvider(); if (provider) { - static_cast(provider.get())->ForceFlush(); + provider->ForceFlush(); } + provider.reset(); std::shared_ptr none; trace::Provider::SetTracerProvider(none); } diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h index 0b8c066fc6..abdec14b0a 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h @@ -4,14 +4,11 @@ #pragma once #include + +#include "opentelemetry/sdk/logs/event_logger_provider.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ -class EventLoggerProvider; -} // namespace logs - namespace sdk { namespace logs @@ -26,7 +23,7 @@ class EventLoggerProviderFactory /** * Create a EventLoggerProvider. */ - static std::unique_ptr Create(); + static std::unique_ptr Create(); }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h index 987a09fe16..10cc3b37bb 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h @@ -6,14 +6,10 @@ #include #include +#include "opentelemetry/sdk/logs/logger_provider.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ -class LoggerProvider; -} // namespace logs - namespace sdk { namespace resource @@ -35,33 +31,33 @@ class OPENTELEMETRY_EXPORT LoggerProviderFactory /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr &&processor); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr &&processor, const opentelemetry::sdk::resource::Resource &resource); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::vector> &&processors); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::vector> &&processors, const opentelemetry::sdk::resource::Resource &resource); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr context); }; diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index 69e77ebf5e..d26fb9b438 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -11,6 +11,7 @@ #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -20,55 +21,19 @@ namespace sdk namespace metrics { -/* - MAINTAINER: - - The best design is to return an API object: - std::unique_ptr - to shield the calling application from SDK implementation details. - - This however assumes that the SDK object can be created in one call, - instead of making multiple calls to the SDK to setup a meter provider. - - Because existing code, already advertised in examples: - - creates an instance of sdk::MeterProvider - - calls SDK methods on it to continue the setup, such as - MeterProvider::AddMetricReader() - MeterProvider::AddView() - existing applications will need to access the underlying - class sdk::MeterProvider. - - We need to decide whether to return: - - (1) std::unique_ptr - - (2) std::unique_ptr - from a Create() method. - - In the long term, (1) is better, but forces users to use a down cast, - to make additional calls to the SDK class, until such a time when - the builders can take all the necessary input at once, - for example using a std::vector to add all readers. - - Implementing (2) is forcing technical debt, and prevents the - calling application configuring the SDK to be decoupled from it, - making deployment of shared libraries much more difficult. - - The design choice here is to return (1) an API MeterProvider, - even if this forces, temporarily, existing applications to use a downcast. -*/ - class OPENTELEMETRY_EXPORT MeterProviderFactory { public: - static std::unique_ptr Create(); + static std::unique_ptr Create(); - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr views); - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr views, const opentelemetry::sdk::resource::Resource &resource); - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr context); }; diff --git a/sdk/src/logs/event_logger_provider_factory.cc b/sdk/src/logs/event_logger_provider_factory.cc index 0c9eff4570..5118833345 100644 --- a/sdk/src/logs/event_logger_provider_factory.cc +++ b/sdk/src/logs/event_logger_provider_factory.cc @@ -11,9 +11,9 @@ namespace sdk namespace logs { -std::unique_ptr EventLoggerProviderFactory::Create() +std::unique_ptr EventLoggerProviderFactory::Create() { - return std::unique_ptr(new EventLoggerProvider()); + return std::unique_ptr(new EventLoggerProvider()); } } // namespace logs diff --git a/sdk/src/logs/logger_provider_factory.cc b/sdk/src/logs/logger_provider_factory.cc index 76e662a909..76c0eef29f 100644 --- a/sdk/src/logs/logger_provider_factory.cc +++ b/sdk/src/logs/logger_provider_factory.cc @@ -12,42 +12,42 @@ namespace sdk namespace logs { -std::unique_ptr LoggerProviderFactory::Create( +std::unique_ptr LoggerProviderFactory::Create( std::unique_ptr &&processor) { auto resource = opentelemetry::sdk::resource::Resource::Create({}); return Create(std::move(processor), resource); } -std::unique_ptr LoggerProviderFactory::Create( +std::unique_ptr LoggerProviderFactory::Create( std::unique_ptr &&processor, const opentelemetry::sdk::resource::Resource &resource) { - std::unique_ptr provider( + std::unique_ptr provider( new LoggerProvider(std::move(processor), resource)); return provider; } -std::unique_ptr LoggerProviderFactory::Create( +std::unique_ptr LoggerProviderFactory::Create( std::vector> &&processors) { auto resource = opentelemetry::sdk::resource::Resource::Create({}); return Create(std::move(processors), resource); } -std::unique_ptr LoggerProviderFactory::Create( +std::unique_ptr LoggerProviderFactory::Create( std::vector> &&processors, const opentelemetry::sdk::resource::Resource &resource) { - std::unique_ptr provider( + std::unique_ptr provider( new LoggerProvider(std::move(processors), resource)); return provider; } -std::unique_ptr LoggerProviderFactory::Create( +std::unique_ptr LoggerProviderFactory::Create( std::unique_ptr context) { - std::unique_ptr provider( + std::unique_ptr provider( new LoggerProvider(std::move(context))); return provider; } diff --git a/sdk/src/metrics/meter_provider_factory.cc b/sdk/src/metrics/meter_provider_factory.cc index bd6bbe932c..49abe00c37 100644 --- a/sdk/src/metrics/meter_provider_factory.cc +++ b/sdk/src/metrics/meter_provider_factory.cc @@ -13,43 +13,39 @@ #include -namespace resource = opentelemetry::sdk::resource; -namespace metrics_api = opentelemetry::metrics; -namespace metrics_sdk = opentelemetry::sdk::metrics; - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace metrics { -std::unique_ptr MeterProviderFactory::Create() +std::unique_ptr MeterProviderFactory::Create() { auto views = ViewRegistryFactory::Create(); return Create(std::move(views)); } -std::unique_ptr MeterProviderFactory::Create( +std::unique_ptr MeterProviderFactory::Create( std::unique_ptr views) { auto resource = opentelemetry::sdk::resource::Resource::Create({}); return Create(std::move(views), resource); } -std::unique_ptr MeterProviderFactory::Create( +std::unique_ptr MeterProviderFactory::Create( std::unique_ptr views, const opentelemetry::sdk::resource::Resource &resource) { - std::unique_ptr provider( - new metrics_sdk::MeterProvider(std::move(views), resource)); + std::unique_ptr provider( + new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); return provider; } -std::unique_ptr MeterProviderFactory::Create( +std::unique_ptr MeterProviderFactory::Create( std::unique_ptr context) { - std::unique_ptr provider( - new metrics_sdk::MeterProvider(std::move(context))); + std::unique_ptr provider( + new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); return provider; }