llm_wire/telemetry

Describes the Sinal events that every executed LLM call emits.

Each execution of a prepared call emits [llm_wire, observation] at fixed stages. Its Metadata names the call, the caller’s correlation, the stage, the provider and a low-cardinality outcome. It never carries request or response content, or credentials.

import llm_wire/telemetry
import sinal

sinal.observe(telemetry.event(), fn(_, meta) {
  log(meta.call, telemetry.stage_name(meta.stage), meta.provider)
})

call is minted for every execution, so the events of one run or stream share it and a retry gets a new one. correlation is the correlation of the http_gun.Client view the call ran on, the value HTTP Gun also carries for the HTTP request under the same key, so both packages’ events join.

Types

Read fields by label; it may gain fields.

pub type Metadata {
  Metadata(
    call: String,
    correlation: option.Option(correlation.Correlation),
    stage: Stage,
    provider: String,
    outcome: Outcome,
  )
}

Constructors

What happened at the stage.

pub type Outcome {
  Accepted
  ResponseStarted
  Received
  Answered
  ToolsRequested
  Refused
  OutputLimited
  Failed
  CallCancelled
  ConsumerClosed
  WholeCallExpired
  FirstTokenExpired
  IdleGapExpired
  TransportClosed
}

Constructors

  • Accepted
  • ResponseStarted
  • Received
  • Answered
  • ToolsRequested
  • Refused
  • OutputLimited
  • Failed
  • CallCancelled
  • ConsumerClosed
  • WholeCallExpired
  • FirstTokenExpired
  • IdleGapExpired
  • TransportClosed

The point in a call’s life an event marks.

pub type Stage {
  Started
  RequestSent
  FirstProgress
  Terminal
  Cancelled
  Deadline
  Cleanup
}

Constructors

  • Started

    Execution began.

  • RequestSent

    The provider’s response head arrived.

  • FirstProgress

    The first progress event arrived.

  • Terminal

    The call reached its final outcome.

  • Cancelled

    The caller closed the stream before the end.

  • Deadline

    A timer expired.

  • Cleanup

    The HTTP stream was released.

Values

pub fn event() -> sinal.Event(Nil, Metadata)

The [llm_wire, observation] event.

pub fn outcome_name(outcome: Outcome) -> String

A stable snake_case name, such as "completed_tools".

pub fn stage_name(stage: Stage) -> String

A stable snake_case name, such as "first_progress".

✨ Search Document