Baton.Telemetry (Baton v0.1.0)

Copy Markdown View Source

Telemetry is Baton's primary integration surface. The PubSub events and LiveView dashboard are optional layers on top; everything observable is also emitted as telemetry, so you can integrate without Phoenix.

Events

[:baton, :step, <state>]

Emitted on every step transition. <state> is one of :executing, :completed, :retryable, :discarded, :cancelled, :snoozed.

Measurements: %{count: 1} Metadata: %{workflow_id, workflow_label, step_name, worker, state, job_id, attempt, has_result, error, timestamp}

[:baton, :workflow, :finished]

Emitted by Baton.Completion the moment a workflow's last outstanding step settles โ€” the prompt, per-workflow "done" signal that backs the {:workflow_finished, _} PubSub event.

Measurements: %{failed_count, total_count} Metadata: %{workflow_id, workflow_label, outcome, failed_steps, timestamp} where outcome is :completed or :failed.

[:baton, :workflow, :failed]

Emitted by Baton.Plugin on its sweep when a workflow fully terminates with at least one failed step. Unlike :finished, this is poll-based and only fires for failures โ€” useful as an alerting backstop.

Measurements: %{failed_count, total_count} Metadata: %{workflow_id, workflow_label}

[:baton, :plugin, :rescued]

Emitted when the plugin cancels orphaned jobs.

Measurements: %{count} ยท Metadata: %{job_ids}

[:baton, :plugin, :sweep, :start | :stop | :exception]

A :telemetry.span/3 around each plugin sweep.

Default logger

Attach a simple Logger-based handler (handy in dev):

Baton.Telemetry.attach_default_logger()

In production, attach your own handlers to route to Sentry, PagerDuty, etc.

Summary

Functions

Attach a Logger handler for failure and rescue events.

Detach the default logger.

Functions

attach_default_logger(level \\ :info)

Attach a Logger handler for failure and rescue events.

detach_default_logger()

Detach the default logger.