mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Decorate mpsc-notification-to-protocol with the protocol name (#3873)
Currently, all protocols use the same metric name for `mpsc-notification-to-protocol` this is bad because we can't actually tell which protocol might cause problems. This patch proposes we derive the name of the metric from the protocol name, so that we have separate metrics for each protocol and properly detect which one is having problem processing its messages. --------- Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
This commit is contained in:
committed by
GitHub
parent
b310b575cd
commit
5638d1a830
@@ -338,7 +338,8 @@ impl NotificationService for NotificationHandle {
|
||||
// Clone [`NotificationService`]
|
||||
fn clone(&mut self) -> Result<Box<dyn NotificationService>, ()> {
|
||||
let mut subscribers = self.subscribers.lock();
|
||||
let (event_tx, event_rx) = tracing_unbounded("mpsc-notification-to-protocol", 100_000);
|
||||
|
||||
let (event_tx, event_rx) = tracing_unbounded(self.rx.name(), 100_000);
|
||||
subscribers.push(event_tx);
|
||||
|
||||
Ok(Box::new(NotificationHandle {
|
||||
@@ -624,7 +625,9 @@ pub fn notification_service(
|
||||
protocol: ProtocolName,
|
||||
) -> (ProtocolHandlePair, Box<dyn NotificationService>) {
|
||||
let (cmd_tx, cmd_rx) = mpsc::channel(COMMAND_QUEUE_SIZE);
|
||||
let (event_tx, event_rx) = tracing_unbounded("mpsc-notification-to-protocol", 100_000);
|
||||
|
||||
let (event_tx, event_rx) =
|
||||
tracing_unbounded(metric_label_for_protocol(&protocol).leak(), 100_000);
|
||||
let subscribers = Arc::new(Mutex::new(vec![event_tx]));
|
||||
|
||||
(
|
||||
@@ -632,3 +635,14 @@ pub fn notification_service(
|
||||
Box::new(NotificationHandle::new(protocol.clone(), cmd_tx, event_rx, subscribers)),
|
||||
)
|
||||
}
|
||||
|
||||
// Decorates the mpsc-notification-to-protocol metric with the name of the protocol,
|
||||
// to be able to distiguish between different protocols in dashboards.
|
||||
fn metric_label_for_protocol(protocol: &ProtocolName) -> String {
|
||||
let protocol_name = protocol.to_string();
|
||||
let keys = protocol_name.split("/").collect::<Vec<_>>();
|
||||
keys.iter()
|
||||
.rev()
|
||||
.take(2) // Last two tokens give the protocol name and version
|
||||
.fold("mpsc-notification-to-protocol".into(), |acc, val| format!("{}-{}", acc, val))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user