diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context.h b/sdk/include/opentelemetry/sdk/metrics/meter_context.h index 336f5da7a0..ea0ef27973 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context.h @@ -12,6 +12,7 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/metrics/exemplar/filter.h" #include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -107,6 +108,9 @@ class MeterContext : public std::enable_shared_from_this std::unique_ptr meter_selector, std::unique_ptr view) noexcept; + void SetExemplarFilter( + std::unique_ptr exemplar_filter) noexcept; + /** * NOTE - INTERNAL method, can change in future. * Adds a meter to the list of configured meters in thread safe manner. @@ -135,6 +139,7 @@ class MeterContext : public std::enable_shared_from_this opentelemetry::sdk::resource::Resource resource_; std::vector> collectors_; std::unique_ptr views_; + std::unique_ptr exemplar_filter_; opentelemetry::common::SystemTimestamp sdk_start_ts_; std::vector> meters_; diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index c7089844a5..f6ea866049 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -10,6 +10,7 @@ #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/metrics/exemplar/filter.h" #include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -100,6 +101,9 @@ class MeterProvider final : public opentelemetry::metrics::MeterProvider std::unique_ptr meter_selector, std::unique_ptr view) noexcept; + void SetExemplarFilter( + std::unique_ptr exemplar_filter) noexcept; + /** * Shutdown the meter provider. */ diff --git a/sdk/src/metrics/meter_context.cc b/sdk/src/metrics/meter_context.cc index 7a299bfc63..8c72ca654e 100644 --- a/sdk/src/metrics/meter_context.cc +++ b/sdk/src/metrics/meter_context.cc @@ -74,6 +74,12 @@ void MeterContext::AddView(std::unique_ptr instrument_select views_->AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); } +void MeterContext::SetExemplarFilter( + std::unique_ptr exemplar_filter) noexcept +{ + exemplar_filter_ = std::move(exemplar_filter); +} + void MeterContext::AddMeter(std::shared_ptr meter) { std::lock_guard guard(meter_lock_); diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 63bea5ae28..eed5008166 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -110,6 +110,12 @@ void MeterProvider::AddView(std::unique_ptr instrument_selec std::move(view)); } +void MeterProvider::SetExemplarFilter( + std::unique_ptr exemplar_filter) noexcept +{ + return context_->SetExemplarFilter(std::move(exemplar_filter)); +} + /** * Shutdown the meter provider. */