Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js New relic browser index.html_Node.js_Backbone.js_Newrelic - Fatal编程技术网

Node.js New relic browser index.html

Node.js New relic browser index.html,node.js,backbone.js,newrelic,Node.js,Backbone.js,Newrelic,我有node express应用程序 我有public folder/public,它还添加了app.use(express.static('./public')) 还有index.html 所以当我跑步的时候 node server.js 它向我显示localhost:3000/index.html 如何输入index.html newrelic.getBrowserTimingHeader() 要在localhost:3000/index.htmlNREUMobjectNew Reli

我有node express应用程序
我有public folder/public,它还添加了app.use(express.static('./public')) 还有index.html
所以当我跑步的时候

 node server.js
它向我显示localhost:3000/index.html
如何输入index.html

newrelic.getBrowserTimingHeader()

要在localhost:3000/index.htmlNREUMobject

New Relic for Node中查看,应用程序需要使用html模板库来插入头

他们在这里有完整的文档:

要查看的重要部分是示例。这些来自使用Express和Jade的示例中的文档:

插入浏览器计时标题的最简单方法是将newrelic模块传递到模板中,然后从模板中调用newrelic.getBrowsertimingHeader()

app.js

var newrelic = require('newrelic');
var app = require('express')();
// in express, this lets you call newrelic from within a template
app.locals.newrelic = newrelic;

app.get('/user/:id', function (req, res) {
  res.render('user');
});
app.listen(process.env.PORT);
布局。jade

doctype html
html
  head
    != newrelic.getBrowserTimingHeader()
    title= title
    link(rel='stylesheet', href='stylesheets/style.css')
  body
    block content
newrelic
模块设置模板中使用的应用程序局部变量的块是重要的一位:
app.locals.newrelic=newrelic


没有办法在静态文件中运行某些东西,默认情况下Express的static模块就是这样工作的。它几乎直接流式传输静态文件的文本内容

但是如果你不想只使用render scenario index.html?@ButuzGOL,newrelic不支持这种情况。脚本必须以某种方式注入到页面中,唯一的方法是注入到模板中。@ButuzGOL它确实支持它,但您必须执行添加newrelic-browser.js文件的复制粘贴方法。