12.0.8 • Published 8 months ago
@mojaloop/central-services-metrics v12.0.8
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, // Set the timeout in ms for the underlying prom-client library. Default is '5000'.
"prefix": "<PREFIX>", // Set prefix for all defined metrics names
"defaultLabels": { // Set default labels that will be applied to all metrics
"serviceName": "<NAME_OF_SERVICE>"
}
}
Initialise Metrics library:
Metrics.setup(config)
Example instrumentation:
const exampleFunction = async (error, message) => {
const histTimerEnd = Metrics.getHistogram( // Create a new Histogram instrumentation
'exampleFunctionMetric', // Name of metric. Note that this name will be concatenated after the prefix set in the config. i.e. '<PREFIX>_exampleFunctionMetric'
'Instrumentation for exampleFunction', // Description of metric
['success'] // Define a custom label 'success'
).startTimer() // Start instrumentation
try {
Logger.info('do something meaningful here')
histTimerEnd({success: true}) // End the instrumentation & set custom label 'success=true'
} catch (e) {
histTimerEnd({success: false}) // End the instrumentation & set custom label '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.
12.0.7
8 months ago
12.0.8
8 months ago
12.0.6
8 months ago
12.0.3
2 years ago
12.0.4
2 years ago
12.0.5
2 years ago
12.0.0
2 years ago
12.0.2
2 years ago
11.0.0
3 years ago
10.3.1-perf
4 years ago
10.3.0-perf
4 years ago
9.5.0
4 years ago
9.1.2-snapshot
4 years ago
9.1.0
4 years ago
9.1.1-snapshot
4 years ago
9.1.0-snapshot
4 years ago
8.8.0
4 years ago
8.3.0
5 years ago
5.2.0
5 years ago
5.1.0
5 years ago
4.4.0
5 years ago