新文物浏览器index.html

时间:2014-09-19 16:01:29

标签: node.js backbone.js newrelic

我有节点快递应用
我有公共文件夹/ p​​ublic也添加如 app.use(express.static(' ./ public')); index.html
所以当我跑步时

 node server.js

它显示我localhost:3000 / index.html
如何输入 index.html

newrelic.getBrowserTimingHeader()

在localhost:3000 / index.html NREUM 对象

中查看

1 个答案:

答案 0 :(得分:0)

New Relic for Node要求应用程序使用HTML模板库来注入标题。

他们在这里有完整的文档:https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/page-load-timing-nodejs

要看的重要部分是示例。这些来自使用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);

<强> layout.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的静态模块无法在静态文件中运行。它几乎直接流式传输静态文件的文本内容。