componentized

Types

use record datetime

from wasi:clocks/wall-clock@0.2.0

A time and date in seconds plus nanoseconds.

  • seconds: u64
  • nanoseconds: u32

use type duration

from wasi:clocks/monotonic-clock@0.2.0

A duration of time, in nanoseconds.

  • u64

use record key-value

from wasi:otel/types@0.2.0-rc.2

A key-value pair describing an attribute.

  • key: key

    The attribute name.

  • value: value

    The attribute value.

use record instrumentation-scope

from wasi:otel/types@0.2.0-rc.2

Describes the instrumentation scope that produced telemetry.

  • name: string

    Name of the instrumentation scope.

  • version: option<string>

    The library version.

  • schema-url: option<string>

    Schema URL used by this library. https://opentelemetry.io/docs/specs/otel/schemas/#schema-url

  • attributes: list<key-value>

    Specifies the instrumentation scope attributes to associate with emitted telemetry.

use record resource

from wasi:otel/types@0.2.0-rc.2

An immutable representation of the entity producing telemetry as attributes.

  • attributes: list<key-value>

    Attributes that identify the resource.

  • schema-url: option<string>

    The schema URL to be recorded in the emitted resource.

use type span-id

from wasi:otel/tracing@0.2.0-rc.2

The id of this span-context.

8 bytes encoded as a hexadecimal string.

  • string

use type trace-id

from wasi:otel/tracing@0.2.0-rc.2

The trace that this span-context belongs to.

16 bytes encoded as a hexadecimal string.

  • string

type error

An error resulting from export being called.

  • string

record exponential-bucket

A set of bucket counts, encoded in a contiguous array of counts.

  • offset: s32

    The bucket index of the first entry in the counts list.

  • counts: list<u64>

    A list where counts[i] carries the count of the bucket at index offset + i.

    counts[i] is the count of values greater than base^(offset+i) and less than or equal to base^(offset+i+1).

enum temporality

Defines the window that an aggregation was calculated over.

  • cumulative

    A measurement interval that continues to expand forward in time from a starting point.

    New measurements are added to all previous measurements since a start time.

    This is the default temporality.

  • delta

    A measurement interval that resets each cycle.

    Measurements from one cycle are recorded independently, measurements from other cycles do not affect them.

  • low-memory

    Configures Synchronous Counter and Histogram instruments to use Delta aggregation temporality, which allows them to shed memory following a cardinality explosion, thus use less memory.

variant metric-number

The number types available for any given instrument.

  • f64: f64
  • s64: s64
  • u64: u64

record exemplar

A measurement sampled from a time series providing a typical example.

  • filtered-attributes: list<key-value>

    The attributes recorded with the measurement but filtered out of the time series' aggregated data.

  • time: datetime

    The time when the measurement was recorded.

  • value: metric-number

    The measured value.

  • span-id: span-id

    The ID of the span that was active during the measurement.

    If no span was active or the span was not sampled this will be empty.

  • trace-id: trace-id

    The ID of the trace the active span belonged to during the measurement.

    If no span was active or the span was not sampled this will be empty.

record gauge-data-point

A single data point in a time series to be associated with a gauge.

  • attributes: list<key-value>

    attributes is the set of key value pairs that uniquely identify the time series.

  • value: metric-number

    The value of this data point.

  • exemplars: list<exemplar>

    The sampled exemplars collected during the time series.

record gauge

A measurement of the current value of an instrument.

  • data-points: list<gauge-data-point>

    Represents individual aggregated measurements with unique attributes.

  • start-time: option<datetime>

    The time when the time series was started.

  • time: datetime

    The time when the time series was recorded.

record sum-data-point

A single data point in a time series to be associated with a sum.

  • attributes: list<key-value>

    attributes is the set of key value pairs that uniquely identify the time series.

  • value: metric-number

    The value of this data point.

  • exemplars: list<exemplar>

    The sampled exemplars collected during the time series.

record sum

Represents the sum of all measurements of values from an instrument.

  • data-points: list<sum-data-point>

    Represents individual aggregated measurements with unique attributes.

  • start-time: datetime

    The time when the time series was started.

  • time: datetime

    The time when the time series was recorded.

  • temporality: temporality

    Describes if the aggregation is reported as the change from the last report time, or the cumulative changes since a fixed start time.

  • is-monotonic: bool

    Whether this aggregation only increases or decreases.

