conduit 0.6.0
Modern C++23 header-only event-dispatching / event-transport library
Loading...
Searching...
No Matches
metrics.hpp
Go to the documentation of this file.
1#pragma once
2
28
29#include <prom/prom.hpp>
30
31#include <memory>
32
34
36inline std::shared_ptr<prom::Scope>& scope() {
37 static std::shared_ptr<prom::Scope> sc =
38 prom::scope("conduit",
39 prom::ScopeConfig{.prefix = "conduit_",
40 .display = comms::DisplayInfo{
41 .name = "conduit",
42 .description = "conduit event-bus metrics.",
43 }});
44 return sc;
45}
46
48inline prom::Counter& events_published() {
49 static prom::Counter m =
50 scope()->counter({.name = "events_published_total",
51 .help = "Envelopes that entered the dispatch pipeline."});
52 return m;
53}
54
57inline prom::Counter& events_dropped() {
58 static prom::Counter m = scope()->counter(
59 {.name = "events_dropped_total",
60 .help = "Envelopes dropped before dispatch (middleware veto or routing conflict)."});
61 return m;
62}
63
66inline prom::Counter& listener_invocations() {
67 static prom::Counter m =
68 scope()->counter({.name = "listener_invocations_total",
69 .help = "Listener handler calls during fan-out (per matched listener)."});
70 return m;
71}
72
74inline prom::Counter& listener_errors() {
75 static prom::Counter m = scope()->counter(
76 {.name = "listener_errors_total", .help = "Listener handlers that threw during fan-out."});
77 return m;
78}
79
82inline prom::Counter& transport_errors() {
83 static prom::Counter m = scope()->counter(
84 {.name = "transport_errors_total",
85 .help = "Transport-level inbound failures (e.g. an undecodable message)."});
86 return m;
87}
88
90inline prom::Gauge& listeners() {
91 static prom::Gauge m = scope()->gauge(
92 {.name = "listeners", .help = "Live listener subscriptions registered on a bus."});
93 return m;
94}
95
99inline prom::Histogram& dispatch_seconds() {
100 static prom::Histogram m = scope()->histogram(
101 {.name = "dispatch_seconds",
102 .help =
103 "Wall-clock seconds from publish to the end of the synchronous dispatch pipeline."});
104 return m;
105}
106
107} // namespace conduit::metrics
Definition metrics.hpp:33
prom::Counter & listener_invocations()
Listener handler calls during fan-out (counts every matched listener, summed over all delivered envel...
Definition metrics.hpp:66
std::shared_ptr< prom::Scope > & scope()
The shared conduit scope; applies the conduit_ prefix to every metric.
Definition metrics.hpp:36
prom::Counter & events_published()
Envelopes that entered the dispatch pipeline (one per Bus::publish).
Definition metrics.hpp:48
prom::Counter & transport_errors()
Transport-level inbound failures, selected by the transport label ("redis", "amqp",...
Definition metrics.hpp:82
prom::Counter & listener_errors()
Listener handlers that threw during fan-out.
Definition metrics.hpp:74
prom::Counter & events_dropped()
Envelopes dropped before listener fan-out (a middleware before_dispatch returned false,...
Definition metrics.hpp:57
prom::Gauge & listeners()
Live listener subscriptions across all buses in the process.
Definition metrics.hpp:90
prom::Histogram & dispatch_seconds()
Wall-clock seconds from publish to the end of the synchronous dispatch pipeline.
Definition metrics.hpp:99