I have node express app
I have public folder /public also it add like app.use(express.static('./public'));
and there index.html
so when I running
node server.js
it shows me localhost:3000/index.html
How can I put in index.html
newrelic.getBrowserTimingHeader()
to see in localhost:3000/index.html NREUM object
New Relic for Node requires that an application be using an HTML templating library to inject the headers.
They have full documentation here: https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/page-load-timing-nodejs
The important bits to look at are the examples. These are from the docs on the example with using Express and Jade:
The simplest way to insert browser timing headings is to pass the newrelic module into your template, and then call newrelic.getBrowsertimingHeader() from within the template.
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
The chunk where the newrelic module gets set the application locals for use in the template is the important bit: app.locals.newrelic = newrelic;.
There's simply no way to run something in a static file the way Express's static module works by default. It pretty much streams the text content of the static file directly.