From 0f9d24800555bc20473f1e0d66369d5ccda511d8 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Fri, 1 Dec 2023 16:26:48 -0800 Subject: [PATCH] Use std shared_ptr, unique_ptr and enable_if Signed-off-by: Bogdan Drutu --- .../sdk/common/global_log_handler.h | 10 +-- .../instrumentation_scope.h | 24 +++---- .../opentelemetry/sdk/logs/event_logger.h | 11 ++- .../sdk/logs/event_logger_provider.h | 7 +- sdk/include/opentelemetry/sdk/logs/logger.h | 5 +- .../opentelemetry/sdk/logs/logger_provider.h | 3 +- .../exemplar/fixed_size_exemplar_reservoir.h | 1 - .../sdk/metrics/exemplar/reservoir.h | 6 +- sdk/include/opentelemetry/sdk/metrics/meter.h | 30 ++++---- .../sdk/metrics/meter_provider.h | 5 +- .../sdk/metrics/meter_provider_factory.h | 2 +- .../sdk/metrics/state/async_metric_storage.h | 5 +- .../sdk/metrics/state/sync_metric_storage.h | 5 +- .../sdk/metrics/view/view_factory.h | 1 - sdk/include/opentelemetry/sdk/trace/sampler.h | 3 +- sdk/include/opentelemetry/sdk/trace/tracer.h | 3 +- .../opentelemetry/sdk/trace/tracer_provider.h | 5 +- sdk/src/common/global_log_handler.cc | 7 +- sdk/src/logs/batch_log_record_processor.cc | 1 + sdk/src/logs/event_logger.cc | 9 ++- sdk/src/logs/event_logger_provider.cc | 6 +- sdk/src/logs/logger.cc | 21 +++--- sdk/src/logs/logger_provider.cc | 9 ++- sdk/src/metrics/exemplar/reservoir.cc | 15 ++-- sdk/src/metrics/meter.cc | 72 +++++++++---------- sdk/src/metrics/meter_provider.cc | 21 +++--- sdk/src/metrics/state/observable_registry.cc | 7 +- sdk/src/trace/tracer.cc | 9 ++- sdk/src/trace/tracer_provider.cc | 11 +-- sdk/test/common/global_log_handle_test.cc | 3 +- sdk/test/logs/log_record_test.cc | 11 +-- sdk/test/logs/logger_provider_sdk_test.cc | 4 +- sdk/test/logs/logger_sdk_test.cc | 3 +- sdk/test/metrics/aggregation_test.cc | 2 +- sdk/test/metrics/meter_test.cc | 7 +- .../sync_metric_storage_counter_test.cc | 7 +- .../sync_metric_storage_histogram_test.cc | 1 - ...ync_metric_storage_up_down_counter_test.cc | 1 - sdk/test/trace/batch_span_processor_test.cc | 4 +- sdk/test/trace/tracer_test.cc | 9 +-- 40 files changed, 190 insertions(+), 176 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/global_log_handler.h b/sdk/include/opentelemetry/sdk/common/global_log_handler.h index a36bd4a8a3..9a95179630 100644 --- a/sdk/include/opentelemetry/sdk/common/global_log_handler.h +++ b/sdk/include/opentelemetry/sdk/common/global_log_handler.h @@ -3,10 +3,10 @@ #pragma once +#include #include #include -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/version.h" @@ -94,7 +94,7 @@ class GlobalLogHandler * * By default, a default LogHandler is returned. */ - static inline const nostd::shared_ptr &GetLogHandler() noexcept + static inline const std::shared_ptr &GetLogHandler() noexcept { return GetHandlerAndLevel().first; } @@ -104,7 +104,7 @@ class GlobalLogHandler * This should be called once at the start of application before creating any Provider * instance. */ - static inline void SetLogHandler(nostd::shared_ptr eh) noexcept + static inline void SetLogHandler(std::shared_ptr eh) noexcept { GetHandlerAndLevel().first = eh; } @@ -124,7 +124,7 @@ class GlobalLogHandler static inline void SetLogLevel(LogLevel level) noexcept { GetHandlerAndLevel().second = level; } private: - static std::pair, LogLevel> &GetHandlerAndLevel() noexcept; + static std::pair, LogLevel> &GetHandlerAndLevel() noexcept; }; } // namespace internal_log @@ -146,7 +146,7 @@ OPENTELEMETRY_END_NAMESPACE { \ break; \ } \ - const opentelemetry::nostd::shared_ptr &log_handler = \ + const opentelemetry::std::shared_ptr &log_handler = \ GlobalLogHandler::GetLogHandler(); \ if (!log_handler) \ { \ diff --git a/sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h b/sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h index 9bae218ba4..b538974e20 100644 --- a/sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h +++ b/sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h @@ -3,12 +3,12 @@ #pragma once +#include #include +#include #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/version.h" @@ -35,13 +35,13 @@ class InstrumentationScope * @param attributes attributes of the instrumentation scope. * @returns the newly created InstrumentationScope. */ - static nostd::unique_ptr Create( + static std::unique_ptr Create( nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "", InstrumentationScopeAttributes &&attributes = {}) { - return nostd::unique_ptr( + return std::unique_ptr( new InstrumentationScope{name, version, schema_url, std::move(attributes)}); } @@ -53,13 +53,13 @@ class InstrumentationScope * @param attributes attributes of the instrumentation scope. * @returns the newly created InstrumentationScope. */ - static nostd::unique_ptr Create( + static std::unique_ptr Create( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, const InstrumentationScopeAttributes &attributes) { - return nostd::unique_ptr(new InstrumentationScope{ + return std::unique_ptr(new InstrumentationScope{ name, version, schema_url, InstrumentationScopeAttributes(attributes)}); } @@ -73,14 +73,14 @@ class InstrumentationScope */ template < class ArgumentType, - nostd::enable_if_t::value> + std::enable_if_t::value> * = nullptr> - static nostd::unique_ptr Create(nostd::string_view name, - nostd::string_view version, - nostd::string_view schema_url, - const ArgumentType &arg) + static std::unique_ptr Create(nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const ArgumentType &arg) { - nostd::unique_ptr result = nostd::unique_ptr( + std::unique_ptr result = std::unique_ptr( new InstrumentationScope{name, version, schema_url}); // Do not construct a KeyValueIterable, so it has better performance. diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger.h b/sdk/include/opentelemetry/sdk/logs/event_logger.h index 8230beeb32..cc9c13c030 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger.h @@ -3,12 +3,11 @@ #pragma once +#include #include #include "opentelemetry/logs/event_logger.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -27,7 +26,7 @@ class EventLogger final : public opentelemetry::logs::EventLogger * @param delegate_logger The delegate logger instance * @param event_domain Event domain */ - explicit EventLogger(nostd::shared_ptr delegate_logger, + explicit EventLogger(std::shared_ptr delegate_logger, nostd::string_view event_domain) noexcept; /** @@ -35,15 +34,15 @@ class EventLogger final : public opentelemetry::logs::EventLogger */ const opentelemetry::nostd::string_view GetName() noexcept override; - nostd::shared_ptr GetDelegateLogger() noexcept override; + std::shared_ptr GetDelegateLogger() noexcept override; using opentelemetry::logs::EventLogger::EmitEvent; void EmitEvent(nostd::string_view event_name, - nostd::unique_ptr &&log_record) noexcept override; + std::unique_ptr &&log_record) noexcept override; private: - nostd::shared_ptr delegate_logger_; + std::shared_ptr delegate_logger_; std::string event_domain_; }; diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h b/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h index 2f3d2a0afd..a4920366d8 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h @@ -3,8 +3,9 @@ #pragma once +#include + #include "opentelemetry/logs/event_logger_provider.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" @@ -27,8 +28,8 @@ class EventLoggerProvider final : public opentelemetry::logs::EventLoggerProvide ~EventLoggerProvider() override; - nostd::shared_ptr CreateEventLogger( - nostd::shared_ptr delegate_logger, + std::shared_ptr CreateEventLogger( + std::shared_ptr delegate_logger, nostd::string_view event_domain) noexcept override; }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/logs/logger.h b/sdk/include/opentelemetry/sdk/logs/logger.h index fbbf4f28a5..9046411a9b 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger.h +++ b/sdk/include/opentelemetry/sdk/logs/logger.h @@ -9,7 +9,6 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/logs/logger.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/logger_context.h" #include "opentelemetry/version.h" @@ -40,12 +39,12 @@ class Logger final : public opentelemetry::logs::Logger */ const opentelemetry::nostd::string_view GetName() noexcept override; - nostd::unique_ptr CreateLogRecord() noexcept override; + std::unique_ptr CreateLogRecord() noexcept override; using opentelemetry::logs::Logger::EmitLogRecord; void EmitLogRecord( - nostd::unique_ptr &&log_record) noexcept override; + std::unique_ptr &&log_record) noexcept override; /** Returns the associated instrumentation scope */ const opentelemetry::sdk::instrumentationscope::InstrumentationScope &GetInstrumentationScope() diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index 0ab5683d3e..5ad0057c6c 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -8,7 +8,6 @@ #include #include "opentelemetry/logs/logger_provider.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -71,7 +70,7 @@ class LoggerProvider final : public opentelemetry::logs::LoggerProvider * @param library_version The version of the library. * @param schema_url The schema URL. */ - nostd::shared_ptr GetLogger( + std::shared_ptr GetLogger( nostd::string_view logger_name, nostd::string_view library_name, nostd::string_view library_version = "", diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h index 76f5742ca2..76b7f4caca 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h @@ -8,7 +8,6 @@ #include "opentelemetry/context/context.h" #include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #include "opentelemetry/sdk/metrics/exemplar/reservoir_cell.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h index 258e099f0f..64277d81b5 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h @@ -64,17 +64,17 @@ class ExemplarReservoir virtual std::vector> CollectAndReset( const MetricAttributes &pointAttributes) noexcept = 0; - static nostd::shared_ptr GetFilteredExemplarReservoir( + static std::shared_ptr GetFilteredExemplarReservoir( std::shared_ptr filter, std::shared_ptr reservoir); - static nostd::shared_ptr GetHistogramExemplarReservoir( + static std::shared_ptr GetHistogramExemplarReservoir( size_t size, std::shared_ptr reservoir_cell_selector, std::shared_ptr (ReservoirCell::*map_and_reset_cell)( const common::OrderedAttributeMap &attributes)); - static nostd::shared_ptr GetNoExemplarReservoir(); + static std::shared_ptr GetNoExemplarReservoir(); }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/metrics/meter.h b/sdk/include/opentelemetry/sdk/metrics/meter.h index 7e89d444ab..5a92f434b9 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter.h @@ -12,9 +12,7 @@ #include "opentelemetry/common/macros.h" #include "opentelemetry/metrics/meter.h" #include "opentelemetry/metrics/noop.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/metrics/instrument_metadata_validator.h" #include "opentelemetry/sdk/metrics/instruments.h" @@ -44,62 +42,62 @@ class Meter final : public opentelemetry::metrics::Meter std::unique_ptr scope = opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create("")) noexcept; - nostd::unique_ptr> CreateUInt64Counter( + std::unique_ptr> CreateUInt64Counter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::unique_ptr> CreateDoubleCounter( + std::unique_ptr> CreateDoubleCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::shared_ptr CreateInt64ObservableCounter( + std::shared_ptr CreateInt64ObservableCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::shared_ptr CreateDoubleObservableCounter( + std::shared_ptr CreateDoubleObservableCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::unique_ptr> CreateUInt64Histogram( + std::unique_ptr> CreateUInt64Histogram( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::unique_ptr> CreateDoubleHistogram( + std::unique_ptr> CreateDoubleHistogram( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::shared_ptr CreateInt64ObservableGauge( + std::shared_ptr CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::shared_ptr CreateDoubleObservableGauge( + std::shared_ptr CreateDoubleObservableGauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::unique_ptr> CreateInt64UpDownCounter( + std::unique_ptr> CreateInt64UpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::unique_ptr> CreateDoubleUpDownCounter( + std::unique_ptr> CreateDoubleUpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::shared_ptr + std::shared_ptr CreateInt64ObservableUpDownCounter(nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; - nostd::shared_ptr + std::shared_ptr CreateDoubleObservableUpDownCounter(nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override; @@ -131,10 +129,10 @@ class Meter final : public opentelemetry::metrics::Meter InstrumentDescriptor &instrument_descriptor); opentelemetry::common::SpinLockMutex storage_lock_; - static nostd::shared_ptr + static std::shared_ptr GetNoopObservableInsrument() { - static nostd::shared_ptr noop_instrument( + static std::shared_ptr noop_instrument( new opentelemetry::metrics::NoopObservableInstrument("", "", "")); return noop_instrument; } diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index 8a8c04c636..d70dc65899 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -8,7 +8,6 @@ #include #include "opentelemetry/metrics/meter_provider.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/sdk/resource/resource.h" @@ -54,13 +53,13 @@ class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics:: using opentelemetry::metrics::MeterProvider::GetMeter; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 - nostd::shared_ptr GetMeter( + std::shared_ptr GetMeter( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, const opentelemetry::common::KeyValueIterable *attributes) noexcept override; #else - nostd::shared_ptr GetMeter( + std::shared_ptr GetMeter( nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") noexcept override; diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index 69e77ebf5e..834d0a1b02 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -6,9 +6,9 @@ #include #include #include + #include "opentelemetry/metrics/meter.h" #include "opentelemetry/metrics/meter_provider.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/resource/resource.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h b/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h index 6a01d5c7f0..19d4e89265 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h @@ -7,7 +7,6 @@ #include #include -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/common/attributemap_hash.h" #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" #include "opentelemetry/sdk/metrics/exemplar/reservoir.h" @@ -30,7 +29,7 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora public: AsyncMetricStorage(InstrumentDescriptor instrument_descriptor, const AggregationType aggregation_type, - nostd::shared_ptr &&exemplar_reservoir + std::shared_ptr &&exemplar_reservoir OPENTELEMETRY_MAYBE_UNUSED, const AggregationConfig *aggregation_config) : instrument_descriptor_(instrument_descriptor), @@ -131,7 +130,7 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora std::unique_ptr delta_hash_map_; opentelemetry::common::SpinLockMutex hashmap_lock_; #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - nostd::shared_ptr exemplar_reservoir_; + std::shared_ptr exemplar_reservoir_; #endif TemporalMetricStorage temporal_metric_storage_; }; diff --git a/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h b/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h index cf249c39f2..9081796fc7 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h @@ -12,7 +12,6 @@ #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attributemap_hash.h" @@ -38,7 +37,7 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage SyncMetricStorage(InstrumentDescriptor instrument_descriptor, const AggregationType aggregation_type, const AttributesProcessor *attributes_processor, - nostd::shared_ptr &&exemplar_reservoir + std::shared_ptr &&exemplar_reservoir OPENTELEMETRY_MAYBE_UNUSED, const AggregationConfig *aggregation_config, size_t attributes_limit = kAggregationCardinalityLimit) @@ -165,7 +164,7 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage std::function()> create_default_aggregation_; const AttributesProcessor *attributes_processor_; #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - nostd::shared_ptr exemplar_reservoir_; + std::shared_ptr exemplar_reservoir_; #endif TemporalMetricStorage temporal_metric_storage_; opentelemetry::common::SpinLockMutex attribute_hashmap_lock_; diff --git a/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h index 22d34bf506..7079a4873c 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h @@ -3,7 +3,6 @@ #pragma once -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index b90a2e66b2..435a0e0829 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -8,7 +8,6 @@ #include #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/trace/span_metadata.h" #include "opentelemetry/trace/trace_id.h" @@ -55,7 +54,7 @@ struct SamplingResult // A set of span Attributes that will also be added to the Span. Can be nullptr. std::unique_ptr> attributes; // The tracestate used by the span. - nostd::shared_ptr trace_state; + std::shared_ptr trace_state; inline bool IsRecording() { diff --git a/sdk/include/opentelemetry/sdk/trace/tracer.h b/sdk/include/opentelemetry/sdk/trace/tracer.h index 67e606ba97..52cd008545 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer.h @@ -6,7 +6,6 @@ #include #include "opentelemetry/common/macros.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" @@ -38,7 +37,7 @@ class Tracer final : public opentelemetry::trace::Tracer, std::unique_ptr instrumentation_scope = InstrumentationScope::Create("")) noexcept; - nostd::shared_ptr StartSpan( + std::shared_ptr StartSpan( nostd::string_view name, const opentelemetry::common::KeyValueIterable &attributes, const opentelemetry::trace::SpanContextKeyValueIterable &links, diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index ce2a6d4401..962e028262 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -9,7 +9,6 @@ #include #include -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/random_id_generator.h" @@ -69,13 +68,13 @@ class TracerProvider final : public opentelemetry::trace::TracerProvider using opentelemetry::trace::TracerProvider::GetTracer; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 - opentelemetry::nostd::shared_ptr GetTracer( + std::shared_ptr GetTracer( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, const opentelemetry::common::KeyValueIterable *attributes) noexcept override; #else - opentelemetry::nostd::shared_ptr GetTracer( + std::shared_ptr GetTracer( nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") noexcept override; diff --git a/sdk/src/common/global_log_handler.cc b/sdk/src/common/global_log_handler.cc index bd1b56a9cd..4c460518ca 100644 --- a/sdk/src/common/global_log_handler.cc +++ b/sdk/src/common/global_log_handler.cc @@ -4,6 +4,7 @@ #include "opentelemetry/sdk/common/global_log_handler.h" #include +#include OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -43,10 +44,10 @@ void NoopLogHandler::Handle(LogLevel, const sdk::common::AttributeMap &) noexcept {} -std::pair, LogLevel> &GlobalLogHandler::GetHandlerAndLevel() noexcept +std::pair, LogLevel> &GlobalLogHandler::GetHandlerAndLevel() noexcept { - static std::pair, LogLevel> handler_and_level{ - nostd::shared_ptr(new DefaultLogHandler), LogLevel::Warning}; + static std::pair, LogLevel> handler_and_level{ + std::shared_ptr(new DefaultLogHandler), LogLevel::Warning}; return handler_and_level; } diff --git a/sdk/src/logs/batch_log_record_processor.cc b/sdk/src/logs/batch_log_record_processor.cc index 92536d1c00..054da7d45c 100644 --- a/sdk/src/logs/batch_log_record_processor.cc +++ b/sdk/src/logs/batch_log_record_processor.cc @@ -6,6 +6,7 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/sdk/logs/recordable.h" +#include #include using opentelemetry::sdk::common::AtomicUniquePtr; diff --git a/sdk/src/logs/event_logger.cc b/sdk/src/logs/event_logger.cc index c9dd5c35b5..97c670a7e9 100644 --- a/sdk/src/logs/event_logger.cc +++ b/sdk/src/logs/event_logger.cc @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/logs/event_logger.h" + +#include + #include "opentelemetry/sdk_config.h" #include "opentelemetry/trace/provider.h" @@ -12,7 +15,7 @@ namespace logs { namespace nostd = opentelemetry::nostd; -EventLogger::EventLogger(nostd::shared_ptr delegate_logger, +EventLogger::EventLogger(std::shared_ptr delegate_logger, nostd::string_view event_domain) noexcept : delegate_logger_(delegate_logger), event_domain_(event_domain) {} @@ -27,13 +30,13 @@ const nostd::string_view EventLogger::GetName() noexcept return {}; } -nostd::shared_ptr EventLogger::GetDelegateLogger() noexcept +std::shared_ptr EventLogger::GetDelegateLogger() noexcept { return delegate_logger_; } void EventLogger::EmitEvent(nostd::string_view event_name, - nostd::unique_ptr &&log_record) noexcept + std::unique_ptr &&log_record) noexcept { if (!delegate_logger_ || !log_record) { diff --git a/sdk/src/logs/event_logger_provider.cc b/sdk/src/logs/event_logger_provider.cc index 28a88d82e2..4a93c01190 100644 --- a/sdk/src/logs/event_logger_provider.cc +++ b/sdk/src/logs/event_logger_provider.cc @@ -25,11 +25,11 @@ EventLoggerProvider::EventLoggerProvider() noexcept EventLoggerProvider::~EventLoggerProvider() {} -nostd::shared_ptr EventLoggerProvider::CreateEventLogger( - nostd::shared_ptr delegate_logger, +std::shared_ptr EventLoggerProvider::CreateEventLogger( + std::shared_ptr delegate_logger, nostd::string_view event_domain) noexcept { - return nostd::shared_ptr{ + return std::shared_ptr{ new EventLogger(delegate_logger, event_domain)}; } diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index 7f85ddd6a3..25de1fe3df 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/logs/logger.h" + +#include + #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" @@ -31,7 +34,7 @@ const nostd::string_view Logger::GetName() noexcept return logger_name_; } -nostd::unique_ptr Logger::CreateLogRecord() noexcept +std::unique_ptr Logger::CreateLogRecord() noexcept { // If this logger does not have a processor, no need to create a log recordable if (!context_) @@ -48,10 +51,10 @@ nostd::unique_ptr Logger::CreateLogRecord() noex opentelemetry::context::ContextValue context_value = opentelemetry::context::RuntimeContext::GetCurrent().GetValue( opentelemetry::trace::kSpanKey); - if (nostd::holds_alternative>(context_value)) + if (nostd::holds_alternative>(context_value)) { - nostd::shared_ptr &data = - nostd::get>(context_value); + std::shared_ptr &data = + nostd::get>(context_value); if (data) { recordable->SetTraceId(data->GetContext().trace_id()); @@ -59,10 +62,10 @@ nostd::unique_ptr Logger::CreateLogRecord() noex recordable->SetSpanId(data->GetContext().span_id()); } } - else if (nostd::holds_alternative>(context_value)) + else if (nostd::holds_alternative>(context_value)) { - nostd::shared_ptr &data = - nostd::get>(context_value); + std::shared_ptr &data = + nostd::get>(context_value); if (data) { recordable->SetTraceId(data->trace_id()); @@ -72,10 +75,10 @@ nostd::unique_ptr Logger::CreateLogRecord() noex } } - return nostd::unique_ptr(recordable.release()); + return std::unique_ptr(recordable.release()); } -void Logger::EmitLogRecord(nostd::unique_ptr &&log_record) noexcept +void Logger::EmitLogRecord(std::unique_ptr &&log_record) noexcept { if (!log_record) { diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index 46eaa01054..54a46d936f 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/logs/logger_provider.h" + +#include + #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/logger.h" @@ -50,7 +53,7 @@ LoggerProvider::~LoggerProvider() } } -nostd::shared_ptr LoggerProvider::GetLogger( +std::shared_ptr LoggerProvider::GetLogger( nostd::string_view logger_name, nostd::string_view library_name, nostd::string_view library_version, @@ -73,7 +76,7 @@ nostd::shared_ptr LoggerProvider::GetLogger( if (logger->GetName() == logger_name && logger_lib.equal(library_name, library_version, schema_url)) { - return nostd::shared_ptr{logger}; + return std::shared_ptr{logger}; } } @@ -96,7 +99,7 @@ nostd::shared_ptr LoggerProvider::GetLogger( loggers_.push_back(std::shared_ptr( new Logger(logger_name, context_, std::move(lib)))); - return nostd::shared_ptr{loggers_.back()}; + return std::shared_ptr{loggers_.back()}; } void LoggerProvider::AddProcessor(std::unique_ptr processor) noexcept diff --git a/sdk/src/metrics/exemplar/reservoir.cc b/sdk/src/metrics/exemplar/reservoir.cc index b6f62a9885..e22b66497d 100644 --- a/sdk/src/metrics/exemplar/reservoir.cc +++ b/sdk/src/metrics/exemplar/reservoir.cc @@ -2,7 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/metrics/exemplar/reservoir.h" + +#include #include + #include "opentelemetry/sdk/metrics/exemplar/filtered_exemplar_reservoir.h" #include "opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h" #include "opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h" @@ -15,26 +18,26 @@ namespace sdk namespace metrics { -nostd::shared_ptr ExemplarReservoir::GetFilteredExemplarReservoir( +std::shared_ptr ExemplarReservoir::GetFilteredExemplarReservoir( std::shared_ptr filter, std::shared_ptr reservoir) { - return nostd::shared_ptr{new FilteredExemplarReservoir{filter, reservoir}}; + return std::shared_ptr{new FilteredExemplarReservoir{filter, reservoir}}; } -nostd::shared_ptr ExemplarReservoir::GetHistogramExemplarReservoir( +std::shared_ptr ExemplarReservoir::GetHistogramExemplarReservoir( size_t size, std::shared_ptr reservoir_cell_selector, std::shared_ptr (ReservoirCell::*map_and_reset_cell)( const common::OrderedAttributeMap &attributes)) { - return nostd::shared_ptr{ + return std::shared_ptr{ new HistogramExemplarReservoir{size, reservoir_cell_selector, map_and_reset_cell}}; } -nostd::shared_ptr ExemplarReservoir::GetNoExemplarReservoir() +std::shared_ptr ExemplarReservoir::GetNoExemplarReservoir() { - return nostd::shared_ptr{new NoExemplarReservoir{}}; + return std::shared_ptr{new NoExemplarReservoir{}}; } } // namespace metrics diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index 0ae3776111..99a9c21bb4 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -2,20 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/metrics/meter.h" + #include +#include + +#include "opentelemetry/sdk_config.h" #include "opentelemetry/metrics/noop.h" -#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/async_instruments.h" +#include "opentelemetry/sdk/metrics/sync_instruments.h" #include "opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h" #include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" #include "opentelemetry/sdk/metrics/state/observable_registry.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" -#include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk/metrics/sync_instruments.h" -#include "opentelemetry/sdk_config.h" - -#include OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -34,7 +34,7 @@ Meter::Meter( observable_registry_(new ObservableRegistry()) {} -nostd::unique_ptr> Meter::CreateUInt64Counter( +std::unique_ptr> Meter::CreateUInt64Counter( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -44,18 +44,18 @@ nostd::unique_ptr> Meter::CreateUInt64Counter( OTEL_INTERNAL_LOG_ERROR("Meter::CreateUInt64Counter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return std::unique_ptr>( new metrics::NoopCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { std::string{name.data(), name.size()}, std::string{description.data(), description.size()}, std::string{unit.data(), unit.size()}, InstrumentType::kCounter, InstrumentValueType::kLong}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>( + return std::unique_ptr>( new LongCounter(instrument_descriptor, std::move(storage))); } -nostd::unique_ptr> Meter::CreateDoubleCounter( +std::unique_ptr> Meter::CreateDoubleCounter( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -65,7 +65,7 @@ nostd::unique_ptr> Meter::CreateDoubleCounter( OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleCounter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return std::unique_ptr>( new metrics::NoopCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -73,11 +73,11 @@ nostd::unique_ptr> Meter::CreateDoubleCounter( std::string{unit.data(), unit.size()}, InstrumentType::kCounter, InstrumentValueType::kDouble}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return std::unique_ptr>{ new DoubleCounter(instrument_descriptor, std::move(storage))}; } -nostd::shared_ptr Meter::CreateInt64ObservableCounter( +std::shared_ptr Meter::CreateInt64ObservableCounter( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -94,11 +94,11 @@ nostd::shared_ptr Meter::CreateInt std::string{unit.data(), unit.size()}, InstrumentType::kObservableCounter, InstrumentValueType::kLong}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return std::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::shared_ptr +std::shared_ptr Meter::CreateDoubleObservableCounter(nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -115,11 +115,11 @@ Meter::CreateDoubleObservableCounter(nostd::string_view name, std::string{unit.data(), unit.size()}, InstrumentType::kObservableCounter, InstrumentValueType::kDouble}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return std::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::unique_ptr> Meter::CreateUInt64Histogram( +std::unique_ptr> Meter::CreateUInt64Histogram( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -129,7 +129,7 @@ nostd::unique_ptr> Meter::CreateUInt64Histogram( OTEL_INTERNAL_LOG_ERROR("Meter::CreateUInt64Histogram - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return std::unique_ptr>( new metrics::NoopHistogram(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -137,11 +137,11 @@ nostd::unique_ptr> Meter::CreateUInt64Histogram( std::string{unit.data(), unit.size()}, InstrumentType::kHistogram, InstrumentValueType::kLong}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return std::unique_ptr>{ new LongHistogram(instrument_descriptor, std::move(storage))}; } -nostd::unique_ptr> Meter::CreateDoubleHistogram( +std::unique_ptr> Meter::CreateDoubleHistogram( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -151,7 +151,7 @@ nostd::unique_ptr> Meter::CreateDoubleHistogram( OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleHistogram - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return std::unique_ptr>( new metrics::NoopHistogram(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -159,11 +159,11 @@ nostd::unique_ptr> Meter::CreateDoubleHistogram( std::string{unit.data(), unit.size()}, InstrumentType::kHistogram, InstrumentValueType::kDouble}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return std::unique_ptr>{ new DoubleHistogram(instrument_descriptor, std::move(storage))}; } -nostd::shared_ptr Meter::CreateInt64ObservableGauge( +std::shared_ptr Meter::CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -180,11 +180,11 @@ nostd::shared_ptr Meter::CreateInt std::string{unit.data(), unit.size()}, InstrumentType::kObservableGauge, InstrumentValueType::kLong}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return std::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::shared_ptr Meter::CreateDoubleObservableGauge( +std::shared_ptr Meter::CreateDoubleObservableGauge( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -201,11 +201,11 @@ nostd::shared_ptr Meter::CreateDou std::string{unit.data(), unit.size()}, InstrumentType::kObservableGauge, InstrumentValueType::kDouble}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return std::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::unique_ptr> Meter::CreateInt64UpDownCounter( +std::unique_ptr> Meter::CreateInt64UpDownCounter( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -215,7 +215,7 @@ nostd::unique_ptr> Meter::CreateInt64UpDownCount OTEL_INTERNAL_LOG_ERROR("Meter::CreateInt64UpDownCounter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return std::unique_ptr>( new metrics::NoopUpDownCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -223,11 +223,11 @@ nostd::unique_ptr> Meter::CreateInt64UpDownCount std::string{unit.data(), unit.size()}, InstrumentType::kUpDownCounter, InstrumentValueType::kLong}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return std::unique_ptr>{ new LongUpDownCounter(instrument_descriptor, std::move(storage))}; } -nostd::unique_ptr> Meter::CreateDoubleUpDownCounter( +std::unique_ptr> Meter::CreateDoubleUpDownCounter( nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -237,7 +237,7 @@ nostd::unique_ptr> Meter::CreateDoubleUpDownCount OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleUpDownCounter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return std::unique_ptr>( new metrics::NoopUpDownCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -245,11 +245,11 @@ nostd::unique_ptr> Meter::CreateDoubleUpDownCount std::string{unit.data(), unit.size()}, InstrumentType::kUpDownCounter, InstrumentValueType::kDouble}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return std::unique_ptr>{ new DoubleUpDownCounter(instrument_descriptor, std::move(storage))}; } -nostd::shared_ptr +std::shared_ptr Meter::CreateInt64ObservableUpDownCounter(nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -266,11 +266,11 @@ Meter::CreateInt64ObservableUpDownCounter(nostd::string_view name, std::string{unit.data(), unit.size()}, InstrumentType::kObservableUpDownCounter, InstrumentValueType::kLong}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return std::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::shared_ptr +std::shared_ptr Meter::CreateDoubleObservableUpDownCounter(nostd::string_view name, nostd::string_view description, nostd::string_view unit) noexcept @@ -287,7 +287,7 @@ Meter::CreateDoubleObservableUpDownCounter(nostd::string_view name, std::string{unit.data(), unit.size()}, InstrumentType::kObservableUpDownCounter, InstrumentValueType::kDouble}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return std::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 63bea5ae28..7a00f166db 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -2,17 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/metrics/meter_provider.h" + +#include +#include + +#include "opentelemetry/sdk_config.h" +#include "opentelemetry/version.h" #include "opentelemetry/metrics/meter.h" +#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk_config.h" -#include "opentelemetry/version.h" - -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { @@ -33,13 +34,13 @@ MeterProvider::MeterProvider(std::unique_ptr views, } #if OPENTELEMETRY_ABI_VERSION_NO >= 2 -nostd::shared_ptr MeterProvider::GetMeter( +std::shared_ptr MeterProvider::GetMeter( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, const opentelemetry::common::KeyValueIterable *attributes) noexcept #else -nostd::shared_ptr MeterProvider::GetMeter( +std::shared_ptr MeterProvider::GetMeter( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url) noexcept @@ -62,7 +63,7 @@ nostd::shared_ptr MeterProvider::GetMeter( auto meter_lib = meter->GetInstrumentationScope(); if (meter_lib->equal(name, version, schema_url)) { - return nostd::shared_ptr{meter}; + return std::shared_ptr{meter}; } } @@ -72,7 +73,7 @@ nostd::shared_ptr MeterProvider::GetMeter( auto meter = std::shared_ptr(new Meter(context_, std::move(scope))); context_->AddMeter(meter); - return nostd::shared_ptr{meter}; + return std::shared_ptr{meter}; } #if OPENTELEMETRY_ABI_VERSION_NO >= 2 diff --git a/sdk/src/metrics/state/observable_registry.cc b/sdk/src/metrics/state/observable_registry.cc index 41b8e86067..4c56821dc1 100644 --- a/sdk/src/metrics/state/observable_registry.cc +++ b/sdk/src/metrics/state/observable_registry.cc @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/metrics/state/observable_registry.h" + +#include + #include "opentelemetry/sdk/metrics/async_instruments.h" #include "opentelemetry/sdk/metrics/observer_result.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" @@ -68,7 +71,7 @@ void ObservableRegistry::Observe(opentelemetry::common::SystemTimestamp collecti } if (value_type == InstrumentValueType::kDouble) { - nostd::shared_ptr> ob_res( + std::shared_ptr> ob_res( new opentelemetry::sdk::metrics::ObserverResultT()); callback_wrap->callback(ob_res, callback_wrap->state); storage->RecordDouble( @@ -78,7 +81,7 @@ void ObservableRegistry::Observe(opentelemetry::common::SystemTimestamp collecti } else { - nostd::shared_ptr> ob_res( + std::shared_ptr> ob_res( new opentelemetry::sdk::metrics::ObserverResultT()); callback_wrap->callback(ob_res, callback_wrap->state); storage->RecordLong( diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index 6ca7b37df5..37555b6683 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/trace/tracer.h" + +#include + #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/trace/context.h" #include "opentelemetry/trace/noop.h" @@ -19,7 +22,7 @@ Tracer::Tracer(std::shared_ptr context, : instrumentation_scope_{std::move(instrumentation_scope)}, context_{context} {} -nostd::shared_ptr Tracer::StartSpan( +std::shared_ptr Tracer::StartSpan( nostd::string_view name, const opentelemetry::common::KeyValueIterable &attributes, const opentelemetry::trace::SpanContextKeyValueIterable &links, @@ -78,7 +81,7 @@ nostd::shared_ptr Tracer::StartSpan( { // create no-op span with valid span-context. - auto noop_span = nostd::shared_ptr{ + auto noop_span = std::shared_ptr{ new (std::nothrow) opentelemetry::trace::NoopSpan(this->shared_from_this(), std::move(span_context))}; return noop_span; @@ -86,7 +89,7 @@ nostd::shared_ptr Tracer::StartSpan( else { - auto span = nostd::shared_ptr{ + auto span = std::shared_ptr{ new (std::nothrow) Span{this->shared_from_this(), name, attributes, links, options, parent_context, std::move(span_context)}}; diff --git a/sdk/src/trace/tracer_provider.cc b/sdk/src/trace/tracer_provider.cc index 8569b63f23..45809bb962 100644 --- a/sdk/src/trace/tracer_provider.cc +++ b/sdk/src/trace/tracer_provider.cc @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/trace/tracer_provider.h" + +#include + #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/tracer.h" @@ -54,13 +57,13 @@ TracerProvider::~TracerProvider() } #if OPENTELEMETRY_ABI_VERSION_NO >= 2 -nostd::shared_ptr TracerProvider::GetTracer( +std::shared_ptr TracerProvider::GetTracer( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, const opentelemetry::common::KeyValueIterable *attributes) noexcept #else -nostd::shared_ptr TracerProvider::GetTracer( +std::shared_ptr TracerProvider::GetTracer( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url) noexcept @@ -87,7 +90,7 @@ nostd::shared_ptr TracerProvider::GetTracer( auto &tracer_scope = tracer->GetInstrumentationScope(); if (tracer_scope.equal(name, version, schema_url)) { - return nostd::shared_ptr{tracer}; + return std::shared_ptr{tracer}; } } @@ -97,7 +100,7 @@ nostd::shared_ptr TracerProvider::GetTracer( auto tracer = std::shared_ptr(new Tracer(context_, std::move(scope))); tracers_.push_back(tracer); - return nostd::shared_ptr{tracer}; + return std::shared_ptr{tracer}; } void TracerProvider::AddProcessor(std::unique_ptr processor) noexcept diff --git a/sdk/test/common/global_log_handle_test.cc b/sdk/test/common/global_log_handle_test.cc index a38bdc8728..bdecb5b531 100644 --- a/sdk/test/common/global_log_handle_test.cc +++ b/sdk/test/common/global_log_handle_test.cc @@ -6,6 +6,7 @@ #include #include +#include class CustomLogHandler : public opentelemetry::sdk::common::internal_log::LogHandler { @@ -45,7 +46,7 @@ TEST(GlobalLogHandleTest, CustomLogHandler) opentelemetry::sdk::common::internal_log::GlobalLogHandler::GetLogHandler(); auto backup_log_level = opentelemetry::sdk::common::internal_log::GlobalLogHandler::GetLogLevel(); - auto custom_log_handler = opentelemetry::nostd::shared_ptr(new CustomLogHandler{}); + auto custom_log_handler = std::shared_ptr(new CustomLogHandler{}); opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogHandler(custom_log_handler); auto before_count = static_cast(custom_log_handler.get())->count; opentelemetry::sdk::common::AttributeMap attributes = { diff --git a/sdk/test/logs/log_record_test.cc b/sdk/test/logs/log_record_test.cc index 689ca7f8ed..34ad58debd 100644 --- a/sdk/test/logs/log_record_test.cc +++ b/sdk/test/logs/log_record_test.cc @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -82,14 +83,14 @@ class TestBodyLogger : public opentelemetry::logs::Logger public: const nostd::string_view GetName() noexcept override { return "test body logger"; } - nostd::unique_ptr CreateLogRecord() noexcept override + std::unique_ptr CreateLogRecord() noexcept override { - return nostd::unique_ptr(new ReadWriteLogRecord()); + return std::unique_ptr(new ReadWriteLogRecord()); } using opentelemetry::logs::Logger::EmitLogRecord; - void EmitLogRecord(nostd::unique_ptr &&record) noexcept override + void EmitLogRecord(std::unique_ptr &&record) noexcept override { if (record) { @@ -112,14 +113,14 @@ class TestBodyProvider : public opentelemetry::logs::LoggerProvider public: using opentelemetry::logs::LoggerProvider::GetLogger; - nostd::shared_ptr GetLogger( + std::shared_ptr GetLogger( nostd::string_view /* logger_name */, nostd::string_view /* library_name */, nostd::string_view /* library_version */, nostd::string_view /* schema_url */, const opentelemetry::common::KeyValueIterable & /* attributes */) override { - return nostd::shared_ptr(new TestBodyLogger()); + return std::shared_ptr(new TestBodyLogger()); } }; diff --git a/sdk/test/logs/logger_provider_sdk_test.cc b/sdk/test/logs/logger_provider_sdk_test.cc index ecb9ea6f9c..bb254c1ad0 100644 --- a/sdk/test/logs/logger_provider_sdk_test.cc +++ b/sdk/test/logs/logger_provider_sdk_test.cc @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include #include "opentelemetry/logs/provider.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/logs/event_logger_provider_factory.h" #include "opentelemetry/sdk/logs/exporter.h" @@ -23,7 +23,7 @@ namespace nostd = opentelemetry::nostd; TEST(LoggerProviderSDK, PushToAPI) { auto lp = - nostd::shared_ptr(new opentelemetry::sdk::logs::LoggerProvider()); + std::shared_ptr(new opentelemetry::sdk::logs::LoggerProvider()); logs_api::Provider::SetLoggerProvider(lp); // Check that the loggerprovider was correctly pushed into the API diff --git a/sdk/test/logs/logger_sdk_test.cc b/sdk/test/logs/logger_sdk_test.cc index 62d523b92a..5eb4bfd598 100644 --- a/sdk/test/logs/logger_sdk_test.cc +++ b/sdk/test/logs/logger_sdk_test.cc @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include #include "opentelemetry/logs/logger_provider.h" @@ -211,7 +212,7 @@ TEST(LoggerSDK, LogToAProcessor) auto logger2 = lp->GetLogger("logger", "opentelelemtry_library", "", schema_url); ASSERT_EQ(logger, logger2); - nostd::shared_ptr include_span; + std::shared_ptr include_span; { std::vector> span_processors; auto trace_provider = diff --git a/sdk/test/metrics/aggregation_test.cc b/sdk/test/metrics/aggregation_test.cc index 94e5f4c1fa..a8ba6e7d2a 100644 --- a/sdk/test/metrics/aggregation_test.cc +++ b/sdk/test/metrics/aggregation_test.cc @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/variant.h" using namespace opentelemetry::sdk::metrics; diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index 084f50fc09..566f6ffd20 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -9,6 +9,7 @@ #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" +#include #include using namespace opentelemetry; @@ -17,7 +18,7 @@ using namespace opentelemetry::sdk::metrics; namespace { -nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, +std::shared_ptr InitMeter(MetricReader **metricReaderPtr, std::string meter_name = "meter_name") { static std::shared_ptr provider(new MeterProvider()); @@ -33,7 +34,7 @@ nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, void asyc_generate_measurements(opentelemetry::metrics::ObserverResult observer, void * /* state */) { auto observer_long = - nostd::get>>(observer); + nostd::get>>(observer); observer_long->Observe(10); } @@ -71,7 +72,7 @@ TEST(MeterTest, StressMultiThread) std::atomic threadCount(0); std::atomic numIterations(MAX_ITERATIONS_MT); std::atomic do_collect{false}, do_sync_create{true}, do_async_create{false}; - std::vector> + std::vector> observable_instruments; std::vector meter_operation_threads; std::atomic instrument_id(0); diff --git a/sdk/test/metrics/sync_metric_storage_counter_test.cc b/sdk/test/metrics/sync_metric_storage_counter_test.cc index e27a9f5a24..abcc606f0d 100644 --- a/sdk/test/metrics/sync_metric_storage_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_counter_test.cc @@ -3,17 +3,16 @@ #include "common.h" +#include +#include #include + #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" -#include -#include - using namespace opentelemetry::sdk::metrics; using namespace opentelemetry::common; using M = std::map; diff --git a/sdk/test/metrics/sync_metric_storage_histogram_test.cc b/sdk/test/metrics/sync_metric_storage_histogram_test.cc index 3da2b0538e..716248fb4a 100644 --- a/sdk/test/metrics/sync_metric_storage_histogram_test.cc +++ b/sdk/test/metrics/sync_metric_storage_histogram_test.cc @@ -4,7 +4,6 @@ #include "common.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" diff --git a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc index 15077b428a..dbbbed9b03 100644 --- a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc @@ -4,7 +4,6 @@ #include "common.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" diff --git a/sdk/test/trace/batch_span_processor_test.cc b/sdk/test/trace/batch_span_processor_test.cc index 411b4dacfe..523a6d80de 100644 --- a/sdk/test/trace/batch_span_processor_test.cc +++ b/sdk/test/trace/batch_span_processor_test.cc @@ -226,7 +226,7 @@ TEST_F(BatchSpanProcessorTestPeer, TestManySpansLoss) /* Test that when exporting more than max_queue_size spans, some are most likely lost*/ // Set up a log handler to verify a warning is generated. - auto log_handler = nostd::shared_ptr(new MockLogHandler()); + auto log_handler = std::shared_ptr(new MockLogHandler()); sdk::common::internal_log::GlobalLogHandler::SetLogHandler(log_handler); std::shared_ptr> shut_down_counter(new std::atomic(0)); @@ -273,7 +273,7 @@ TEST_F(BatchSpanProcessorTestPeer, TestManySpansLoss) // Reinstate the default log handler. sdk::common::internal_log::GlobalLogHandler::SetLogHandler( - nostd::shared_ptr( + std::shared_ptr( new sdk::common::internal_log::DefaultLogHandler())); } diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 36cc135a1d..2901cd8532 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -11,6 +11,7 @@ #include "opentelemetry/sdk/trace/span_data.h" #include "opentelemetry/trace/context.h" +#include #include using namespace opentelemetry::sdk::trace; @@ -47,19 +48,19 @@ class MockSampler final : public Sampler // Return two pairs of attributes. These attributes should be added to the // span attributes return {Decision::RECORD_AND_SAMPLE, - nostd::unique_ptr>( + std::unique_ptr>( new const std::map( {{"sampling_attr1", 123}, {"sampling_attr2", "string"}})), - nostd::shared_ptr(nullptr)}; + std::shared_ptr(nullptr)}; } else { // we should never reach here assert(false); return {Decision::DROP, - nostd::unique_ptr>( + std::unique_ptr>( nullptr), - nostd::shared_ptr(nullptr)}; + std::shared_ptr(nullptr)}; } }