Bloccs.Web.Telemetry.Collector (bloccs_web v0.1.0)

Copy Markdown View Source

The single sink for bloccs telemetry. Attaches Bloccs.Web.Telemetry.Handler to the [:bloccs, …] stream and folds it into two per-network views:

On a 1-second tick it broadcasts a snapshot of each over Phoenix.PubSub (topic/1 for metrics, flow_topic/1 for flow). Panels subscribe for live updates and call snapshot/1 / flow_snapshot/1 on mount for first paint.

A plain GenServer is the right tool here: this is a stateful telemetry sink with a periodic tick, not a dataflow stage. The "no raw GenServers" rule governs the bloccs library core (where Broadway/GenStage apply), not this observability process.

Summary

Functions

Returns a specification to start this module under a supervisor.

First-paint flow snapshot for a network.

PubSub topic carrying a network's flow frames.

Cast a normalized metrics event in (called by the telemetry handler).

Cast a flow event in (called by the telemetry handler).

First-paint metrics snapshot for a network (empty frame if unseen).

PubSub topic carrying a network's metric frames.

Types

frame()

@type frame() :: %{nodes: map(), updated_at: integer() | nil}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

flow_snapshot(network)

@spec flow_snapshot(atom()) :: %{
  events: list(),
  series: list(),
  rate: non_neg_integer()
}

First-paint flow snapshot for a network.

flow_topic(network)

@spec flow_topic(atom()) :: String.t()

PubSub topic carrying a network's flow frames.

record(collector, network, event)

@spec record(pid() | atom(), atom(), Bloccs.Web.Telemetry.Metrics.event()) :: :ok

Cast a normalized metrics event in (called by the telemetry handler).

record_flow(collector, network, event)

@spec record_flow(pid() | atom(), atom(), Bloccs.Web.Telemetry.Flow.event()) :: :ok

Cast a flow event in (called by the telemetry handler).

snapshot(network)

@spec snapshot(atom()) :: frame()

First-paint metrics snapshot for a network (empty frame if unseen).

start_link(opts)

topic(network)

@spec topic(atom()) :: String.t()

PubSub topic carrying a network's metric frames.