1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use ;
/// Used to customize the metrics that are output by the SDK.
///
/// Here are some examples when a [View] might be needed:
///
/// * Customize which Instruments are to be processed/ignored. For example, an
/// instrumented library can provide both temperature and humidity, but the
/// application developer might only want temperature.
/// * Customize the aggregation - if the default aggregation associated with the
/// [Instrument] does not meet the needs of the user. For example, an HTTP client
/// library might expose HTTP client request duration as Histogram by default,
/// but the application developer might only want the total count of outgoing
/// requests.
/// * Customize which attribute(s) are to be reported on metrics. For example,
/// an HTTP server library might expose HTTP verb (e.g. GET, POST) and HTTP
/// status code (e.g. 200, 301, 404). The application developer might only care
/// about HTTP status code (e.g. reporting the total count of HTTP requests for
/// each HTTP status code). There could also be extreme scenarios in which the
/// application developer does not need any attributes (e.g. just get the total
/// count of all incoming requests).
///
/// # Example Custom View
///
/// View is implemented for all `Fn(&Instrument) -> Option<Stream>`.
///
/// ```
/// use opentelemetry_sdk::metrics::{Instrument, SdkMeterProvider, Stream};
///
/// // return streams for the given instrument
/// let my_view = |i: &Instrument| {
/// // return Some(Stream) or
/// None
/// };
///
/// let provider = SdkMeterProvider::builder().with_view(my_view).build();
/// # drop(provider)
/// ```
pub