0.1.0 • Published 4 years ago

phaeton-newrelic v0.1.0

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
4 years ago

phaeton-newrelic

License: GPL v3

A newrelic custom instrumentation for Phaeton Core

Installation

$ npm install --save newrelic
$ npm install --save https://github.com/PhaetonHQ/phaeton-newrelic.git

Usage

You have to create your own copy of newrelic configuration. NewRelicPhaeton just instrument using available newrelic object.

const newrelic = require('newrelic');
const newrelicPhaeton = require('phaeton-newrelic')(newrelic, {
	exitOnFailure: true,
	rootPath: process.cwd(),
});

newrelicPhaeton.instrumentWeb();
newrelicPhaeton.instrumentDatabase();
newrelicPhaeton.instrumentBackgroundJobs();

Options

Following options can be passed to create the phaeton instrumentation object.

OptionTypeRequiredDescription
exitOnFailureBooleanYesExit the main process if any error occurred during instrument initialization.
rootPathStringYesAbsolute path of the phaeton core directory

API

MethodDescription
instrumentWebInstrument web requests to show the request path exactly defined in swagger by Phaeton Core.
instrumentDatabaseInstrument some functions of pg-promise to get good insight of database transactions.
instrumentBackgroundJobsInstrument every job in the jobQueue in Phaeton Core
instrumentCallbackMethodsInstrument methods of modules which have defined callback.

Instrumenting a module

If you have a module to instrument, with following details:

  1. A module named node
  2. It is require in the app with exactly the path ./modules/node.js
  3. And you want to instrument two methods internal.getForgingStatus and shared.getConstants You can instrument this:
newrelicPhaeton.instrumentCallbackMethods(
	'./modules/node.js',
	'modules.node',
	['internal.getForgingStatus', 'shared.getConstants']
)

Contributors

https://github.com/PhaetonHQ/phaeton-newrelic/graphs/contributors

License

Copyright © 2017 Phaeton Foundation

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

phaeton-newrelic