piscinajs / piscina

A fast, efficient Node.js Worker Thread Pool implementation

Home Page:https://piscinajs.github.io/piscina/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: allow to reset histograms

vmarchaud opened this issue · comments

I'm collecting runTime and waitTime metrics for my pool with otel:

const metrics = {
  workersQueueWaitTime: meter.createObservableGauge('content_workers_queue_wait_time'),
  workersQueueLatency: meter.createObservableGauge('content_workers_queue_latency')
} as const

// later on
const percentiles = ['p50', 'p99', 'p99_9'] as const
metrics.workersQueueWaitTime.addCallback((result) => {
  for (const percentile of percentiles) {
    result.observe(this.workers.waitTime[percentile], { percentile })
  }
})
metrics.workersQueueLatency.addCallback((result) => {
  for (const percentile of percentiles) {
    result.observe(this.workers.runTime[percentile], { percentile })
  }
})

However over the lifetime of the pool, those histogram are never reset so the p99 and p99_9 take a lot of time to get back to a current value since it stores old one. I would like to be able to call this.workers.runTime.reset() to clear the buckets after each value collection.

If that's something you are okay with, i can make a PR for it

Just out of curiosity, what would be the shape of the API?
Just to reset the histograms at a given point in time?

Along with that, do you have a distributed setup? How do you measure the distribution among hosts?

This issue has been marked as stale because it has been opened 30 days without activity. Remove stale label or comment or this will be closed in 5 days.

This issue was closed because it has been stalled for 5 days with no activity.