Otel.SDK.Metrics.View (otel v0.2.0)

Copy Markdown View Source

Instrument selection criteria + stream configuration (metrics/sdk.md §View L259-L327).

A View maps matching instruments to metric streams by specifying which instruments to select and how the resulting stream should be configured (name override, description override, attribute filtering, aggregation, etc.).

All selection criteria are optional and additive (AND). An instrument must match all provided criteria for the View to apply.

References

  • OTel Metrics SDK §View: opentelemetry-specification/specification/metrics/sdk.md L259-L327

Summary

Types

config()

@type config() :: %{
  optional(:name) => String.t(),
  optional(:description) => String.t(),
  optional(:attribute_keys) =>
    {:include, [String.t()]} | {:exclude, [String.t()]},
  optional(:aggregation) => module(),
  optional(:aggregation_options) => map(),
  optional(:exemplar_reservoir) => module(),
  optional(:aggregation_cardinality_limit) => pos_integer()
}

criteria()

@type criteria() :: %{
  optional(:name) => String.t(),
  optional(:type) => Otel.API.Metrics.Instrument.kind(),
  optional(:unit) => String.t(),
  optional(:meter_name) => String.t(),
  optional(:meter_version) => String.t(),
  optional(:meter_schema_url) => String.t()
}

primitive()

@type primitive() ::
  String.t() | {:bytes, binary()} | boolean() | integer() | float() | nil

primitive_any()

@type primitive_any() ::
  primitive() | [primitive_any()] | %{required(String.t()) => primitive_any()}

t()

@type t() :: %Otel.SDK.Metrics.View{config: config(), criteria: criteria()}

Functions

description(view, instrument)

@spec description(view :: t(), instrument :: Otel.API.Metrics.Instrument.t()) ::
  String.t()

matches?(view, instrument)

@spec matches?(view :: t(), instrument :: Otel.API.Metrics.Instrument.t()) ::
  boolean()

name(view, instrument)

@spec name(view :: t(), instrument :: Otel.API.Metrics.Instrument.t()) :: String.t()

new(criteria \\ %{}, config \\ %{})

@spec new(criteria :: criteria(), config :: config()) ::
  {:ok, t()} | {:error, String.t()}