diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c462112a7..3de3fe70dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,6 +116,14 @@ Increment the: * [CONFIGURATION] Apply default sampler when none is specified [#4170](https://github.com/open-telemetry/opentelemetry-cpp/pull/4170) +* [API] Add `trace::GetSpanContext()` to read the active span's `SpanContext` + from a `Context`; reuse it in the logs SDK to remove a duplicated helper. + [#4191](https://github.com/open-telemetry/opentelemetry-cpp/pull/4191) + +* [SDK] Apply the `ExemplarFilter` (AlwaysOn/AlwaysOff/TraceBased) via + `ExemplarReservoir::GetSimpleFilteredExemplarReservoir()`. + [#4191](https://github.com/open-telemetry/opentelemetry-cpp/pull/4191) + ## [1.27.0] 2026-05-13 * [RELEASE] Bump main branch to 1.27.0-dev diff --git a/api/include/opentelemetry/trace/context.h b/api/include/opentelemetry/trace/context.h index 146f0d65f9..d68f19a7db 100644 --- a/api/include/opentelemetry/trace/context.h +++ b/api/include/opentelemetry/trace/context.h @@ -23,6 +23,33 @@ inline nostd::shared_ptr GetSpan(const context::Context &context) noexcept return nostd::shared_ptr(new DefaultSpan(SpanContext::GetInvalid())); } +// Get the SpanContext of the active span from explicit context. Falls back to a SpanContext +// stored directly in the context, and returns an invalid SpanContext if neither is present. +inline SpanContext GetSpanContext(const context::Context &context) noexcept +{ + if (!context.HasKey(kSpanKey)) + { + return SpanContext::GetInvalid(); + } + + const context::ContextValue context_value = context.GetValue(kSpanKey); + + // Get the span metadata from the active span in the context. + if (const nostd::shared_ptr *maybe_span = + nostd::get_if>(&context_value)) + { + return (*maybe_span)->GetContext(); + } + // Get the span metadata directly from a SpanContext in the context. + // TODO: This path is unused and may be removed in the future. + if (const nostd::shared_ptr *maybe_span_context = + nostd::get_if>(&context_value)) + { + return **maybe_span_context; + } + return SpanContext::GetInvalid(); +} + // Check if the context is from a root span inline bool IsRootSpan(const context::Context &context) noexcept { diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/filtered_exemplar_reservoir.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/filtered_exemplar_reservoir.h new file mode 100644 index 0000000000..179cf7d533 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/filtered_exemplar_reservoir.h @@ -0,0 +1,111 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW + +# include +# include +# include +# include + +# include "opentelemetry/common/timestamp.h" +# include "opentelemetry/context/context.h" +# include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/sdk/metrics/data/exemplar_data.h" +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" +# include "opentelemetry/trace/context.h" +# include "opentelemetry/trace/span_context.h" +# include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace metrics +{ + +/** + * A reservoir that pre-filters measurements according to an ExemplarFilterType before + * delegating eligible ones to a wrapped reservoir. + */ +class FilteredExemplarReservoir final : public ExemplarReservoir +{ +public: + FilteredExemplarReservoir(ExemplarFilterType filter_type, + nostd::shared_ptr reservoir) + : should_sample_(SelectFilter(filter_type)), reservoir_(std::move(reservoir)) + {} + + void OfferMeasurement(int64_t value, + const MetricAttributes &attributes, + const opentelemetry::context::Context &context, + const opentelemetry::common::SystemTimestamp ×tamp) noexcept override + { + if (should_sample_(context)) + { + reservoir_->OfferMeasurement(value, attributes, context, timestamp); + } + } + + void OfferMeasurement(double value, + const MetricAttributes &attributes, + const opentelemetry::context::Context &context, + const opentelemetry::common::SystemTimestamp ×tamp) noexcept override + { + if (should_sample_(context)) + { + reservoir_->OfferMeasurement(value, attributes, context, timestamp); + } + } + + std::vector> CollectAndReset( + const MetricAttributes &pointAttributes) noexcept override + { + return reservoir_->CollectAndReset(pointAttributes); + } + +private: + using ShouldSampleFn = bool (*)(const opentelemetry::context::Context &context); + + static bool AlwaysOn(const opentelemetry::context::Context & /* context */) noexcept + { + return true; + } + + static bool AlwaysOff(const opentelemetry::context::Context & /* context */) noexcept + { + return false; + } + + static bool TraceBased(const opentelemetry::context::Context &context) noexcept + { + const opentelemetry::trace::SpanContext span_context = + opentelemetry::trace::GetSpanContext(context); + return span_context.IsValid() && span_context.IsSampled(); + } + + static ShouldSampleFn SelectFilter(ExemplarFilterType filter_type) noexcept + { + switch (filter_type) + { + case ExemplarFilterType::kAlwaysOn: + return &AlwaysOn; + case ExemplarFilterType::kAlwaysOff: + return &AlwaysOff; + case ExemplarFilterType::kTraceBased: + return &TraceBased; + } + return &TraceBased; // unreachable; all enumerators handled above + } + + ShouldSampleFn should_sample_; + nostd::shared_ptr reservoir_; +}; + +} // namespace metrics +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE + +#endif // ENABLE_METRICS_EXEMPLAR_PREVIEW diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h index efbd20abc4..19ad5551e6 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h @@ -75,7 +75,7 @@ class ExemplarReservoir static nostd::shared_ptr GetSimpleFilteredExemplarReservoir( ExemplarFilterType filter_type, - std::shared_ptr reservoir); + nostd::shared_ptr reservoir); static nostd::shared_ptr GetSimpleFixedSizeExemplarReservoir( size_t size, diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h index 6ca88411af..e8e2970e89 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h @@ -10,6 +10,8 @@ # include "opentelemetry/common/macros.h" # include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h" +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h" # include "opentelemetry/version.h" @@ -49,7 +51,8 @@ static inline size_t GetSimpleFixedReservoirDefaultSize(const AggregationType ag static inline nostd::shared_ptr GetExemplarReservoir( const AggregationType agg_type, const AggregationConfig *agg_config, - const InstrumentDescriptor &instrument_descriptor) + const InstrumentDescriptor &instrument_descriptor, + ExemplarFilterType filter_type) { if (agg_type == AggregationType::kHistogram) { @@ -62,18 +65,21 @@ static inline nostd::shared_ptr GetExemplarReservoir( // if (histogram_agg_config != nullptr && histogram_agg_config->boundaries_.size() > 1) { - return nostd::shared_ptr(new AlignedHistogramBucketExemplarReservoir( - histogram_agg_config->boundaries_.size(), - AlignedHistogramBucketExemplarReservoir::GetHistogramCellSelector( - histogram_agg_config->boundaries_), - GetMapAndResetCellMethod(instrument_descriptor))); + return ExemplarReservoir::GetSimpleFilteredExemplarReservoir( + filter_type, + nostd::shared_ptr(new AlignedHistogramBucketExemplarReservoir( + histogram_agg_config->boundaries_.size(), + AlignedHistogramBucketExemplarReservoir::GetHistogramCellSelector( + histogram_agg_config->boundaries_), + GetMapAndResetCellMethod(instrument_descriptor)))); } } - return nostd::shared_ptr(new SimpleFixedSizeExemplarReservoir( - GetSimpleFixedReservoirDefaultSize(agg_type, agg_config), - SimpleFixedSizeExemplarReservoir::GetSimpleFixedSizeCellSelector(), - GetMapAndResetCellMethod(instrument_descriptor))); + return ExemplarReservoir::GetSimpleFilteredExemplarReservoir( + filter_type, nostd::shared_ptr(new SimpleFixedSizeExemplarReservoir( + GetSimpleFixedReservoirDefaultSize(agg_type, agg_config), + SimpleFixedSizeExemplarReservoir::GetSimpleFixedSizeCellSelector(), + GetMapAndResetCellMethod(instrument_descriptor)))); } } // namespace metrics } // namespace sdk 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 a3f56ef64d..017d802578 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h @@ -13,7 +13,6 @@ #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif @@ -37,7 +36,6 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora AsyncMetricStorage(const InstrumentDescriptor &instrument_descriptor, const AggregationType aggregation_type, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType exempler_filter_type, nostd::shared_ptr &&exemplar_reservoir, #endif const AggregationConfig *aggregation_config) @@ -49,7 +47,6 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora delta_hash_map_( std::make_unique(aggregation_config_->cardinality_limit_)), #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - exemplar_filter_type_(exempler_filter_type), exemplar_reservoir_(std::move(exemplar_reservoir)), #endif temporal_metric_storage_(instrument_descriptor, aggregation_type, aggregation_config) @@ -66,11 +63,8 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora for (auto &measurement : measurements) { #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - if (exemplar_filter_type_ == ExemplarFilterType::kAlwaysOn) - { - exemplar_reservoir_->OfferMeasurement(measurement.second, {}, {}, - std::chrono::system_clock::now()); - } + exemplar_reservoir_->OfferMeasurement(measurement.second, {}, {}, + std::chrono::system_clock::now()); #endif auto aggr = DefaultAggregation::CreateAggregation(aggregation_type_, instrument_descriptor_); @@ -146,7 +140,6 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora std::unique_ptr delta_hash_map_; opentelemetry::common::SpinLockMutex hashmap_lock_; #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType exemplar_filter_type_; nostd::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 0c77f74c63..b3112a47f6 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h @@ -36,7 +36,6 @@ #endif #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif @@ -48,25 +47,11 @@ namespace metrics class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage { -#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - - static inline bool EnableExamplarFilter(ExemplarFilterType filter_type, - const opentelemetry::context::Context &context) - { - return filter_type == ExemplarFilterType::kAlwaysOn || - (filter_type == ExemplarFilterType::kTraceBased && - opentelemetry::trace::GetSpan(context)->GetContext().IsValid() && - opentelemetry::trace::GetSpan(context)->GetContext().IsSampled()); - } - -#endif // ENABLE_METRICS_EXEMPLAR_PREVIEW - public: SyncMetricStorage(const InstrumentDescriptor &instrument_descriptor, const AggregationType aggregation_type, std::shared_ptr attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType exempler_filter_type, nostd::shared_ptr &&exemplar_reservoir, #endif const AggregationConfig *aggregation_config) @@ -76,7 +61,6 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage std::make_unique(aggregation_config_->cardinality_limit_)), attributes_processor_(std::move(attributes_processor)), #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - exemplar_filter_type_(exempler_filter_type), exemplar_reservoir_(std::move(exemplar_reservoir)), #endif temporal_metric_storage_(instrument_descriptor, aggregation_type, aggregation_config) @@ -97,10 +81,7 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage return; } #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - if (EnableExamplarFilter(exemplar_filter_type_, context)) - { - exemplar_reservoir_->OfferMeasurement(value, {}, context, std::chrono::system_clock::now()); - } + exemplar_reservoir_->OfferMeasurement(value, {}, context, std::chrono::system_clock::now()); #endif static MetricAttributes attr = MetricAttributes{}; std::lock_guard guard(attribute_hashmap_lock_); @@ -123,11 +104,8 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage return; } #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - if (EnableExamplarFilter(exemplar_filter_type_, context)) - { - exemplar_reservoir_->OfferMeasurement(value, attributes, context, - std::chrono::system_clock::now()); - } + exemplar_reservoir_->OfferMeasurement(value, attributes, context, + std::chrono::system_clock::now()); #endif MetricAttributes attr{attributes, attributes_processor_.get()}; @@ -155,10 +133,7 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage return; } #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - if (EnableExamplarFilter(exemplar_filter_type_, context)) - { - exemplar_reservoir_->OfferMeasurement(value, {}, context, std::chrono::system_clock::now()); - } + exemplar_reservoir_->OfferMeasurement(value, {}, context, std::chrono::system_clock::now()); #endif static MetricAttributes attr = MetricAttributes{}; std::lock_guard guard(attribute_hashmap_lock_); @@ -181,11 +156,8 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage return; } #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - if (EnableExamplarFilter(exemplar_filter_type_, context)) - { - exemplar_reservoir_->OfferMeasurement(value, attributes, context, - std::chrono::system_clock::now()); - } + exemplar_reservoir_->OfferMeasurement(value, attributes, context, + std::chrono::system_clock::now()); #endif MetricAttributes attr{attributes, attributes_processor_.get()}; std::lock_guard guard(attribute_hashmap_lock_); @@ -298,7 +270,6 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage std::function()> create_default_aggregation_; std::shared_ptr attributes_processor_; #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType exemplar_filter_type_; nostd::shared_ptr exemplar_reservoir_; #endif TemporalMetricStorage temporal_metric_storage_; diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index 5c643da7b6..bdef3d445d 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -8,13 +8,11 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/context/context.h" -#include "opentelemetry/context/context_value.h" #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/logs/event_id.h" #include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/noop.h" #include "opentelemetry/logs/severity.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/nostd/variant.h" @@ -25,10 +23,9 @@ #include "opentelemetry/sdk/logs/logger_context.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" -#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/context.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" -#include "opentelemetry/trace/span_metadata.h" #include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/version.h" @@ -49,33 +46,6 @@ nostd::string_view GetEventName(const opentelemetry::logs::EventId &event_id) no : nostd::string_view{}; } -trace_api::SpanContext ExtractSpanContextFromContext(const context::Context &context) noexcept -{ - if (!context.HasKey(trace_api::kSpanKey)) - { - return trace_api::SpanContext::GetInvalid(); - } - - const context::ContextValue context_value = context.GetValue(trace_api::kSpanKey); - - // Get the span metadata from the active span in the context - if (const nostd::shared_ptr *maybe_span = - nostd::get_if>(&context_value)) - { - const nostd::shared_ptr &span = *maybe_span; - return span->GetContext(); - } - // Get the span metadata directly from a SpanContext in the context. - // TODO: This path is unused and may be removed in the future. - if (const nostd::shared_ptr *maybe_span_context = - nostd::get_if>(&context_value)) - { - const nostd::shared_ptr &span_context = *maybe_span_context; - return *span_context; - } - return trace_api::SpanContext::GetInvalid(); -} - trace_api::SpanContext ExtractSpanContext( const nostd::variant &context_or_span) noexcept { @@ -85,7 +55,7 @@ trace_api::SpanContext ExtractSpanContext( } if (const context::Context *ctx = nostd::get_if(&context_or_span)) { - return ExtractSpanContextFromContext(*ctx); + return trace_api::GetSpanContext(*ctx); } return trace_api::SpanContext::GetInvalid(); } diff --git a/sdk/src/metrics/exemplar/reservoir.cc b/sdk/src/metrics/exemplar/reservoir.cc index f5fe4064b6..71e46ba298 100644 --- a/sdk/src/metrics/exemplar/reservoir.cc +++ b/sdk/src/metrics/exemplar/reservoir.cc @@ -4,9 +4,12 @@ #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include +# include # include "opentelemetry/nostd/shared_ptr.h" # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h" +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +# include "opentelemetry/sdk/metrics/exemplar/filtered_exemplar_reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir_cell.h" @@ -20,6 +23,14 @@ namespace sdk namespace metrics { +nostd::shared_ptr ExemplarReservoir::GetSimpleFilteredExemplarReservoir( + ExemplarFilterType filter_type, + nostd::shared_ptr reservoir) +{ + return nostd::shared_ptr{ + new FilteredExemplarReservoir{filter_type, std::move(reservoir)}}; +} + nostd::shared_ptr ExemplarReservoir::GetSimpleFixedSizeExemplarReservoir( size_t size, const std::shared_ptr &reservoir_cell_selector, diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index 4a4c2f6b68..8acab9f3dd 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -545,9 +545,8 @@ std::unique_ptr Meter::RegisterSyncMetricStorage( sync_storage = std::shared_ptr(new SyncMetricStorage( view_instr_desc, view.GetAggregationType(), view.GetAttributesProcessor(), #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - exemplar_filter_type, GetExemplarReservoir(view.GetAggregationType(), view.GetAggregationConfig(), - view_instr_desc), + view_instr_desc, exemplar_filter_type), #endif view.GetAggregationConfig())); storage_registry_.insert({view_instr_desc, sync_storage}); @@ -618,9 +617,8 @@ std::unique_ptr Meter::RegisterAsyncMetricStorage( async_storage = std::shared_ptr(new AsyncMetricStorage( view_instr_desc, view.GetAggregationType(), #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - exemplar_filter_type, GetExemplarReservoir(view.GetAggregationType(), view.GetAggregationConfig(), - view_instr_desc), + view_instr_desc, exemplar_filter_type), #endif view.GetAggregationConfig())); storage_registry_.insert({view_instr_desc, async_storage}); diff --git a/sdk/test/metrics/async_metric_storage_test.cc b/sdk/test/metrics/async_metric_storage_test.cc index 4de1a95c4f..3987770420 100644 --- a/sdk/test/metrics/async_metric_storage_test.cc +++ b/sdk/test/metrics/async_metric_storage_test.cc @@ -28,7 +28,6 @@ #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif @@ -66,7 +65,7 @@ TEST_P(WritableMetricStorageTestFixture, TestAggregation) opentelemetry::sdk::metrics::AsyncMetricStorage storage( instr_desc, AggregationType::kSum, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); int64_t get_count1 = 20; @@ -161,7 +160,7 @@ TEST_P(WritableMetricStorageTestUpDownFixture, TestAggregation) opentelemetry::sdk::metrics::AsyncMetricStorage storage( instr_desc, AggregationType::kDefault, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); int64_t get_count1 = 20; @@ -257,7 +256,7 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) opentelemetry::sdk::metrics::AsyncMetricStorage storage( instr_desc, AggregationType::kLastValue, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); int64_t freq_cpu0 = 3; diff --git a/sdk/test/metrics/bound_sync_instruments_test.cc b/sdk/test/metrics/bound_sync_instruments_test.cc index 9c2f233691..a3194e54a1 100644 --- a/sdk/test/metrics/bound_sync_instruments_test.cc +++ b/sdk/test/metrics/bound_sync_instruments_test.cc @@ -40,7 +40,6 @@ # include "opentelemetry/sdk/metrics/view/attributes_processor.h" # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # endif @@ -75,7 +74,6 @@ class StorageHolder } storage_ = std::make_shared(desc, agg_type, proc_, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), # endif cfg_); @@ -186,12 +184,12 @@ TEST(BoundSyncInstruments, BoundCounterBindInitializerList) InstrumentValueType::kLong}; std::shared_ptr proc(new DefaultAttributesProcessor{}); AggregationConfig cfg; - std::unique_ptr storage(new SyncMetricStorage( - desc, AggregationType::kSum, proc, + std::unique_ptr storage( + new SyncMetricStorage(desc, AggregationType::kSum, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif - &cfg)); + &cfg)); SyncMetricStorage *storage_ptr = storage.get(); LongCounter counter(desc, std::move(storage)); opentelemetry::metrics::Counter &api_counter = counter; @@ -238,12 +236,12 @@ TEST(BoundSyncInstruments, UnboundCounterDropsValueAboveInt64Max) InstrumentValueType::kLong}; std::shared_ptr proc(new DefaultAttributesProcessor{}); AggregationConfig cfg; - std::unique_ptr storage(new SyncMetricStorage( - desc, AggregationType::kSum, proc, + std::unique_ptr storage( + new SyncMetricStorage(desc, AggregationType::kSum, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif - &cfg)); + &cfg)); SyncMetricStorage *storage_ptr = storage.get(); LongCounter counter(desc, std::move(storage)); M attrs = {{"key", "v"}}; @@ -261,12 +259,12 @@ TEST(BoundSyncInstruments, BoundCounterDropsValueAboveInt64Max) InstrumentValueType::kLong}; std::shared_ptr proc(new DefaultAttributesProcessor{}); AggregationConfig cfg; - std::unique_ptr storage(new SyncMetricStorage( - desc, AggregationType::kSum, proc, + std::unique_ptr storage( + new SyncMetricStorage(desc, AggregationType::kSum, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif - &cfg)); + &cfg)); SyncMetricStorage *storage_ptr = storage.get(); LongCounter counter(desc, std::move(storage)); M attrs = {{"key", "v"}}; @@ -315,12 +313,12 @@ TEST(BoundSyncInstruments, UnboundHistogramDropsValueAboveInt64Max) InstrumentValueType::kLong}; std::shared_ptr proc(new DefaultAttributesProcessor{}); HistogramAggregationConfig cfg; - std::unique_ptr storage(new SyncMetricStorage( - desc, AggregationType::kHistogram, proc, + std::unique_ptr storage( + new SyncMetricStorage(desc, AggregationType::kHistogram, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif - &cfg)); + &cfg)); SyncMetricStorage *storage_ptr = storage.get(); LongHistogram histogram(desc, std::move(storage)); M attrs = {{"key", "v"}}; @@ -354,12 +352,12 @@ TEST(BoundSyncInstruments, BoundHistogramDropsValueAboveInt64Max) InstrumentValueType::kLong}; std::shared_ptr proc(new DefaultAttributesProcessor{}); HistogramAggregationConfig cfg; - std::unique_ptr storage(new SyncMetricStorage( - desc, AggregationType::kHistogram, proc, + std::unique_ptr storage( + new SyncMetricStorage(desc, AggregationType::kHistogram, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif - &cfg)); + &cfg)); SyncMetricStorage *storage_ptr = storage.get(); LongHistogram histogram(desc, std::move(storage)); M attrs = {{"key", "v"}}; @@ -394,12 +392,12 @@ TEST(BoundSyncInstruments, BoundHistogramBindInitializerList) InstrumentValueType::kLong}; std::shared_ptr proc(new DefaultAttributesProcessor{}); HistogramAggregationConfig cfg; - std::unique_ptr storage(new SyncMetricStorage( - desc, AggregationType::kHistogram, proc, + std::unique_ptr storage( + new SyncMetricStorage(desc, AggregationType::kHistogram, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif - &cfg)); + &cfg)); SyncMetricStorage *storage_ptr = storage.get(); LongHistogram histogram(desc, std::move(storage)); opentelemetry::metrics::Histogram &api_histogram = histogram; @@ -436,7 +434,6 @@ TEST(BoundSyncInstruments, BoundCounterRespectsDropAggregation) AggregationConfig cfg; SyncMetricStorage storage(desc, AggregationType::kDrop, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), # endif &cfg); @@ -472,7 +469,6 @@ TEST(BoundSyncInstruments, BoundCounterRespectsLastValueAggregation) AggregationConfig cfg; SyncMetricStorage storage(desc, AggregationType::kLastValue, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), # endif &cfg); @@ -511,7 +507,6 @@ TEST(BoundSyncInstruments, BoundHistogramRespectsCustomBuckets) cfg.boundaries_ = {10.0, 20.0}; SyncMetricStorage storage(desc, AggregationType::kHistogram, proc, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), # endif &cfg); diff --git a/sdk/test/metrics/cardinality_limit_test.cc b/sdk/test/metrics/cardinality_limit_test.cc index 01aaf79b0a..4a5e47139b 100644 --- a/sdk/test/metrics/cardinality_limit_test.cc +++ b/sdk/test/metrics/cardinality_limit_test.cc @@ -32,7 +32,6 @@ #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif @@ -116,7 +115,6 @@ TEST_P(WritableMetricStorageCardinalityLimitTestFixture, LongCounterSumAggregati new DefaultAttributesProcessor{}}; SyncMetricStorage storage(instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), #endif &aggConfig); diff --git a/sdk/test/metrics/exemplar/BUILD b/sdk/test/metrics/exemplar/BUILD index 9b11a64b9c..10973fd000 100644 --- a/sdk/test/metrics/exemplar/BUILD +++ b/sdk/test/metrics/exemplar/BUILD @@ -53,3 +53,20 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name = "filtered_exemplar_reservoir_test", + srcs = [ + "filtered_exemplar_reservoir_test.cc", + ], + tags = [ + "metrics", + "test", + ], + deps = [ + "//api", + "//sdk:headers", + "//sdk/src/metrics", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/sdk/test/metrics/exemplar/CMakeLists.txt b/sdk/test/metrics/exemplar/CMakeLists.txt index 04a715b2f8..32f755e747 100644 --- a/sdk/test/metrics/exemplar/CMakeLists.txt +++ b/sdk/test/metrics/exemplar/CMakeLists.txt @@ -1,9 +1,10 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -foreach(testname - no_exemplar_reservoir_test - aligned_histogram_bucket_exemplar_reservoir_test reservoir_cell_test) +foreach( + testname + no_exemplar_reservoir_test aligned_histogram_bucket_exemplar_reservoir_test + reservoir_cell_test filtered_exemplar_reservoir_test) add_executable(${testname} "${testname}.cc") target_link_libraries( ${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} diff --git a/sdk/test/metrics/exemplar/always_sample_filter_test.cc b/sdk/test/metrics/exemplar/always_sample_filter_test.cc deleted file mode 100644 index f78cd412bd..0000000000 --- a/sdk/test/metrics/exemplar/always_sample_filter_test.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#include - -#include "opentelemetry/context/context.h" -#include "opentelemetry/sdk/metrics/exemplar/filter.h" - -using namespace opentelemetry::sdk::metrics; - -TEST(AlwaysSampleFilter, SampleMeasurement) -{ - auto filter = opentelemetry::sdk::metrics::ExemplarFilter::GetAlwaysSampleFilter(); - ASSERT_TRUE( - filter->ShouldSampleMeasurement(1.0, MetricAttributes{}, opentelemetry::context::Context{})); - ASSERT_TRUE(filter->ShouldSampleMeasurement(static_cast(1), MetricAttributes{}, - opentelemetry::context::Context{})); -} diff --git a/sdk/test/metrics/exemplar/filtered_exemplar_reservoir_test.cc b/sdk/test/metrics/exemplar/filtered_exemplar_reservoir_test.cc new file mode 100644 index 0000000000..22d4616370 --- /dev/null +++ b/sdk/test/metrics/exemplar/filtered_exemplar_reservoir_test.cc @@ -0,0 +1,125 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW + +# include +# include +# include +# include +# include + +# include "opentelemetry/common/timestamp.h" +# include "opentelemetry/context/context.h" +# include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/nostd/span.h" +# include "opentelemetry/sdk/metrics/data/exemplar_data.h" +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" +# include "opentelemetry/trace/context.h" +# include "opentelemetry/trace/default_span.h" +# include "opentelemetry/trace/span.h" +# include "opentelemetry/trace/span_context.h" +# include "opentelemetry/trace/span_id.h" +# include "opentelemetry/trace/trace_flags.h" +# include "opentelemetry/trace/trace_id.h" + +namespace +{ +namespace metrics_sdk = opentelemetry::sdk::metrics; +namespace trace_api = opentelemetry::trace; +namespace context_api = opentelemetry::context; +namespace nostd = opentelemetry::nostd; + +class CountingReservoir : public metrics_sdk::ExemplarReservoir +{ +public: + void OfferMeasurement(int64_t, + const metrics_sdk::MetricAttributes &, + const context_api::Context &, + const opentelemetry::common::SystemTimestamp &) noexcept override + { + ++offered; + } + + void OfferMeasurement(double, + const metrics_sdk::MetricAttributes &, + const context_api::Context &, + const opentelemetry::common::SystemTimestamp &) noexcept override + { + ++offered; + } + + std::vector> CollectAndReset( + const metrics_sdk::MetricAttributes &) noexcept override + { + return {}; + } + + int offered = 0; +}; + +context_api::Context ContextWithSpan(bool sampled) +{ + const uint8_t trace_id_bytes[trace_api::TraceId::kSize] = {1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16}; + const uint8_t span_id_bytes[trace_api::SpanId::kSize] = {1, 2, 3, 4, 5, 6, 7, 8}; + trace_api::SpanContext span_context( + trace_api::TraceId(trace_id_bytes), trace_api::SpanId(span_id_bytes), + sampled ? trace_api::TraceFlags(trace_api::TraceFlags::kIsSampled) : trace_api::TraceFlags(), + false); + nostd::shared_ptr span(new trace_api::DefaultSpan(span_context)); + context_api::Context context; + return trace_api::SetSpan(context, span); +} + +int ForwardedCount(metrics_sdk::ExemplarFilterType filter_type, const context_api::Context &context) +{ + auto *spy = new CountingReservoir(); + auto filtered = metrics_sdk::ExemplarReservoir::GetSimpleFilteredExemplarReservoir( + filter_type, nostd::shared_ptr(spy)); + filtered->OfferMeasurement(1.0, metrics_sdk::MetricAttributes{}, context, + std::chrono::system_clock::now()); + return spy->offered; +} +} // namespace + +TEST(FilteredExemplarReservoir, AlwaysOnOffersMeasurement) +{ + EXPECT_EQ(ForwardedCount(metrics_sdk::ExemplarFilterType::kAlwaysOn, context_api::Context{}), 1); +} + +TEST(FilteredExemplarReservoir, AlwaysOnOffersLongMeasurement) +{ + auto *spy = new CountingReservoir(); + auto filtered = metrics_sdk::ExemplarReservoir::GetSimpleFilteredExemplarReservoir( + metrics_sdk::ExemplarFilterType::kAlwaysOn, + nostd::shared_ptr(spy)); + filtered->OfferMeasurement(static_cast(1), metrics_sdk::MetricAttributes{}, + context_api::Context{}, std::chrono::system_clock::now()); + EXPECT_EQ(spy->offered, 1); +} + +TEST(FilteredExemplarReservoir, AlwaysOffDropsMeasurement) +{ + EXPECT_EQ(ForwardedCount(metrics_sdk::ExemplarFilterType::kAlwaysOff, context_api::Context{}), 0); +} + +TEST(FilteredExemplarReservoir, TraceBasedDropsWithoutSpan) +{ + EXPECT_EQ(ForwardedCount(metrics_sdk::ExemplarFilterType::kTraceBased, context_api::Context{}), + 0); +} + +TEST(FilteredExemplarReservoir, TraceBasedOffersWithSampledSpan) +{ + EXPECT_EQ(ForwardedCount(metrics_sdk::ExemplarFilterType::kTraceBased, ContextWithSpan(true)), 1); +} + +TEST(FilteredExemplarReservoir, TraceBasedDropsUnsampledSpan) +{ + EXPECT_EQ(ForwardedCount(metrics_sdk::ExemplarFilterType::kTraceBased, ContextWithSpan(false)), + 0); +} + +#endif // ENABLE_METRICS_EXEMPLAR_PREVIEW diff --git a/sdk/test/metrics/exemplar/with_trace_sample_filter_test.cc b/sdk/test/metrics/exemplar/with_trace_sample_filter_test.cc deleted file mode 100644 index fcf9d6344e..0000000000 --- a/sdk/test/metrics/exemplar/with_trace_sample_filter_test.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#include -#include "opentelemetry/context/context.h" -#include "opentelemetry/sdk/metrics/exemplar/filter.h" - -using namespace opentelemetry::sdk::metrics; - -TEST(WithTraceSampleFilter, SampleMeasurement) -{ - auto filter = opentelemetry::sdk::metrics::ExemplarFilter::GetWithTraceSampleFilter(); - ASSERT_FALSE( - filter->ShouldSampleMeasurement(1.0, MetricAttributes{}, opentelemetry::context::Context{})); - ASSERT_FALSE(filter->ShouldSampleMeasurement(static_cast(1), MetricAttributes{}, - opentelemetry::context::Context{})); -} diff --git a/sdk/test/metrics/sync_metric_storage_counter_test.cc b/sdk/test/metrics/sync_metric_storage_counter_test.cc index 89e8df46ff..f31599a8af 100644 --- a/sdk/test/metrics/sync_metric_storage_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_counter_test.cc @@ -27,7 +27,6 @@ #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif @@ -53,7 +52,7 @@ TEST_P(WritableMetricStorageTestFixture, LongCounterSumAggregation) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); @@ -193,7 +192,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleCounterSumAggregation) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); @@ -329,7 +328,7 @@ TEST(SyncMetricStorageTest, DeltaCounterStartTimestampTracksEmptyCycles) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); @@ -407,7 +406,7 @@ TEST(SyncMetricStorageTest, DeltaCounterFirstIntervalUsesInstrumentCreationTime) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); auto after_creation = std::chrono::system_clock::now(); @@ -460,7 +459,7 @@ TEST(SyncMetricStorageTest, DeltaCounterMultiCollectorFirstIntervalUsesInstrumen opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); auto after_creation = std::chrono::system_clock::now(); diff --git a/sdk/test/metrics/sync_metric_storage_gauge_test.cc b/sdk/test/metrics/sync_metric_storage_gauge_test.cc index 1dc0a4d2cd..2675a9aaf8 100644 --- a/sdk/test/metrics/sync_metric_storage_gauge_test.cc +++ b/sdk/test/metrics/sync_metric_storage_gauge_test.cc @@ -26,7 +26,6 @@ # include "opentelemetry/nostd/variant.h" # include "opentelemetry/sdk/metrics/data/metric_data.h" # include "opentelemetry/sdk/metrics/data/point_data.h" -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/state/metric_collector.h" # include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" @@ -58,7 +57,7 @@ TEST_P(WritableMetricStorageTestFixture, LongGaugeLastValueAggregation) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kLastValue, default_attributes_processor, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif nullptr); @@ -142,7 +141,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleGaugeLastValueAggregation) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kLastValue, default_attributes_processor, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif nullptr); @@ -236,7 +235,7 @@ TEST_P(WritableMetricStorageDeltaMultiReaderTestFixture, opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kLastValue, default_attributes_processor, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif nullptr); auto after_creation = std::chrono::system_clock::now(); @@ -417,7 +416,7 @@ TEST_P(WritableMetricStorageDeltaMultiReaderTestFixture, opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kLastValue, default_attributes_processor, # ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), # endif nullptr); auto after_creation = std::chrono::system_clock::now(); diff --git a/sdk/test/metrics/sync_metric_storage_histogram_test.cc b/sdk/test/metrics/sync_metric_storage_histogram_test.cc index 9f608bcd16..aabef07f14 100644 --- a/sdk/test/metrics/sync_metric_storage_histogram_test.cc +++ b/sdk/test/metrics/sync_metric_storage_histogram_test.cc @@ -27,7 +27,6 @@ #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif @@ -54,7 +53,7 @@ TEST_P(WritableMetricStorageHistogramTestFixture, LongHistogram) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kHistogram, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); @@ -195,7 +194,7 @@ TEST_P(WritableMetricStorageHistogramTestFixture, DoubleHistogram) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kHistogram, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); @@ -343,7 +342,7 @@ TEST_P(WritableMetricStorageHistogramTestFixture, Base2ExponentialDoubleHistogra opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kBase2ExponentialHistogram, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); 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 cf54165341..3b36aaa940 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 @@ -26,7 +26,6 @@ #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" #endif @@ -52,7 +51,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr); @@ -202,7 +201,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) opentelemetry::sdk::metrics::SyncMetricStorage storage( instr_desc, AggregationType::kSum, default_attributes_processor, #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW - ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), + ExemplarReservoir::GetNoExemplarReservoir(), #endif nullptr);