Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use NewRelic for my Meteor application?

Tags:

meteor

I'm hosting my Meteor app on Heroku and would like to have more monitoring capabilities rather than heroku logs --tail. NewRelic could be a good option, though its node.js agent is still in beta. Does anybody tried to use it with Meteor app?

like image 614
Vladimir Lebedev Avatar asked Jan 30 '13 08:01

Vladimir Lebedev


1 Answers

Old answer available below.

UPDATE FOR 2014:

Meteor version as of time of writing: 0.9.4. sweet. almost at 1.0!

OK I decided to edit this as this still gets upvotes with it being very outdated now.

As of Meteor 0.7+ or around that (can't remember exactly), require-ing in Meteor has been long changed from __meteor_bootstrap__.require to Npm.require

var require = Npm.require; var newrelic = require('newrelic');

This follows the Npm in a smart package pattern. Read more about it here

Excerpt for the lazy (thanks, Meteorpedia!):

NPM in a Smart Package

  1. In your package.js, add a clause like:

    Npm.depends({ "walk": "2.2.1" });

  2. Use Npm.require instead of require, e.g.

    var http = Npm.require('http');

But seriously, read the whole thing on meteorpedia. It's worth your time.

Alternatively, you can also use arunoda's excellent NPM smart package. Check it out here! https://github.com/meteorhacks/npm

Old answer:

Taken from this guide, You should be able to install the newrelic agent like any other npm module. In your meteor project folder:

$ cd .meteor/local/build/server
$ npm install newrelic

Now, you can use it via require:

var require = __meteor_bootstrap__.require;
var newrelic = require('newrelic');

Then, configure your agent as specified here: https://github.com/newrelic/node-newrelic/#configuring-the-agent

if you need to use env vars specified in that guide, run the meteor command with the env vars set e.g.:

$ NEW_RELIC_APP_NAME=mynodeapp meteor 

That should be it, but I haven't really used it extensively because I haven't found any reason yet to do so. Let us know what you get to!

like image 109
Seth Malaki Avatar answered Sep 22 '22 18:09

Seth Malaki