PropertyDamage.Telemetry.Collector (PropertyDamage v0.2.0)
View SourceCollects and aggregates telemetry events for the dashboard.
The Collector is a GenServer that:
- Attaches to PropertyDamage telemetry events
- Aggregates metrics (counts, timings, pass/fail rates)
- Maintains a sliding window of recent events
- Broadcasts updates to subscribers (LiveView processes)
Usage
# Start the collector (typically in your application supervisor)
{:ok, pid} = PropertyDamage.Telemetry.Collector.start_link()
# Subscribe to updates (from a LiveView)
PropertyDamage.Telemetry.Collector.subscribe()
# Get current state
state = PropertyDamage.Telemetry.Collector.get_state()State Structure
The collector maintains:
runs- Total runs startedruns_completed- Successful runsruns_failed- Failed runscommands_executed- Total commands executedchecks_passed- Total checks passedchecks_failed- Total checks failedcurrent_run- Current run info (if running)recent_events- Last N events (sliding window)command_stats- Per-command timing statscheck_stats- Per-check pass/fail stats
Summary
Functions
Returns a specification to start this module under a supervisor.
Get the current aggregated state.
Get the PubSub topic for broadcasts.
Reset all collected metrics.
Start the collector.
Subscribe to telemetry updates.
Unsubscribe from telemetry updates.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_state(GenServer.server()) :: map()
Get the current aggregated state.
@spec pubsub_topic() :: String.t()
Get the PubSub topic for broadcasts.
@spec reset(GenServer.server()) :: :ok
Reset all collected metrics.
@spec start_link(keyword()) :: GenServer.on_start()
Start the collector.
@spec subscribe(GenServer.server()) :: :ok
Subscribe to telemetry updates.
The calling process will receive messages of the form:
{:telemetry_update, event_type, data}
@spec unsubscribe(GenServer.server()) :: :ok
Unsubscribe from telemetry updates.