Switch to counter of events and add tick counter

This commit is contained in:
Imbris 2022-06-15 19:25:00 -04:00
parent 950723dd0d
commit d5718fd410
3 changed files with 12 additions and 4 deletions

View File

@ -288,7 +288,7 @@ impl Server {
server_event_metrics
.event_count
.with_label_values(&[event_name])
.set(i64::from(count));
.inc_by(count.into());
})
}

View File

@ -1023,6 +1023,7 @@ impl Server {
.duration_since(before_state_tick)
.as_secs_f64(),
);
tick_metrics.tick_count.inc();
}
// 9) Finish the tick, pass control back to the frontend.

View File

@ -62,10 +62,11 @@ pub struct TickMetrics {
pub start_time: IntGauge,
pub time_of_day: Gauge,
pub light_count: IntGauge,
pub tick_count: IntCounter,
}
pub struct ServerEventMetrics {
pub event_count: IntGaugeVec,
pub event_count: IntCounterVec,
}
impl PhysicsMetrics {
@ -371,6 +372,10 @@ impl TickMetrics {
)
.buckets(bucket),
)?;
let tick_count = IntCounter::with_opts(Opts::new(
"tick_count",
"counts the number of ticks that have been processed",
))?;
let since_the_epoch = SystemTime::now()
.duration_since(UNIX_EPOCH)
@ -387,6 +392,7 @@ impl TickMetrics {
registry.register(Box::new(light_count.clone()))?;
registry.register(Box::new(tick_time.clone()))?;
registry.register(Box::new(tick_time_hist.clone()))?;
registry.register(Box::new(tick_count.clone()))?;
Ok(Self {
chonks_count,
@ -399,14 +405,15 @@ impl TickMetrics {
start_time,
time_of_day,
light_count,
tick_count,
})
}
}
impl ServerEventMetrics {
pub fn new(registry: &Registry) -> Result<Self, Box<dyn Error>> {
let event_count = IntGaugeVec::new(
Opts::new("event_count", "number of ServerEvents handled this tick"),
let event_count = IntCounterVec::new(
Opts::new("event_count", "number of ServerEvents handled"),
&["event"],
)?;
registry.register(Box::new(event_count.clone()))?;