Add compose-metrics.ds (Layer 1): receives counter+clock+stats, derives uptime/events/status, re-streams on /peer/metrics. This app is BOTH a receiver and a source. Add compose-master.ds (Layer 2): receives chained metrics from Layer 1 + mood direct from Layer 0. Demonstrates multi-layer signal composition with independent stream mixing. Verified: Uptime: 51s, Total Events: 9 flowing through the full three-layer chain to the master dashboard.
39 lines
1.3 KiB
Text
39 lines
1.3 KiB
Text
-- DreamStack Chained Composition — Layer 1: Metrics Aggregator
|
|
-- Receives 3 signal streams, derives combined metrics, re-streams them.
|
|
--
|
|
-- Architecture:
|
|
-- Counter ──┐
|
|
-- Clock ───┤──► THIS APP ──► /peer/metrics
|
|
-- Stats ───┘
|
|
--
|
|
-- This app is BOTH a receiver AND a source:
|
|
-- - Receives: counter.count, counter.doubled, clock.seconds, stats.total, stats.max
|
|
-- - Derives: uptime (from clock), events (from stats+counter), status (combined)
|
|
-- - Streams: uptime, events, status on /peer/metrics
|
|
--
|
|
-- Run with:
|
|
-- dreamstack stream examples/compose-metrics.ds --port 3006
|
|
|
|
let counter = stream from "ws://localhost:9100/stream/counter"
|
|
let clock = stream from "ws://localhost:9100/stream/clock"
|
|
let stats = stream from "ws://localhost:9100/stream/stats"
|
|
|
|
-- Derived metrics from upstream streams
|
|
let uptime = clock.seconds
|
|
let events = counter.count + stats.total
|
|
let status = "nominal"
|
|
|
|
-- Re-stream derived metrics downstream
|
|
stream metrics on "ws://localhost:9100/peer/metrics" {
|
|
mode: signal,
|
|
output: uptime, events, status
|
|
}
|
|
|
|
view metrics =
|
|
column [
|
|
text "⚡ Metrics Aggregator (Layer 1)"
|
|
text "Receives: counter + clock + stats"
|
|
text "Uptime: {uptime}s"
|
|
text "Total Events: {events}"
|
|
text "Status: {status}"
|
|
]
|