This would be useful in cases where you're doing batch processing.
const start = process.hrtime.bigint();
await doBatchProcessing(batch)
const duration = Number(process.hrtime.bigint() - start) / 1e9
// record the histogram for the processing time of "each" item
histogram.observe({label: 'something'}, duration / batch.length, batch.length)
Current workaround is something like:
const start = process.hrtime.bigint();
await doBatchProcessing(batch)
const duration = Number(process.hrtime.bigint() - start) / 1e9
for (let i = 0; i < batch.length; ++i) {
histogram.observe({label: 'something'}, duration / batch.length)
}
This would be useful in cases where you're doing batch processing.
Current workaround is something like: