@vesselstech/central-services-health
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

central-services-health

Git Commit Git Releases Npm Version NPM Vulnerabilities CircleCI

Installation

npm install @mojaloop/central-services-health

Usage

//TODO: rewrite example usage

Import HealthCheck 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'
    }
}

Package Sidebar

Install

npm i @vesselstech/central-services-health

Weekly Downloads

0

Version

0.1.1

License

Apache-2.0

Unpacked Size

37.9 kB

Total Files

10

Last publish

Collaborators

  • lwilld