record histogram-data-point

A single data point in a time series to be associated with a histogram.

  • attributes: list<key-value>

    The set of key value pairs that uniquely identify the time series.

  • count: u64

    The number of updates this histogram has been calculated with.

  • bounds: list<f64>

    The upper bounds of the buckets of the histogram.

  • bucket-counts: list<u64>

    The count of each of the buckets.

  • min: option<metric-number>

    The minimum value recorded.

  • max: option<metric-number>

    The maximum value recorded.

  • sum: metric-number

    The sum of the values recorded

  • exemplars: list<exemplar>

    The sampled exemplars collected during the time series.

record histogram

Represents the histogram of all measurements of values from an instrument.

  • data-points: list<histogram-data-point>

    Individual aggregated measurements with unique attributes.

  • start-time: datetime

    The time when the time series was started.

  • time: datetime

    The time when the time series was recorded.

  • temporality: temporality

    Describes if the aggregation is reported as the change from the last report time, or the cumulative changes since a fixed start time.

record exponential-histogram-data-point

A single data point in a time series to be associated with an exponential-histogram .

  • attributes: list<key-value>

    The set of key value pairs that uniquely identify the time series.

  • count: u64

    The number of updates this histogram has been calculated with.

  • min: option<metric-number>

    The minimum value recorded.

  • max: option<metric-number>

    The maximum value recorded.

  • sum: metric-number

    The maximum value recorded.

  • scale: s8

    Describes the resolution of the histogram.

    Boundaries are located at powers of the base, where:

    base = 2 ^ (2 ^ -scale)

  • zero-count: u64

    The number of values whose absolute value is less than or equal to zero_threshold.

    When zero_threshold is 0, this is the number of values that cannot be expressed using the standard exponential formula as well as values that have been rounded to zero.

  • positive-bucket: exponential-bucket

    The range of positive value bucket counts.

  • negative-bucket: exponential-bucket

    The range of negative value bucket counts.

  • zero-threshold: f64

    The width of the zero region.

    Where the zero region is defined as the closed interval [-zero_threshold, zero_threshold].

  • exemplars: list<exemplar>

    The sampled exemplars collected during the time series.

record exponential-histogram

The histogram of all measurements of values from an instrument.

  • data-points: list<exponential-histogram-data-point>

    The individual aggregated measurements with unique attributes.

  • start-time: datetime

    When the time series was started.

  • time: datetime

    The time when the time series was recorded.

  • temporality: temporality

    Describes if the aggregation is reported as the change from the last report time, or the cumulative changes since a fixed start time.

variant metric-data

Metric data for all types.

  • f64-gauge: gauge

    Metric data for an f64 gauge.

  • f64-sum: sum

    Metric data for an f64 sum.

  • f64-histogram: histogram

    Metric data for an f64 histogram.

  • f64-exponential-histogram: exponential-histogram

    Metric data for an f64 exponential-histogram.

  • u64-gauge: gauge

    Metric data for an u64 gauge.

  • u64-sum: sum

    Metric data for an u64 sum.

  • u64-histogram: histogram

    Metric data for an u64 histogram.

  • u64-exponential-histogram: exponential-histogram

    Metric data for an u64 exponential-histogram.

  • s64-gauge: gauge

    Metric data for an s64 gauge.

  • s64-sum: sum

    Metric data for an s64 sum.

  • s64-histogram: histogram

    Metric data for an s64 histogram.

  • s64-exponential-histogram: exponential-histogram

    Metric data for an s64 exponential-histogram.

record metric

A collection of one or more aggregated time series from a metric.

  • name: string

    The name of the metric that created this data.

  • description: string

    The description of the metric, which can be used in documentation.

  • unit: string

    The unit in which the metric reports.

  • data: metric-data

    The aggregated data from a metric.

record scope-metrics

A collection of metrics produced by a meter.

  • scope: instrumentation-scope

    The instrumentation scope that the meter was created with.

  • metrics: list<metric>

    The list of aggregations created by the meter.

record resource-metrics

A collection of scope-metrics and the associated resource that created them.

  • resource: resource

    The entity that collected the metrics.

  • scope-metrics: list<scope-metrics>

    The collection of metrics with unique instrumentation-scopes.

Functions

