Live and historical metrics
This commit is contained in:
@@ -9,8 +9,8 @@ use super::MetricType;
|
||||
impl MetricType {
|
||||
pub fn name(&self) -> &'static str {
|
||||
match self {
|
||||
Self::MessageIngestionTime => "message.ingestion-time",
|
||||
Self::MessageFtsIndexTime => "message.fts-index-time",
|
||||
Self::MessageIngestionTime => "message-ingest.time",
|
||||
Self::MessageFtsIndexTime => "message-ingest.index-time",
|
||||
Self::DeliveryTotalTime => "delivery.total-time",
|
||||
Self::DeliveryTime => "delivery.attempt-time",
|
||||
Self::MessageSize => "message.size",
|
||||
@@ -34,6 +34,8 @@ impl MetricType {
|
||||
Self::DeliveryActiveConnections => "delivery.active-connections",
|
||||
Self::ServerMemory => "server.memory",
|
||||
Self::QueueCount => "queue.count",
|
||||
Self::UserCount => "user.count",
|
||||
Self::DomainCount => "domain.count",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +66,8 @@ impl MetricType {
|
||||
Self::DeliveryActiveConnections => "Active delivery connections",
|
||||
Self::ServerMemory => "Server memory usage",
|
||||
Self::QueueCount => "Total number of messages in the queue",
|
||||
Self::UserCount => "Total number of users",
|
||||
Self::DomainCount => "Total number of domains",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +98,8 @@ impl MetricType {
|
||||
| Self::SieveActiveConnections
|
||||
| Self::DeliveryActiveConnections => "connections",
|
||||
Self::QueueCount => "messages",
|
||||
Self::UserCount => "users",
|
||||
Self::DomainCount => "domains",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +130,8 @@ impl MetricType {
|
||||
Self::DeliveryActiveConnections => 22,
|
||||
Self::ServerMemory => 23,
|
||||
Self::QueueCount => 24,
|
||||
Self::UserCount => 25,
|
||||
Self::DomainCount => 26,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,14 +162,16 @@ impl MetricType {
|
||||
22 => Some(Self::DeliveryActiveConnections),
|
||||
23 => Some(Self::ServerMemory),
|
||||
24 => Some(Self::QueueCount),
|
||||
25 => Some(Self::UserCount),
|
||||
26 => Some(Self::DomainCount),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_parse(name: &str) -> Option<Self> {
|
||||
match name {
|
||||
"message.ingestion-time" => Some(Self::MessageIngestionTime),
|
||||
"message.fts-index-time" => Some(Self::MessageFtsIndexTime),
|
||||
"message-ingest.time" => Some(Self::MessageIngestionTime),
|
||||
"message-ingest.index-time" => Some(Self::MessageFtsIndexTime),
|
||||
"delivery.total-time" => Some(Self::DeliveryTotalTime),
|
||||
"delivery.attempt-time" => Some(Self::DeliveryTime),
|
||||
"message.size" => Some(Self::MessageSize),
|
||||
@@ -185,6 +195,8 @@ impl MetricType {
|
||||
"delivery.active-connections" => Some(Self::DeliveryActiveConnections),
|
||||
"server.memory" => Some(Self::ServerMemory),
|
||||
"queue.count" => Some(Self::QueueCount),
|
||||
"user.count" => Some(Self::UserCount),
|
||||
"domain.count" => Some(Self::DomainCount),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ static DNS_LOOKUP_TIME: AtomicHistogram<12> =
|
||||
|
||||
static SERVER_MEMORY: AtomicGauge = AtomicGauge::new(MetricType::ServerMemory);
|
||||
static QUEUE_COUNT: AtomicGauge = AtomicGauge::new(MetricType::QueueCount);
|
||||
static USER_COUNT: AtomicGauge = AtomicGauge::new(MetricType::UserCount);
|
||||
static DOMAIN_COUNT: AtomicGauge = AtomicGauge::new(MetricType::DomainCount);
|
||||
|
||||
const CONN_SMTP_IN: usize = 0;
|
||||
const CONN_SMTP_OUT: usize = 1;
|
||||
@@ -224,8 +226,9 @@ impl Collector {
|
||||
}
|
||||
|
||||
pub fn collect_gauges(is_enterprise: bool) -> impl Iterator<Item = &'static AtomicGauge> {
|
||||
static E_GAUGES: &[&AtomicGauge] = &[&SERVER_MEMORY, &QUEUE_COUNT];
|
||||
static C_GAUGES: &[&AtomicGauge] = &[&SERVER_MEMORY];
|
||||
static E_GAUGES: &[&AtomicGauge] =
|
||||
&[&SERVER_MEMORY, &QUEUE_COUNT, &USER_COUNT, &DOMAIN_COUNT];
|
||||
static C_GAUGES: &[&AtomicGauge] = &[&SERVER_MEMORY, &USER_COUNT, &DOMAIN_COUNT];
|
||||
|
||||
if is_enterprise { E_GAUGES } else { C_GAUGES }
|
||||
.iter()
|
||||
@@ -275,6 +278,23 @@ impl Collector {
|
||||
match metric_type {
|
||||
MetricType::ServerMemory => SERVER_MEMORY.set(value),
|
||||
MetricType::QueueCount => QUEUE_COUNT.set(value),
|
||||
MetricType::UserCount => USER_COUNT.set(value),
|
||||
MetricType::DomainCount => DOMAIN_COUNT.set(value),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_event_counter(event_type: EventType, value: u32) {
|
||||
EVENT_COUNTERS.add(event_type.into(), value);
|
||||
}
|
||||
|
||||
pub fn update_histogram(metric_type: MetricType, value: u64) {
|
||||
match metric_type {
|
||||
MetricType::MessageIngestionTime => MESSAGE_INGESTION_TIME.observe(value),
|
||||
MetricType::MessageFtsIndexTime => MESSAGE_INDEX_TIME.observe(value),
|
||||
MetricType::DeliveryTotalTime => MESSAGE_DELIVERY_TIME.observe(value),
|
||||
MetricType::DeliveryTime => CONNECTION_METRICS[CONN_SMTP_OUT].elapsed.observe(value),
|
||||
MetricType::DnsLookupTime => DNS_LOOKUP_TIME.observe(value),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,6 +954,8 @@ pub enum MetricType {
|
||||
SmtpRequestTime,
|
||||
SieveActiveConnections,
|
||||
SieveRequestTime,
|
||||
UserCount,
|
||||
DomainCount,
|
||||
}
|
||||
|
||||
pub const TOTAL_EVENT_COUNT: usize = total_event_count!();
|
||||
|
||||
Reference in New Issue
Block a user