Skip to content

bruuuuuuuce/goodmetrics-nodejs

Repository files navigation

Goodmetrics Nodejs

Nodejs metrics client to be used with either the goodmetrics protocol, or any open telemetry compliant protocol. Currently has a built in lightstep open telemetry client.

This library is based off of the opensource kotlin goodmetrics library

Installing

npm i goodmetrics-nodejs

example usages

import {Dimension, MetricsSetups} from 'goodmetrics-nodejs';

const main = async () => {
    // metrics setup for recording metrics inside of a lambda
  const lambdaMetrics =
    MetricsSetups.lightstepNativeOtlpButItSendsMetricsUponRecordingForLambda({
      lightstepAccessToken: '<your lightstep api key>',
      resourceDimensions: new Map<string, Dimension>(),
    });

  await lambdaMetrics.record(
    {name: 'test'},
    async metrics => {
      console.info('inside metrics block');
      metrics.measure('runs', 1);
      // await some async task
      metrics.dimension('result', 'success');
    }
  );

  // using goodmetrics
  const goodmetrics = MetricsSetups.goodMetrics();
  await goodmetrics.unaryMetricsFactory.record({name: 'unary'}, metrics => {
    metrics.dimension('is_local', true);
    metrics.measure('runs', 1);
  });
  await goodmetrics.preaggregatedMetricsFactory.record(
    {name: 'preaggregated'},
    metrics => {
        metrics.measure('w00t', 1);
    }
  );
};

main().finally();

Protos

Goodmetrics

More information about the goodmetrics protocol can be found here

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •