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
55
66* preferred_aggregation.py: Shows how to configure the preferred aggregation for metric instrument types.
77* 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.
89
910The source files of these examples are available :scm_web: `here <docs/examples/metrics/reader/> `.
1011
Original file line number Diff line number Diff line change 1717from opentelemetry .metrics import get_meter_provider , set_meter_provider
1818from opentelemetry .sdk .metrics import MeterProvider
1919from opentelemetry .sdk .metrics ._internal .exemplar import (
20- TraceBasedExemplarFilter ,
20+ AlwaysOnExemplarFilter ,
2121)
2222from opentelemetry .sdk .metrics .export import (
2323 ConsoleMetricExporter ,
2424 PeriodicExportingMetricReader ,
2525)
2626from opentelemetry .sdk .trace import TracerProvider
2727
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 ()
3239
3340exporter = ConsoleMetricExporter ()
3441
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
77* change_name.py: Shows how to change the name of a metric.
88* limit_num_of_attrs.py: Shows how to limit the number of attributes that are output for a metric.
99* 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 ``
1011
1112The source files of these examples are available :scm_web: `here <docs/examples/metrics/views/> `.
1213
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ def custom_reservoir_factory(
4444 if issubclass (aggregationType , _ExplicitBucketHistogramAggregation ):
4545 return AlignedHistogramBucketExemplarReservoir
4646 else :
47+ # Custom reservoir must accept `**kwargs` that may set the `size` for
48+ # _ExponentialBucketHistogramAggregation or the `boundaries` for
49+ # _ExplicitBucketHistogramAggregation
4750 return lambda ** kwargs : SimpleFixedSizeExemplarReservoir (
4851 size = 10 ,
4952 ** {k : v for k , v in kwargs .items () if k != "size" },
You can’t perform that action at this time.
0 commit comments