imports.md

September 19, 2024 ยท View on GitHub

World imports

Import interface wasi:logging/logging

WASI Logging is a logging API intended to let users emit log messages with simple priority levels and context values.


Types

enum level

A log level, describing a kind of message.

Enum Cases
  • trace

    Describes messages about the values of variables and the flow of control within a program.

  • debug

    Describes messages likely to be of interest to someone debugging a program.

  • info

    Describes messages likely to be of interest to someone monitoring a program.

  • warn

    Describes messages indicating hazardous situations.

  • error

    Describes messages indicating serious errors.

  • critical

    Describes messages indicating fatal errors.


Functions

log: func

Emit a log message.

A log message has a level describing what kind of message is being sent, a context, which is an uninterpreted string meant to help consumers group similar messages, and a string containing the message text.

Params

Import interface wasi:clocks/wall-clock@0.2.1

WASI Wall Clock is a clock API intended to let users query the current time. The name "wall" makes an analogy to a "clock on the wall", which is not necessarily monotonic as it may be reset.

It is intended to be portable at least between Unix-family platforms and Windows.

A wall clock is a clock which measures the date and time according to some external reference.

External references may be reset, so this clock is not necessarily monotonic, making it unsuitable for measuring elapsed time.

It is intended for reporting the current date and time for humans.


Types

record datetime

A time and date in seconds plus nanoseconds.

Record Fields
  • seconds: u64
  • nanoseconds: u32

Functions

now: func

Read the current value of the clock.

This clock is not monotonic, therefore calling this function repeatedly will not necessarily produce a sequence of non-decreasing values.

The returned timestamps represent the number of seconds since 1970-01-01T00:00:00Z, also known as POSIX's Seconds Since the Epoch, also known as Unix Time.

The nanoseconds field of the output is always less than 1000000000.

Return values

resolution: func

Query the resolution of the clock.

The nanoseconds field of the output is always less than 1000000000.

Return values

Import interface wasi:observe/tracer


Types

type datetime

datetime

#### `resource span`

Represents a unit of work or operation.

enum span-kind

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

Enum Cases
  • 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.

variant status

The status of a span.

Variant Cases
  • 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.

type key

string

The key part of attribute `key-value` pairs.

variant value

The value part of attribute key-value pairs.

Variant Cases
  • string: string

    A string value.

  • bool: bool

    A boolean value.

  • float64: f64

    A double precision floating point value.

  • s64: s64

    A signed 64 bit integer value.

  • string-array: list<string>

    A homogeneous array of string values.

  • bool-array: list<bool>

    A homogeneous array of boolean values.

  • float64-array: list<f64>

    A homogeneous array of double precision floating point values.

  • s64-array: list<s64>

    A homogeneous array of 64 bit integer values.

record key-value

A key-value pair describing an attribute.

Record Fields

type trace-id

string

The trace that this `span-context` belongs to.

16 bytes encoded as a hexadecimal string.

type span-id

string

The id of this `span-context`.

8 bytes encoded as a hexadecimal string.

flags trace-flags

Flags that can be set on a span-context.

Flags members
  • sampled:

    Whether the `span` should be sampled or not.

type trace-state

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.

record span-context

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

Record Fields

record link

Describes a relationship to another span.

Record Fields

record start-options

Configuration for starting a span.

Record Fields
  • new-root: bool

    Whether this span should act as the root of a new trace.

  • span-kind: option<span-kind>

    `span-kind` for the new `span`.

  • attributes: option<list<key-value>>

    Attributes for the new `span`.

  • links: option<list<link>>

    `link`'s for the new `span`.

  • timestamp: option<datetime>

    When the `span` should begin. If this is not provided it defaults to the current time.


Functions

start: func

Starts a new span with the given name and options.

Params
Return values

[method]span.span-context: func

Get the span-context for this span.

Params
  • self: borrow<span>
Return values

[method]span.is-recording: func

Returns true when the data provided to this span is captured in some form. If it returns false then any data provided is discarded.

Params
  • self: borrow<span>
Return values
  • bool

[method]span.set-attributes: func

Set attributes of this span.

If a key already exists for an attribute of the Span it will be overwritten with the corresponding new value.

Params

[method]span.add-event: func

Adds an event with the provided name at the curent timestamp.

Optionally an alternative timestamp may be provided. You may also provide attributes of this event.

Params

[method]span.add-link: func

Associates this span with another.

Params

[method]span.set-status: func

Override the default span status, which is unset.

Params

[method]span.update-name: func

Updates the span name.

Params
  • self: borrow<span>
  • name: string

[method]span.end: func

Signals that the operation described by this span has now ended.

If a timestamp is not provided then it is treated equivalent to passing the current time. Dropping this resource is the equivalent of calling end(none).

Params