Pluggable observation hook for the two Datastar entry points
(/ds/nds and /ds/nds-connect). datastar stays metrics-agnostic: it
reports plain maps to ONE observer fn installed at startup
(taia.ds.datastar.interface/set-observer!), and does nothing at all when none is set.
Observations:
No component-id is ever reported — every instance of a component is one
series. And the reported values are BOUNDED: component and event come
from the URL, so anyone could mint new ones. A component counts only once
discovery has resolved it (the discovery cache holds it), an event only
when that component's machine declares it; everything else collapses to
unknown-component / other-event.
Pluggable observation hook for the two Datastar entry points
(/ds/nds and /ds/nds-connect). `datastar` stays metrics-agnostic: it
reports plain maps to ONE observer fn installed at startup
(`taia.ds.datastar.interface/set-observer!`), and does nothing at all when none is set.
Observations:
- {:type :event :route :nds|:nds-connect|:nds-connect-event :component c :event e
:outcome :ok|:error :seconds s}
- {:type :sse-opened :component c}
- {:type :sse-closed :component c :seconds lifetime}
No component-id is ever reported — every instance of a component is one
series. And the reported values are BOUNDED: component and event come
from the URL, so anyone could mint new ones. A component counts only once
discovery has resolved it (the discovery cache holds it), an event only
when that component's machine declares it; everything else collapses to
`unknown-component` / `other-event`.(connection-closed! token)Reports the close of a stream connection-opened! returned token for.
nil token ⇒ no-op.
Reports the close of a stream `connection-opened!` returned `token` for. nil token ⇒ no-op.
(connection-opened! component-name started-nanos)Reports an opened SSE stream. Returns the token connection-closed!
needs (the label is fixed at open so the gauge's up and down always hit
the same series), or nil when no observer is set.
Reports an opened SSE stream. Returns the token `connection-closed!` needs (the label is fixed at open so the gauge's up and down always hit the same series), or nil when no observer is set.
(labels component-name controller-name event-name)Bounded {:component :event} label values for one component event.
Bounded {:component :event} label values for one component event.
(observe-event! route component-name controller-name event-name f)Calls (f) and returns its result. When an observer is set, reports the
call's duration as an :event observation: :error when f throws
(rethrown) or returns a Ring response with status >= 400, else :ok.
Labels are computed AFTER f, so the discovery f performed counts.
Calls `(f)` and returns its result. When an observer is set, reports the call's duration as an :event observation: :error when `f` throws (rethrown) or returns a Ring response with status >= 400, else :ok. Labels are computed AFTER `f`, so the discovery `f` performed counts.
(set-observer! f)Installs f (a 1-arg fn of an observation map) as the observer; nil
removes it. Returns nil.
Installs `f` (a 1-arg fn of an observation map) as the observer; nil removes it. Returns nil.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |