如何将 NewRelic 用于我的 Meteor 应用程序? [英] How can I use NewRelic for my Meteor application?
问题描述
我在 Heroku 上托管我的 Meteor 应用程序,并希望拥有更多的监控功能,而不是 heroku logs --tail
.NewRelic 可能是一个不错的选择,尽管它的 node.js 代理仍处于测试阶段.有没有人尝试将它与 Meteor 应用一起使用?
旧答案在下方.
2014 年更新:
截至撰写本文时的流星版本:0.9.4
.甜的.快到 1.0 了!
好的,我决定编辑它,因为它现在仍然很过时,仍然得到了赞成.
从 Meteor 0.7+ 或左右开始(记不清了),Meteor 中的 require-ing 早已从 __meteor_bootstrap__.require
更改为 Npm.require
<代码>var require = Npm.require;var newrelic = require('newrelic');
这遵循了智能包模式中的 Npm.在此处阅读更多相关信息
懒人摘录(感谢,Meteorpedia!):
<块引用>智能包中的 NPM
在您的
package.js
中,添加如下子句:Npm.depends({走":2.2.1"});
使用
Npm.require
代替 require,例如var http = Npm.require('http');
但是说真的,请在流星百科上阅读整篇文章.值得你花时间.
或者,您也可以使用arunoda的优秀NPM智能包.看看这里!https://github.com/meteorhacks/npm
旧答案:
取自本指南,您应该能够像安装任何其他 npm 模块一样安装 newrelic 代理.在您的流星项目文件夹中:
$ cd .meteor/local/build/server$ npm install newrelic
现在,你可以通过require
来使用它:
var require = __meteor_bootstrap__.require;var newrelic = require('newrelic');
然后,按照此处指定的方式配置您的代理:https://github.com/newrelic/node-newrelic/#configuring-the-agent
如果您需要使用该指南中指定的环境变量,请使用环境变量集运行 meteor
命令,例如:
$ NEW_RELIC_APP_NAME=mynodeapp 流星
应该是这样,但我还没有真正广泛使用它,因为我还没有找到任何理由这样做.让我们知道你会得到什么!
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?
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
In your
package.js
, add a clause like:Npm.depends({ "walk": "2.2.1" });
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!
这篇关于如何将 NewRelic 用于我的 Meteor 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!