Skip to content

About

Seneca telemetry for NewRelic

Resources

Code of conduct

Stars

0 stars

Watchers

2 watching

Forks

Repository files navigation

Seneca

A Seneca.js plugin

@seneca/telemetry-newrelic

npm version build Coverage Status Known Vulnerabilities DeepScan grade Maintainability

Voxgig This open source module is sponsored and supported by Voxgig.

Capture NewRelic telemetry for Seneca actions.

Install

npm install @seneca/telemetry-newrelic

Dependencies:

Quick Example

const Seneca = require('seneca');
const newrelicPlugin = require('seneca-telemetry-newrelic');

const SECRET_NEWRELIC_API_KEY = "SECRET_NEWRELIC_API_KEY";
const MY_SERVICE_NAME = "MY_SERVICE_NAME";

const senecaInstance = Seneca()
  .use('promisify')
  .use(newrelicPlugin, {
    // Enable Tracing
    tracing: {
      enabled: true,
      accountApiKey: SECRET_NEWRELIC_API_KEY,
      serviceName: MY_SERVICE_NAME,
    },
    // Enable Segments
    segment: {
      enabled: true,
    },
    // Enable Metrics
    metrics: {
      enabled: true,
      accountApiKey: SECRET_NEWRELIC_API_KEY,
    },
    // Enable Events
    events: {
      enabled: true,
      accountApiKey: SECRET_NEWRELIC_API_KEY,
    },
  });

More Examples

See test/ for more usage examples.

Motivation

Plugin for integrating New Relic with Seneca.js for telemetry and observability.

Support

If you're using this module and need help, you can:

API

Events

Send your own custom event data.

Events API should be used to track specific/edge cases. In most cases, try to use Metrics.

// The base pattern is: "plugin:newrelic,api:event"
// All res objects follow the same pattern: { err?: Error, statusCode?: number, body? }

seneca.act('plugin:newrelic,api:event,somethingHappened,attributes:{isOK:false,error:"System Crash - CODE 784"}', (err, res) => {
  // err is null
  // handle res here (Check for errors, log data, et cetera)
});

Metrics

Send your own custom dimensional metrics to New Relic.

The SDK supports three types of Metrics: count, gauge, summary. Read about metric types here.

// The base pattern is: "plugin:newrelic,api:metric"
// You can also pass a custom object in the attributes field
// All res objects follow the same pattern: { err?: Error, statusCode?: number, body? }

Gauge example:

// value must be typeof number
seneca.act("plugin:newrelic,api:metric,type:gauge,value:2,name:custom.seneca.counter,attributes:{'user.name': 'Vitor', age: 26}", (err, res) => {
  // handle res here
})

Summary example:

// value must be of typeof { count?: number, sum?: number, min?: number, max?: number }
seneca.act('plugin:newrelic,api:metric,type:summary,name:sumOfSomething,value:{sum: 1}');

Count example:

// value must be typeof number
seneca.act('plugin:newrelic,api:metric,type:count,name:custom.counter,value:10');

Tracing

After enabling it, Seneca will start sending distributed tracing data to New Relic.

When an action is dispatched, Seneca traces it until it finishes, then sends the aggregated data to New Relic. In the New Relic UI you will see the performance of your Seneca actions.

Segment

TODO

Contributing

The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.

Running tests

npm run test

Background

Integrates with New Relic for observability of Seneca microservices.

About

Seneca telemetry for NewRelic

Resources

Code of conduct

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages