@mojaloop/central-services-metrics
Shared code for metrics generation
Last updated 7 months ago by l1pcircleci .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mojaloop/central-services-metrics 
SYNC missed versions from official npm registry.

central-services-metrics

Git Commit Git Releases Npm Version NPM Vulnerabilities CircleCI

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 npm-audit-resolver along with npm audit to check dependencies for vulnerabilities, and keep track of resolved dependencies with an audit-resolv.json file.

To start a new resolution process, run:

npm run audit:resolve

You can then check to see if the CI will pass based on the current dependencies with:

npm run audit:check

And commit the changed audit-resolv.json to ensure that CircleCI will build correctly.

Current Tags

  • 9.5.0                                ...           latest (7 months ago)
  • 10.3.1-perf                                ...           performance (5 months ago)
  • 9.1.2-snapshot                                ...           snapshot (8 months ago)

12 Versions

  • 10.3.1-perf                                ...           5 months ago
  • 10.3.0-perf                                ...           5 months ago
  • 9.5.0                                ...           7 months ago
  • 9.1.2-snapshot                                ...           8 months ago
  • 9.1.0                                ...           9 months ago
  • 9.1.1-snapshot                                ...           9 months ago
  • 9.1.0-snapshot                                ...           9 months ago
  • 8.8.0                                ...           9 months ago
  • 8.3.0                                ...           a year ago
  • 5.2.0                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 4.4.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (17)

Copyright 2014 - 2017 © taobao.org |