monitor

package
v0.47.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package monitor provides a real-time web dashboard for a DDS participant. It embeds a single-page HTML UI (Server-Sent Events) and exposes an HTTP server that streams DDS samples and participant metrics to any browser.

Usage:

p, _ := rtps.New(dds.Domain(0))
mon, _ := monitor.New(p, monitor.Options{Addr: ":8080"})
defer mon.Close()
// browse http://localhost:8080

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor wraps a dds.Participant and serves a real-time web dashboard.

func New

func New(p dds.Participant, opts Options) (*Monitor, error)

New creates a Monitor wrapping p and starts the HTTP server. The caller must call Close() to release the HTTP listener.

func (*Monitor) Addr

func (m *Monitor) Addr() string

Addr returns the address the HTTP server is listening on (useful when Addr was ":0" to let the OS pick a port).

func (*Monitor) Close

func (m *Monitor) Close() error

Close stops the HTTP server and all background goroutines.

func (*Monitor) Publish

func (m *Monitor) Publish(s dds.Sample)

Publish emits a sample event to all connected browser clients. Call this whenever a sample is written or received that should appear in the dashboard.

func (*Monitor) PublishSafetyEvent added in v0.12.1

func (m *Monitor) PublishSafetyEvent(e safety.SafetyEvent)

PublishSafetyEvent broadcasts a safety violation event to all connected SSE clients.

func (*Monitor) RegisterSafetyMetrics added in v0.13.0

func (m *Monitor) RegisterSafetyMetrics(p safety.SafetyMetricsProvider)

RegisterSafetyMetrics adds p to the set of safety metrics providers whose snapshots are periodically broadcast as "safety_metrics" SSE events. May be called after New returns.

func (*Monitor) RegisterTSNHealth added in v0.13.0

func (m *Monitor) RegisterTSNHealth(name string, ht *tsn.HealthTracker)

RegisterTSNHealth registers a HealthTracker under name. Its health snapshot is periodically broadcast as a "tsn_health" SSE event and served at /api/tsn. May be called after New returns.

func (*Monitor) WatchSafety added in v0.12.1

func (m *Monitor) WatchSafety(events <-chan safety.SafetyEvent)

WatchSafety starts a goroutine that reads from events and calls PublishSafetyEvent for each one. It stops when the monitor is closed or the channel is closed. Intended to be wired to E2ESubscriber.SafetyEvents().

type Options

type Options struct {
	// Addr is the TCP listen address. Default: ":8080".
	Addr string
	// MetricsInterval controls how often metrics snapshots are pushed to the
	// browser. Default: 2s.
	MetricsInterval time.Duration
}

Options configures the monitor HTTP server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL