mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-27 18:56:30 +00:00
Log stats-own generated events
This commit is contained in:
48
src/stats.rs
48
src/stats.rs
@@ -305,6 +305,24 @@ impl Collector {
|
|||||||
Collector { rx, tx }
|
Collector { rx, tx }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn send(tx: &Sender<Event>, event: Event) {
|
||||||
|
let name = event.name;
|
||||||
|
let result = tx.try_send(event);
|
||||||
|
|
||||||
|
match result {
|
||||||
|
Ok(_) => trace!(
|
||||||
|
"{:?} event reported successfully, capacity: {}",
|
||||||
|
name,
|
||||||
|
tx.capacity()
|
||||||
|
),
|
||||||
|
|
||||||
|
Err(err) => match err {
|
||||||
|
TrySendError::Full { .. } => error!("{:?} event dropped, buffer full", name),
|
||||||
|
TrySendError::Closed { .. } => error!("{:?} event dropped, channel closed", name),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// The statistics collection handler. It will collect statistics
|
/// The statistics collection handler. It will collect statistics
|
||||||
/// for `address_id`s starting at 0 up to `addresses`.
|
/// for `address_id`s starting at 0 up to `addresses`.
|
||||||
pub async fn collect(&mut self) {
|
pub async fn collect(&mut self) {
|
||||||
@@ -354,12 +372,15 @@ impl Collector {
|
|||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
let address_count = get_number_of_addresses();
|
let address_count = get_number_of_addresses();
|
||||||
for address_id in 0..address_count {
|
for address_id in 0..address_count {
|
||||||
let _ = tx.try_send(Event {
|
Self::send(
|
||||||
name: EventName::UpdateStats,
|
&tx,
|
||||||
value: 0,
|
Event {
|
||||||
process_id: -1,
|
name: EventName::UpdateStats,
|
||||||
address_id: address_id,
|
value: 0,
|
||||||
});
|
process_id: -1,
|
||||||
|
address_id: address_id,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -372,12 +393,15 @@ impl Collector {
|
|||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
let address_count = get_number_of_addresses();
|
let address_count = get_number_of_addresses();
|
||||||
for address_id in 0..address_count {
|
for address_id in 0..address_count {
|
||||||
let _ = tx.try_send(Event {
|
Self::send(
|
||||||
name: EventName::UpdateAverages,
|
&tx,
|
||||||
value: 0,
|
Event {
|
||||||
process_id: -1,
|
name: EventName::UpdateAverages,
|
||||||
address_id: address_id,
|
value: 0,
|
||||||
});
|
process_id: -1,
|
||||||
|
address_id: address_id,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user