Otel.Metrics.Exemplar (otel v0.4.1)

Copy Markdown View Source

An Exemplar is a recorded measurement that links metric data to trace context. Exemplars are sampled from measurements by ExemplarReservoirs and attached to metric data points during collection.

Trace context invariant

Reservoirs only construct Exemplars after Otel.Metrics.Exemplar.Filter.should_sample?/1 accepts the context — that filter passes only when the active span has the W3C trace_flags sampled bit set, which means the span is valid (non-zero trace_id / span_id). The struct fields therefore mirror Otel.Trace.Span and Otel.Logs.LogRecord: trace_id: TraceId.t() (no | nil), with the proto3 zero-value 0 as the unset default.

Summary

Functions

SDK — Build an Exemplar from struct fields. Reservoirs destructure Otel.Trace.current_span(ctx) directly to obtain :trace_id / :span_id for the call.

Types

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.Metrics.Exemplar{
  filtered_attributes: %{required(String.t()) => primitive_any()},
  span_id: Otel.Trace.SpanId.t(),
  time: non_neg_integer(),
  trace_id: Otel.Trace.TraceId.t(),
  value: number()
}

Functions

new(opts \\ %{})

@spec new(opts :: map()) :: t()

SDK — Build an Exemplar from struct fields. Reservoirs destructure Otel.Trace.current_span(ctx) directly to obtain :trace_id / :span_id for the call.