Class MetricFilter
Defined in File metric_filter.h
Class Documentation
-
class MetricFilter
MetricFilter defines the interface which enables the MetricReader’s registered MetricProducers or the SDK’s MetricProducer to filter aggregated data points (Metric Points) inside its Produce operation. The filtering is done at the MetricProducer for performance reasons.
The MetricFilter allows filtering an entire metric stream - dropping or allowing all its attribute sets - by its TestMetric operation, which accepts the metric stream information (scope, name, kind and unit) and returns an enumeration: kAccept, kDrop or kAcceptPartial. If the latter returned, the TestAttributes operation is to be called per attribute set of that metric stream, returning an enumeration determining if the data point for that (metric stream, attributes) pair is to be allowed in the result of the MetricProducer Produce operation.
Public Types
-
using TestMetricFn = std::function<MetricFilterResult(const opentelemetry::sdk::instrumentationscope::InstrumentationScope &scope, opentelemetry::nostd::string_view name, const InstrumentType &type, opentelemetry::nostd::string_view unit)>
-
using TestAttributesFn = std::function<AttributesFilterResult(const opentelemetry::sdk::instrumentationscope::InstrumentationScope &scope, opentelemetry::nostd::string_view name, const InstrumentType &type, opentelemetry::nostd::string_view unit, const PointAttributes &attributes)>
Public Functions
-
inline MetricFilter(const TestMetricFn &test_metric_fn, const TestAttributesFn &test_attributes_fn)
-
inline MetricFilterResult TestMetric(const opentelemetry::sdk::instrumentationscope::InstrumentationScope &scope, opentelemetry::nostd::string_view name, const InstrumentType &type, opentelemetry::nostd::string_view unit)
TestMetric is called once for every metric stream, in each MetricProducer Produce operation.
-
inline AttributesFilterResult TestAttributes(const opentelemetry::sdk::instrumentationscope::InstrumentationScope &scope, opentelemetry::nostd::string_view name, const InstrumentType &type, opentelemetry::nostd::string_view unit, const PointAttributes &attributes)
TestAttributes determines for a given metric stream and attribute set if it should be allowed or filtered out.
This operation should only be called if TestMetric operation returned kAcceptPartial for the given metric stream arguments.
Public Static Functions
-
static inline std::unique_ptr<MetricFilter> Create(const TestMetricFn &test_metric_fn, const TestAttributesFn &test_attributes_fn)
-
using TestMetricFn = std::function<MetricFilterResult(const opentelemetry::sdk::instrumentationscope::InstrumentationScope &scope, opentelemetry::nostd::string_view name, const InstrumentType &type, opentelemetry::nostd::string_view unit)>