Pure-Clojure Prometheus metrics adapter.
An in-memory metric registry that renders the Prometheus text exposition
format (https://prometheus.io/docs/instrumenting/exposition_formats/).
It implements all four metrics protocols
(IMetricsRegistry, IMetricsEmitter, IMetricsExporter, IMetricsConfig)
in a single component backed by one Clojure atom, so it is safe for
concurrent use via swap!.
No external Prometheus client dependency is used — the exposition text is produced by this namespace directly.
Sanitization + collisions (BOU-207): metric/label names are sanitized to valid Prometheus identifiers. Post-sanitization COLLISIONS are handled so the output stays valid:
# TYPE line).Each metric value is keyed by (metric-name, label-set), where the label-set is the merge of the registry default tags, the metric's registration tags, and any per-call tags. Distinct label-sets are therefore distinct series.
_sum/_count pair is emitted (see note below)._sum and
_count, which is a valid (if minimal) Prometheus summary exposition.Pure-Clojure Prometheus metrics adapter.
An in-memory metric registry that renders the Prometheus text exposition
format (https://prometheus.io/docs/instrumenting/exposition_formats/).
It implements all four metrics protocols
(IMetricsRegistry, IMetricsEmitter, IMetricsExporter, IMetricsConfig)
in a single component backed by one Clojure atom, so it is safe for
concurrent use via `swap!`.
No external Prometheus client dependency is used — the exposition text is
produced by this namespace directly.
Sanitization + collisions (BOU-207): metric/label names are sanitized to valid
Prometheus identifiers. Post-sanitization COLLISIONS are handled so the output
stays valid:
- Metric names: if a later registration sanitizes to the same name as an
already-registered different key (e.g. :http.requests then :http-requests,
both -> http_requests), the later one is logged and IGNORED — the first
registration wins (no duplicate `# TYPE` line).
- Label keys within a series: keys that sanitize to the same label name are
de-duplicated deterministically at render (the lexicographically-first
[name value] pair wins), so no duplicate label appears in a series.
Series identity
---------------
Each metric value is keyed by (metric-name, label-set), where the label-set
is the merge of the registry default tags, the metric's registration tags,
and any per-call tags. Distinct label-sets are therefore distinct series.
Metric storage
--------------
- counter : {label-set -> numeric total}
- gauge : {label-set -> numeric value (last write wins)}
- histogram: {label-set -> {:counts {bucket -> n} :inf n :sum s :count c}}
(per-bucket non-cumulative counts; cumulative counts are computed
at export time)
- summary : {label-set -> {:sum s :count c}} — quantiles are NOT tracked;
only the `_sum`/`_count` pair is emitted (see note below).
Simplifications
---------------
- Summary quantiles are not computed. A summary emits only `_sum` and
`_count`, which is a valid (if minimal) Prometheus summary exposition.
- Metric names are emitted as-is (assumed already valid Prometheus names).(create-metrics-component)(create-metrics-component config)Create a Prometheus metrics component implementing all four metrics protocols, backed by a single atom.
Args: config - Prometheus provider config map (see wagoe.observability.metrics.schema/PrometheusMetricsConfig). Recognised keys: :histogram-buckets, :include-help-text, :registry-name, and :tagging {:default-tags {...}}.
Returns: Component implementing IMetricsRegistry, IMetricsEmitter, IMetricsExporter, and IMetricsConfig.
Create a Prometheus metrics component implementing all four metrics
protocols, backed by a single atom.
Args:
config - Prometheus provider config map (see
wagoe.observability.metrics.schema/PrometheusMetricsConfig).
Recognised keys: :histogram-buckets, :include-help-text,
:registry-name, and :tagging {:default-tags {...}}.
Returns:
Component implementing IMetricsRegistry, IMetricsEmitter,
IMetricsExporter, and IMetricsConfig.(create-metrics-components)(create-metrics-components config)Create a complete set of Prometheus metrics components that all share a single underlying component/atom, so registration, emission, export, and config operate on the same state.
Returns: {:registry IMetricsRegistry :emitter IMetricsEmitter :exporter IMetricsExporter :config IMetricsConfig}
Create a complete set of Prometheus metrics components that all share a
single underlying component/atom, so registration, emission, export, and
config operate on the same state.
Returns:
{:registry IMetricsRegistry
:emitter IMetricsEmitter
:exporter IMetricsExporter
:config IMetricsConfig}(create-metrics-config)(create-metrics-config config)Create a Prometheus metrics config (a full component; all protocols share
one atom). See create-metrics-component.
Create a Prometheus metrics config (a full component; all protocols share one atom). See `create-metrics-component`.
(create-metrics-emitter)(create-metrics-emitter config)Create a Prometheus metrics emitter (a full component; all protocols share
one atom). See create-metrics-component.
Create a Prometheus metrics emitter (a full component; all protocols share one atom). See `create-metrics-component`.
(create-metrics-exporter)(create-metrics-exporter config)Create a Prometheus metrics exporter (a full component; all protocols share
one atom). See create-metrics-component.
Create a Prometheus metrics exporter (a full component; all protocols share one atom). See `create-metrics-component`.
(create-metrics-registry)(create-metrics-registry config)Create a Prometheus metrics registry (a full component; all protocols share
one atom). See create-metrics-component.
Create a Prometheus metrics registry (a full component; all protocols share one atom). See `create-metrics-component`.
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 |