|
5 | 5 | import os |
6 | 6 | import ssl |
7 | 7 |
|
| 8 | +from prometheus_client import Counter, Gauge |
| 9 | + |
8 | 10 | from .entrypoints import run_as_node, run_as_controller, run_as_ping, run_as_send |
9 | 11 | from .exceptions import ReceptorRuntimeError, ReceptorConfigError |
10 | 12 |
|
|
30 | 32 | }, |
31 | 33 | } |
32 | 34 |
|
| 35 | +messages_received_counter = Counter("incoming_messages", "Messages received from Receptor Peers") |
| 36 | +connected_peers_guage = Gauge("connected_peers", "Number of active peer connections") |
| 37 | +work_counter = Counter("work_events", "A count of the number of work events that have been received") |
| 38 | +active_work_gauge = Gauge("active_work", "Amount of work currently being performed") |
| 39 | +route_counter = Counter("route_events", "A count of the number of messages that have been routed elsewhere in the mesh") |
| 40 | + |
33 | 41 |
|
34 | 42 | def py_class(class_spec): |
35 | 43 | if class_spec not in SINGLETONS: |
@@ -137,6 +145,21 @@ def __init__(self, args=None): |
137 | 145 | value_type='bool', |
138 | 146 | hint='Disable the server function and only connect to configured peers', |
139 | 147 | ) |
| 148 | + self.add_config_option( |
| 149 | + section='node', |
| 150 | + key='stats_enable', |
| 151 | + default_value=None, |
| 152 | + set_value=True, |
| 153 | + value_type='bool', |
| 154 | + hint="Enable Prometheus style stats port", |
| 155 | + ) |
| 156 | + self.add_config_option( |
| 157 | + section='node', |
| 158 | + key='stats_port', |
| 159 | + default_value=8889, |
| 160 | + value_type='int', |
| 161 | + hint='Port to listen for requests to show stats', |
| 162 | + ) |
140 | 163 | self.add_config_option( |
141 | 164 | section='node', |
142 | 165 | key='ping_interval', |
@@ -192,6 +215,21 @@ def __init__(self, args=None): |
192 | 215 | value_type='path', |
193 | 216 | hint='Path to control socket for controller commands.', |
194 | 217 | ) |
| 218 | + self.add_config_option( |
| 219 | + section='controller', |
| 220 | + key='stats_enable', |
| 221 | + default_value=None, |
| 222 | + set_value=True, |
| 223 | + value_type='bool', |
| 224 | + hint="Enable Prometheus style stats port", |
| 225 | + ) |
| 226 | + self.add_config_option( |
| 227 | + section='controller', |
| 228 | + key='stats_port', |
| 229 | + default_value=8889, |
| 230 | + value_type='int', |
| 231 | + hint='Port to listen for requests to show stats', |
| 232 | + ) |
195 | 233 | self.add_config_option( |
196 | 234 | section='ping', |
197 | 235 | key='count', |
|
0 commit comments