central-services-metrics

Installation
npm install @mojaloop/central-services-metrics
Usage
Import Metrics library:
const Metrics = require('@mojaloop/central-services-metrics')
Set configuration options:
let config = {
"timeout": 5000,
"prefix": "<PREFIX>",
"defaultLabels": {
"serviceName": "<NAME_OF_SERVICE>"
}
}
Initialise Metrics library:
Metrics.setup(config)
Example instrumentation:
const exampleFunction = async (error, message) => {
const histTimerEnd = Metrics.getHistogram(
'exampleFunctionMetric',
'Instrumentation for exampleFunction',
['success']
).startTimer()
try {
Logger.info('do something meaningful here')
histTimerEnd({success: true})
} catch (e) {
histTimerEnd({success: false})
}
}
Auditing Dependencies
We use audit-ci
along with npm audit
to check dependencies for node vulnerabilities, and keep track of resolved dependencies with an audit-ci.jsonc
file.
To start a new resolution process, run:
npm run audit:fix
You can then check to see if the CI will pass based on the current dependencies with:
npm run audit:check
The audit-ci.jsonc contains any audit-exceptions that cannot be fixed to ensure that CircleCI will build correctly.