File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ These examples show how to customize the metrics that are output by the SDK usin
5
5
6
6
* preferred_aggregation.py: Shows how to configure the preferred aggregation for metric instrument types.
7
7
* preferred_temporality.py: Shows how to configure the preferred temporality for metric instrument types.
8
+ * preferred_exemplarfilter.py: Shows how to configure the exemplar filter.
8
9
9
10
The source files of these examples are available :scm_web: `here <docs/examples/metrics/reader/> `.
10
11
Original file line number Diff line number Diff line change 17
17
from opentelemetry .metrics import get_meter_provider , set_meter_provider
18
18
from opentelemetry .sdk .metrics import MeterProvider
19
19
from opentelemetry .sdk .metrics ._internal .exemplar import (
20
- TraceBasedExemplarFilter ,
20
+ AlwaysOnExemplarFilter ,
21
21
)
22
22
from opentelemetry .sdk .metrics .export import (
23
23
ConsoleMetricExporter ,
24
24
PeriodicExportingMetricReader ,
25
25
)
26
26
from opentelemetry .sdk .trace import TracerProvider
27
27
28
- # Create an ExemplarFilter instance (e.g., TraceBasedExemplarFilter)
29
- # Default available values are AlwaysOffExemplarFilter, AlwaysOnExemplarFilter
30
- # and TraceBasedExemplarFilter
31
- exemplar_filter = TraceBasedExemplarFilter ()
28
+ # Create an ExemplarFilter instance
29
+ # Available values are AlwaysOffExemplarFilter, AlwaysOnExemplarFilter
30
+ # and TraceBasedExemplarFilter.
31
+ # The default value is `TraceBasedExemplarFilter`.
32
+ #
33
+ # You can also use the environment variable `OTEL_METRICS_EXEMPLAR_FILTER`
34
+ # to change the default value.
35
+ #
36
+ # You can also define your own filter by implementing the abstract class
37
+ # `ExemplarFilter`
38
+ exemplar_filter = AlwaysOnExemplarFilter ()
32
39
33
40
exporter = ConsoleMetricExporter ()
34
41
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ These examples show how to customize the metrics that are output by the SDK usin
7
7
* change_name.py: Shows how to change the name of a metric.
8
8
* limit_num_of_attrs.py: Shows how to limit the number of attributes that are output for a metric.
9
9
* drop_metrics_from_instrument.py: Shows how to drop measurements from an instrument.
10
+ * change_reservoir_factory.py: Shows how to use your own ``ExemplarReservoir ``
10
11
11
12
The source files of these examples are available :scm_web: `here <docs/examples/metrics/views/> `.
12
13
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ def custom_reservoir_factory(
44
44
if issubclass (aggregationType , _ExplicitBucketHistogramAggregation ):
45
45
return AlignedHistogramBucketExemplarReservoir
46
46
else :
47
+ # Custom reservoir must accept `**kwargs` that may set the `size` for
48
+ # _ExponentialBucketHistogramAggregation or the `boundaries` for
49
+ # _ExplicitBucketHistogramAggregation
47
50
return lambda ** kwargs : SimpleFixedSizeExemplarReservoir (
48
51
size = 10 ,
49
52
** {k : v for k , v in kwargs .items () if k != "size" },
You can’t perform that action at this time.
0 commit comments