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 record key-value

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

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.1

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.

type trace-id

The trace that this span-context belongs to.

16 bytes encoded as a hexadecimal string.

  • string

type span-id

The id of this span-context.

8 bytes encoded as a hexadecimal string.

  • string

flags trace-flags

Flags that can be set on a span-context.

  • sampled

    Whether the span should be sampled or not.

type trace-state

Carries system-specific configuration data, represented as a list of key-value pairs. trace-state allows multiple tracing systems to participate in the same trace.

If any invalid keys or values are provided then the trace-state will be treated as an empty list.

  • list<tuple<string, string>>

record span-context

Identifying trace information about a span that can be serialized and propagated.

  • trace-id: trace-id

    The trace-id for this span-context.

  • span-id: span-id

    The span-id for this span-context.

  • trace-flags: trace-flags

    The trace-flags for this span-context.

  • is-remote: bool

    Whether this span-context was propagated from a remote parent.

  • trace-state: trace-state

    The trace-state for this span-context.

enum span-kind

Describes the relationship between the Span, its parents, and its children in a trace.

  • client

    Indicates that the span describes a request to some remote service. This span is usually the parent of a remote server span and does not end until the response is received.

  • server

    Indicates that the span covers server-side handling of a synchronous RPC or other remote request. This span is often the child of a remote client span that was expected to wait for a response.

  • producer

    Indicates that the span describes the initiators of an asynchronous request. This parent span will often end before the corresponding child consumer span, possibly even before the child span starts. In messaging scenarios with batching, tracing individual messages requires a new producer span per message to be created.

  • consumer

    Indicates that the span describes a child of an asynchronous consumer request.

  • internal

    Default value. Indicates that the span represents an internal operation within an application, as opposed to an operations with remote parents or children.

record event

An event describing a specific moment in time on a span and associated attributes.

  • name: string

    Event name.

  • time: datetime

    Event time.

  • attributes: list<key-value>

    Event attributes.

variant status

The status of a span.

  • unset

    The default status.

  • ok

    The operation has been validated by an Application developer or Operator to have completed successfully.

  • error: string

    The operation contains an error with a description.

record span-data

The data associated with a span.

  • span-context: span-context

    Span context.

  • parent-span-id: string

    Span parent id.

  • span-kind: span-kind

    Span kind.

  • name: string

    Span name.

  • start-time: datetime

    Span start time.

  • end-time: datetime

    Span end time.

  • attributes: list<key-value>

    Span attributes.

  • events: list<event>

    Span events.

  • links: list<link>

    Span Links.

  • status: status

    Span status.

  • instrumentation-scope: instrumentation-scope

    Instrumentation scope that produced this span.

  • dropped-attributes: u32

    Number of attributes dropped by the span due to limits being reached.

  • dropped-events: u32

    Number of events dropped by the span due to limits being reached.

  • dropped-links: u32

    Number of links dropped by the span due to limits being reached.

Functions

functionon-start: func(context: span-context)

Called when a span is started.

functionon-end: func(span: span-data)

Called when a span is ended.

functionouter-span-context: func() -> span-context

Returns the span context of the host.

WIT

interface tracing {
  use wasi:clocks/wall-clock@0.2.0.{datetime};
  use types.{key-value, instrumentation-scope};

  /// The trace that this `span-context` belongs to.
  ///
  /// 16 bytes encoded as a hexadecimal string.
  type trace-id = string;

  /// The id of this `span-context`.
  ///
  /// 8 bytes encoded as a hexadecimal string.
  type span-id = string;

  /// Flags that can be set on a `span-context`.
  flags trace-flags {
    /// Whether the `span` should be sampled or not.
    sampled,
  }

  /// Carries system-specific configuration data, represented as a list of key-value pairs. `trace-state` allows multiple tracing systems to participate in the same trace.
  ///
  /// If any invalid keys or values are provided then the `trace-state` will be treated as an empty list.
  type trace-state = list<tuple<string, string>>;

  /// Identifying trace information about a span that can be serialized and propagated.
  record span-context {
    /// The `trace-id` for this `span-context`.
    trace-id: trace-id,
    /// The `span-id` for this `span-context`.
    span-id: span-id,
    /// The `trace-flags` for this `span-context`.
    trace-flags: trace-flags,
    /// Whether this `span-context` was propagated from a remote parent.
    is-remote: bool,
    /// The `trace-state` for this `span-context`.
    trace-state: trace-state,
  }

  /// Describes the relationship between the Span, its parents, and its children in a trace.
  enum span-kind {
    /// Indicates that the span describes a request to some remote service. This span is usually the parent of a remote server span and does not end until the response is received.
    client,
    /// Indicates that the span covers server-side handling of a synchronous RPC or other remote request. This span is often the child of a remote client span that was expected to wait for a response.
    server,
    /// Indicates that the span describes the initiators of an asynchronous request. This parent span will often end before the corresponding child consumer span, possibly even before the child span starts. In messaging scenarios with batching, tracing individual messages requires a new producer span per message to be created.
    producer,
    /// Indicates that the span describes a child of an asynchronous consumer request.
    consumer,
    /// Default value. Indicates that the span represents an internal operation within an application, as opposed to an operations with remote parents or children.
    internal,
  }

  /// An event describing a specific moment in time on a span and associated attributes.
  record event {
    /// Event name.
    name: string,
    /// Event time.
    time: datetime,
    /// Event attributes.
    attributes: list<key-value>,
  }

  /// Describes a relationship to another `span`.
  record link {
    /// Denotes which `span` to link to.
    span-context: span-context,
    /// Attributes describing the link.
    attributes: list<key-value>,
  }

  /// The `status` of a `span`.
  variant status {
    /// The default status.
    unset,
    /// The operation has been validated by an Application developer or Operator to have completed successfully.
    ok,
    /// The operation contains an error with a description.
    error(string),
  }

  /// The data associated with a span.
  record span-data {
    /// Span context.
    span-context: span-context,
    /// Span parent id.
    parent-span-id: string,
    /// Span kind.
    span-kind: span-kind,
    /// Span name.
    name: string,
    /// Span start time.
    start-time: datetime,
    /// Span end time.
    end-time: datetime,
    /// Span attributes.
    attributes: list<key-value>,
    /// Span events.
    events: list<event>,
    /// Span Links.
    links: list<link>,
    /// Span status.
    status: status,
    /// Instrumentation scope that produced this span.
    instrumentation-scope: instrumentation-scope,
    /// Number of attributes dropped by the span due to limits being reached.
    dropped-attributes: u32,
    /// Number of events dropped by the span due to limits being reached.
    dropped-events: u32,
    /// Number of links dropped by the span due to limits being reached.
    dropped-links: u32,
  }

  /// Called when a span is started.
  on-start: func(context: span-context);

  /// Called when a span is ended.
  on-end: func(span: span-data);

  /// Returns the span context of the host.
  outer-span-context: func() -> span-context;
}