opentelemetry.sdk.metrics.view

class opentelemetry.sdk.metrics.view.Aggregation[source]

Bases: abc.ABC

Base class for all aggregation types.

class opentelemetry.sdk.metrics.view.DefaultAggregation[source]

Bases: opentelemetry.sdk.metrics._internal.aggregation.Aggregation

The default aggregation to be used in a View.

This aggregation will create an actual aggregation depending on the instrument type, as specified next:

Instrument

Aggregation

opentelemetry.sdk.metrics.Counter

SumAggregation

opentelemetry.sdk.metrics.UpDownCounter

SumAggregation

opentelemetry.sdk.metrics.ObservableCounter

SumAggregation

opentelemetry.sdk.metrics.ObservableUpDownCounter

SumAggregation

opentelemetry.sdk.metrics.Histogram

ExplicitBucketHistogramAggregation

opentelemetry.sdk.metrics.ObservableGauge

LastValueAggregation

class opentelemetry.sdk.metrics.view.DropAggregation[source]

Bases: opentelemetry.sdk.metrics._internal.aggregation.Aggregation

Using this aggregation will make all measurements be ignored.

class opentelemetry.sdk.metrics.view.ExplicitBucketHistogramAggregation(boundaries=(0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0, 7500.0, 10000.0), record_min_max=True)[source]

Bases: opentelemetry.sdk.metrics._internal.aggregation.Aggregation

This aggregation informs the SDK to collect:

  • Count of Measurement values falling within explicit bucket boundaries.

  • Arithmetic sum of Measurement values in population. This SHOULD NOT be collected when used with instruments that record negative measurements, e.g. UpDownCounter or ObservableGauge.

  • Min (optional) Measurement value in population.

  • Max (optional) Measurement value in population.

Parameters
  • boundaries (Sequence[float]) – Array of increasing values representing explicit bucket boundary values.

  • record_min_max (bool) – Whether to record min and max.

class opentelemetry.sdk.metrics.view.ExponentialBucketHistogramAggregation(max_size=160, max_scale=20)[source]

Bases: opentelemetry.sdk.metrics._internal.aggregation.Aggregation

class opentelemetry.sdk.metrics.view.LastValueAggregation[source]

Bases: opentelemetry.sdk.metrics._internal.aggregation.Aggregation

This aggregation informs the SDK to collect:

  • The last Measurement.

  • The timestamp of the last Measurement.

class opentelemetry.sdk.metrics.view.SumAggregation[source]

Bases: opentelemetry.sdk.metrics._internal.aggregation.Aggregation

This aggregation informs the SDK to collect:

  • The arithmetic sum of Measurement values.

class opentelemetry.sdk.metrics.view.View(instrument_type=None, instrument_name=None, meter_name=None, meter_version=None, meter_schema_url=None, name=None, description=None, attribute_keys=None, aggregation=None, instrument_unit=None)[source]

Bases: object

A View configuration parameters can be used for the following purposes:

  1. Match instruments: When an instrument matches a view, measurements received by that instrument will be processed.

  2. Customize metric streams: A metric stream is identified by a match between a view and an instrument and a set of attributes. The metric stream can be customized by certain attributes of the corresponding view.

The attributes documented next serve one of the previous two purposes.

Parameters
  • instrument_type (Optional[Type[Instrument]]) – This is an instrument matching attribute: the class the instrument must be to match the view.

  • instrument_name (Optional[str]) – This is an instrument matching attribute: the name the instrument must have to match the view. Wild card characters are supported. Wild card characters should not be used with this attribute if the view has also a name defined.

  • meter_name (Optional[str]) – This is an instrument matching attribute: the name the instrument meter must have to match the view.

  • meter_version (Optional[str]) – This is an instrument matching attribute: the version the instrument meter must have to match the view.

  • meter_schema_url (Optional[str]) – This is an instrument matching attribute: the schema URL the instrument meter must have to match the view.

  • name (Optional[str]) – This is a metric stream customizing attribute: the name of the metric stream. If None, the name of the instrument will be used.

  • description (Optional[str]) – This is a metric stream customizing attribute: the description of the metric stream. If None, the description of the instrument will be used.

  • attribute_keys (Optional[Set[str]]) – This is a metric stream customizing attribute: this is a set of attribute keys. If not None then only the measurement attributes that are in attribute_keys will be used to identify the metric stream.

  • aggregation (Optional[Aggregation]) – This is a metric stream customizing attribute: the aggregation instance to use when data is aggregated for the corresponding metrics stream. If None an instance of DefaultAggregation will be used.

  • instrument_unit (Optional[str]) – This is an instrument matching attribute: the unit the instrument must have to match the view.

This class is not intended to be subclassed by the user.