functionexport: func(metrics: resource-metrics) -> result<_, error>

Exports a resource's metric data.

WIT

interface metrics {
  use wasi:clocks/wall-clock@0.2.0.{datetime};
  use wasi:clocks/monotonic-clock@0.2.0.{duration};
  use types.{key-value, instrumentation-scope, %resource};
  use tracing.{span-id, trace-id};

  /// An error resulting from `export` being called.
  type error = string;

  /// A set of bucket counts, encoded in a contiguous array of counts.
  record exponential-bucket {
    /// The bucket index of the first entry in the `counts` list.
    offset: s32,
    /// A list where `counts[i]` carries the count of the bucket at index `offset + i`.
    ///
    /// `counts[i]` is the count of values greater than base^(offset+i) and less than
    /// or equal to base^(offset+i+1).
    counts: list<u64>,
  }

  /// Defines the window that an aggregation was calculated over.
  enum temporality {
    /// A measurement interval that continues to expand forward in time from a
    /// starting point.
    ///
    /// New measurements are added to all previous measurements since a start time.
    ///
    /// This is the default temporality.
    cumulative,
    /// A measurement interval that resets each cycle.
    ///
    /// Measurements from one cycle are recorded independently, measurements from
    /// other cycles do not affect them.
    delta,
    /// Configures Synchronous Counter and Histogram instruments to use
    /// Delta aggregation temporality, which allows them to shed memory
    /// following a cardinality explosion, thus use less memory.
    low-memory,
  }

  /// The number types available for any given instrument.
  variant metric-number {
    %f64(f64),
    %s64(s64),
    %u64(u64),
  }

  /// A measurement sampled from a time series providing a typical example.
  record exemplar {
    /// The attributes recorded with the measurement but filtered out of the
    /// time series' aggregated data.
    filtered-attributes: list<key-value>,
    /// The time when the measurement was recorded.
    time: datetime,
    /// The measured value.
    value: metric-number,
    /// The ID of the span that was active during the measurement.
    ///
    /// If no span was active or the span was not sampled this will be empty.
    span-id: span-id,
    /// The ID of the trace the active span belonged to during the measurement.
    ///
    /// If no span was active or the span was not sampled this will be empty.
    trace-id: trace-id,
  }

  /// A single data point in a time series to be associated with a `gauge`.
  record gauge-data-point {
    /// `attributes` is the set of key value pairs that uniquely identify the
    /// time series.
    attributes: list<key-value>,
    /// The value of this data point.
    value: metric-number,
    /// The sampled `exemplar`s collected during the time series.
    exemplars: list<exemplar>,
  }

  /// A measurement of the current value of an instrument.
  record gauge {
    /// Represents individual aggregated measurements with unique attributes.
    data-points: list<gauge-data-point>,
    /// The time when the time series was started.
    start-time: option<datetime>,
    /// The time when the time series was recorded.
    time: datetime,
  }

  /// A single data point in a time series to be associated with a `sum`.
  record sum-data-point {
    /// `attributes` is the set of key value pairs that uniquely identify the
    /// time series.
    attributes: list<key-value>,
    /// The value of this data point.
    value: metric-number,
    /// The sampled `exemplar`s collected during the time series.
    exemplars: list<exemplar>,
  }

  /// Represents the sum of all measurements of values from an instrument.
  record sum {
    /// Represents individual aggregated measurements with unique attributes.
    data-points: list<sum-data-point>,
    /// The time when the time series was started.
    start-time: datetime,
    /// The time when the time series was recorded.
    time: datetime,
    /// Describes if the aggregation is reported as the change from the last report
    /// time, or the cumulative changes since a fixed start time.
    temporality: temporality,
    /// Whether this aggregation only increases or decreases.
    is-monotonic: bool,
  }

  /// A single data point in a time series to be associated with a `histogram`.
  record histogram-data-point {
    /// The set of key value pairs that uniquely identify the time series.
    attributes: list<key-value>,
    /// The number of updates this histogram has been calculated with.
    count: u64,
    /// The upper bounds of the buckets of the histogram.
    bounds: list<f64>,
    /// The count of each of the buckets.
    bucket-counts: list<u64>,
    /// The minimum value recorded.
    min: option<metric-number>,
    /// The maximum value recorded.
    max: option<metric-number>,
    /// The sum of the values recorded
    sum: metric-number,
    /// The sampled `exemplar`s collected during the time series.
    exemplars: list<exemplar>,
  }

  /// Represents the histogram of all measurements of values from an instrument.
  record histogram {
    /// Individual aggregated measurements with unique attributes.
    data-points: list<histogram-data-point>,
    /// The time when the time series was started.
    start-time: datetime,
    /// The time when the time series was recorded.
    time: datetime,
    /// Describes if the aggregation is reported as the change from the last report
    /// time, or the cumulative changes since a fixed start time.
    temporality: temporality,
  }

  /// A single data point in a time series to be associated with an `exponential-histogram `.
  record exponential-histogram-data-point {
    /// The set of key value pairs that uniquely identify the time series.
    attributes: list<key-value>,
    /// The number of updates this histogram has been calculated with.
    count: u64,
    /// The minimum value recorded.
    min: option<metric-number>,
    /// The maximum value recorded.
    max: option<metric-number>,
    /// The maximum value recorded.
    sum: metric-number,
    /// Describes the resolution of the histogram.
    ///
    /// Boundaries are located at powers of the base, where:
    ///
    ///   base = 2 ^ (2 ^ -scale)
    scale: s8,
    /// The number of values whose absolute value is less than or equal to
    /// `zero_threshold`.
    ///
    /// When `zero_threshold` is `0`, this is the number of values that cannot be
    /// expressed using the standard exponential formula as well as values that have
    /// been rounded to zero.
    zero-count: u64,
    /// The range of positive value bucket counts.
    positive-bucket: exponential-bucket,
    /// The range of negative value bucket counts.
    negative-bucket: exponential-bucket,
    /// The width of the zero region.
    ///
    /// Where the zero region is defined as the closed interval
    /// [-zero_threshold, zero_threshold].
    zero-threshold: f64,
    /// The sampled exemplars collected during the time series.
    exemplars: list<exemplar>,
  }

  /// The histogram of all measurements of values from an instrument.
  record exponential-histogram {
    /// The individual aggregated measurements with unique attributes.
    data-points: list<exponential-histogram-data-point>,
    /// When the time series was started.
    start-time: datetime,
    /// The time when the time series was recorded.
    time: datetime,
    /// Describes if the aggregation is reported as the change from the last report
    /// time, or the cumulative changes since a fixed start time.
    temporality: temporality,
  }

  /// Metric data for all types.
  variant metric-data {
    /// Metric data for an f64 gauge.
    f64-gauge(gauge),
    /// Metric data for an f64 sum.
    f64-sum(sum),
    /// Metric data for an f64 histogram.
    f64-histogram(histogram),
    /// Metric data for an f64 exponential-histogram.
    f64-exponential-histogram(exponential-histogram),
    /// Metric data for an u64 gauge.
    u64-gauge(gauge),
    /// Metric data for an u64 sum.
    u64-sum(sum),
    /// Metric data for an u64 histogram.
    u64-histogram(histogram),
    /// Metric data for an u64 exponential-histogram.
    u64-exponential-histogram(exponential-histogram),
    /// Metric data for an s64 gauge.
    s64-gauge(gauge),
    /// Metric data for an s64 sum.
    s64-sum(sum),
    /// Metric data for an s64 histogram.
    s64-histogram(histogram),
    /// Metric data for an s64 exponential-histogram.
    s64-exponential-histogram(exponential-histogram),
  }

  /// A collection of one or more aggregated time series from a metric.
  record metric {
    /// The name of the metric that created this data.
    name: string,
    /// The description of the metric, which can be used in documentation.
    description: string,
    /// The unit in which the metric reports.
    unit: string,
    /// The aggregated data from a metric.
    data: metric-data,
  }

  /// A collection of `metric`s produced by a meter.
  record scope-metrics {
    /// The instrumentation scope that the meter was created with.
    scope: instrumentation-scope,
    /// The list of aggregations created by the meter.
    metrics: list<metric>,
  }

  /// A collection of `scope-metrics` and the associated `resource` that created them.
  record resource-metrics {
    /// The entity that collected the metrics.
    %resource: %resource,
    /// The collection of metrics with unique `instrumentation-scope`s.
    scope-metrics: list<scope-metrics>,
  }

  /// Exports a resource's metric data.
  %export: func(metrics: resource-metrics) -> result<_, error>;
}