pinpoint-node-agent
Version:
Pinpoint node agent provided by NAVER
49 lines (40 loc) • 932 B
JavaScript
/**
* Pinpoint Node.js Agent
* Copyright 2020-present NAVER Corp.
* Apache License v2.0
*/
'use strict'
const HistogramSchema = require('./histogram-schema')
class ActiveTraceHistogram {
constructor(schema) {
this.schema = schema || HistogramSchema.NORMAL_SCHEMA
this.typeCode = schema.typeCode
this.fastCount = 0
this.normalCount = 0
this.slowCount = 0
this.verySlowCount = 0
}
increase(elapsedTime) {
if (!elapsedTime) {
return
}
if (elapsedTime <= this.schema.fast) {
this.fastCount++
} else if (elapsedTime <= this.schema.normal) {
this.normalCount++
} else if (elapsedTime <= this.schema.slow) {
this.slowCount++
} else {
this.verySlowCount++
}
}
histogramValues() {
return [
this.fastCount,
this.normalCount,
this.slowCount,
this.verySlowCount
]
}
}
module.exports = ActiveTraceHistogram