npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

newrelic-node

v0.3.7

Published

Logger para newrelic

Downloads

96

Readme

Agente de newrelic para node.

Instalación

npm install newrelic-node

Configuración

Editar el archivo newrelic/newrelic.yml con la license_key y app_name de la aplicación correspondiente.

Use con Express:

var newrelic = require( "newrelic-node" );
app.use(newrelic.express);	

Uso manual:

var newrelic = require( "newrelic-node" );
var startDate = new Date();

newrelic.logRequest(request, response, Date.now()-startDate.getTime());
o
newrelic.log({timespent:{"URI_WEB_TRANSACTION":Date.now()-startDate.getTime()}, 
	path:"/test", httpStatus:200, httpMethod:"GET"});
o
newrelic.log({timespent:{"URI_WEB_TRANSACTION":Date.now()-startDate.getTime(), WEB_TRANSACTION_EXTERNAL_ALL: 1000}}, }
	path:"/test", httpStatus:200, httpMethod:"GET"});
o
newrelic.log({timespent:{"URI_WEB_TRANSACTION":Date.now()-startDate.getTime()}, 
	path:"/test", httpStatus:200, httpMethod:"GET", calls:100}); //simula 100 request

Loguear errores manualmente:

var newrelic = require( "newrelic-node" );
newrelic.logRequestError("Un mensaje de error", request, response, timespent);
o
newrelic.log({timespent:{"URI_WEB_TRANSACTION":12}, error: "Mensaje de error", 
	path:"/error", httpStatus:500, httpMethod:"GET"}});		

Custom Metrics:

var newrelic = require( "newrelic-node" );
newrelic.log({timespent:{URI_WEB_TRANSACTION:5}, path:"/test", httpStatus:201, httpMethod:"GET", 
	custom_metric:[{name:"tiempo", type: "time", value:1 }, {name:"tiempo", type: "counter", value:1000 }]});

Las custom metrics son de tipo "counter" o "time". Las mismas se pueden graficar en una custom view como /CUSTOM/name.

Tipos de timespent:

  • External/allWeb

  • WebTransaction/Uri

  • WebFrontend/QueueTime

  • Database/allWeb

  • Solr/allWeb

Cada timespent es independiente en el dashboard de newrelic, se pueden enviar varios concatenados en el mismo mensaje.

Formato de Json:

{timespent:
	{type_timespent:(number|double|date), type_timespent:(number|double|date)},
	path:string, 
	httpStatus:number, 
	httpMethod:string, 
	custom_metric:[
		{name:string, type:counter, value:(numbre|double|string) }, 
		{name:string, type:time, value:(number|double) }
	],
	calls: number}

Entorno de desarrollo:

Para que no levante el proceso en entorno de desarrollo se puede usar: NODE_ENV=development node app.js

Requisitos:

JAVA 1.6

Empaquetar:

npm publish

Como funciona?

Como newrelic no tiene soporte nativo para nodejs, lo que hace el modulo es levantar un proceso java que loguea en newrelic. El proceso java usa MINA para comunicarse con nodejs.

Herramientas usadas:

Mina (mina.apache.org)