Function opentelemetry_sdk::metrics::new_view

source ·
pub fn new_view(criteria: Instrument, mask: Stream) -> Result<Box<dyn View>>
Expand description

Creates a View that applies the Stream mask for all instruments that match criteria.

The returned View will only apply the mask if all non-empty fields of criteria match the corresponding Instrument passed to the view. If all fields of the criteria are their default values, a view that matches no instruments is returned. If you need to match an empty-value field, create a View directly.

The Instrument::name field of criteria supports wildcard pattern matching. The wildcard * is recognized as matching zero or more characters, and ? is recognized as matching exactly one character. For example, a pattern of * will match all instrument names.

The Stream mask only applies updates for non-empty fields. By default, the Instrument the View matches against will be use for the name, description, and unit of the returned Stream and no aggregation or allowed_attribute_keys are set. All non-empty fields of mask are used instead of the default. If you need to set a an empty value in the returned stream, create a custom View directly.

§Example

use opentelemetry_sdk::metrics::{new_view, Aggregation, Instrument, Stream};

let criteria = Instrument::new().name("counter_*");
let mask = Stream::new().aggregation(Aggregation::Sum);

let view = new_view(criteria, mask);