WardrikCore.Event (wardrik_core v0.1.0-rc.1)

Copy Markdown

Something that happened to an agent.

Each event goes to two places:

  • :telemetry, for metrics and traces. Handlers run in the emitting process, and :telemetry detaches a handler that raises.
  • The agent's WardrikCore.Events sink, for clients that follow the agent, such as a CLI, a TUI or a web page.

An event has a telemetry name, such as [:wardrik_core, :turn, :stop], measurements and metadata. See WardrikCore.Telemetry for core's events. Packages emit their own the same way:

WardrikCore.Event.emit(context, [:my_package, :refused], %{}, %{call: call})

Summary

Functions

Emits an event to telemetry and to a sink.

Types

t()

@type t() :: %WardrikCore.Event{
  measurements: map(),
  metadata: map(),
  name: [atom()],
  time: DateTime.t()
}

Functions

emit(source, name, measurements \\ %{}, metadata)

@spec emit(
  WardrikCore.Context.t() | WardrikCore.Context.entry() | nil,
  [atom()],
  map(),
  map()
) :: :ok

Emits an event to telemetry and to a sink.

source is one of:

  • a WardrikCore.Context - emits to the agent's sink.
  • a sink, as module or {module, opts}.
  • nil - emits to telemetry only.