Metrics port: op-key -> latency/frequency aggregation for hive internals.
Op key: a vector [area op] or [area op sub]; each element a keyword or a short string from a closed vocabulary (tool name, verb, addon id, backend, method). Never ids, paths, queries or user text.
Callers bind this namespace late (requiring-resolve) and fall back to a
no-op when it is absent. record! and timed never throw because of the
sink: a sink failure is swallowed and counted in sink-error-count.
Metrics port: op-key -> latency/frequency aggregation for hive internals. Op key: a vector [area op] or [area op sub]; each element a keyword or a short string from a closed vocabulary (tool name, verb, addon id, backend, method). Never ids, paths, queries or user text. Callers bind this namespace late (requiring-resolve) and fall back to a no-op when it is absent. `record!` and `timed` never throw because of the sink: a sink failure is swallowed and counted in `sink-error-count`.
Number of log2 histogram buckets per op key.
Number of log2 histogram buckets per op key.
(bucket-index ns)Histogram bucket for elapsed-ns: 0 for ns <= 0, else floor(log2 ns)+1, capped at 63. Bucket i holds values in [2^(i-1), 2^i).
Histogram bucket for elapsed-ns: 0 for ns <= 0, else floor(log2 ns)+1, capped at 63. Bucket i holds values in [2^(i-1), 2^i).
(bucket-upper i)Inclusive upper bound (ns) of bucket i.
Inclusive upper bound (ns) of bucket i.
(composite-sink & sinks)Fan-out sink: observe! reaches every child (a throwing child is swallowed and counted, the others still record). snapshot merges the children's snapshots, later children winning on equal keys.
Fan-out sink: observe! reaches every child (a throwing child is swallowed and counted, the others still record). snapshot merges the children's snapshots, later children winning on equal keys.
(current-sink)The installed sink, or noop-sink when none is installed.
The installed sink, or `noop-sink` when none is installed.
(hotspots snap)(hotspots snap {:keys [by limit area] :or {by :total limit 20}})PURE. Rank the rows of snapshot snap. opts: :by one of #{:total :count :mean :p99 :max :errors} (default :total) :limit max rows (default 20; nil or <= 0 keeps all) :area keep only keys whose first element equals area (keyword, or string spelling such as "mcp/tool"). Returns a vector of {:k :count :errors :total-ms :mean-ms :p50-ms :p95-ms :p99-ms :max-ms :share}; :share = row total time / total time of every row kept by :area (before :limit).
PURE. Rank the rows of snapshot snap.
opts: :by one of #{:total :count :mean :p99 :max :errors} (default :total)
:limit max rows (default 20; nil or <= 0 keeps all)
:area keep only keys whose first element equals area (keyword, or
string spelling such as "mcp/tool").
Returns a vector of {:k :count :errors :total-ms :mean-ms :p50-ms :p95-ms
:p99-ms :max-ms :share}; :share = row total time / total time of every row
kept by :area (before :limit).(observe! sink k elapsed-ns outcome)Record one observation. k = op key. elapsed-ns = long. outcome = :ok | :error.
Record one observation. k = op key. elapsed-ns = long. outcome = :ok | :error.
(snapshot sink)Immutable value: {k {:count n :errors n :total-ns n :max-ns n :p50-ns n :p95-ns n :p99-ns n}}
Immutable value: {k {:count n :errors n :total-ns n :max-ns n :p50-ns n :p95-ns n :p99-ns n}}
(install! sink)Set the process-global sink (nil uninstalls). Returns sink.
Set the process-global sink (nil uninstalls). Returns sink.
(-reset! sink)Clear every aggregate held by sink.
Clear every aggregate held by sink.
Sink that records nothing; snapshot is {}.
Sink that records nothing; snapshot is {}.
(record! k elapsed-ns outcome)observe! on the current sink. Never throws; a sink exception is counted in
sink-error-count. Returns nil.
observe! on the current sink. Never throws; a sink exception is counted in `sink-error-count`. Returns nil.
(reset-sink! sink)Clear the aggregates of sink (a stats-sink, or a composite holding one). Sinks without state are left alone. Returns nil.
Clear the aggregates of sink (a stats-sink, or a composite holding one). Sinks without state are left alone. Returns nil.
(sink-error-count)Number of sink exceptions swallowed by record! and composite-sink.
Number of sink exceptions swallowed by `record!` and `composite-sink`.
(stats-sink)Lock-free in-process aggregator: ConcurrentHashMap k -> cell of LongAdders plus a 64-bucket log2 histogram (AtomicLongArray). Percentiles are the upper bound of the bucket holding the rank, clamped to :max-ns.
Lock-free in-process aggregator: ConcurrentHashMap k -> cell of LongAdders plus a 64-bucket log2 histogram (AtomicLongArray). Percentiles are the upper bound of the bucket holding the rank, clamped to :max-ns.
(timed k & body)Evaluate body, recording [k elapsed-ns outcome] through record!.
outcome is :error when body throws (the throwable is rethrown), else :ok.
Returns body's value. k is evaluated once, before body.
Evaluate body, recording [k elapsed-ns outcome] through `record!`. outcome is :error when body throws (the throwable is rethrown), else :ok. Returns body's value. k is evaluated once, before body.
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 |