How to use the newrelic.getBrowserTimingHeader function in newrelic

To help you get started, we’ve selected a few newrelic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ello / webapp / src / server / iso.js View on Github external
app.use((req, res) => {
  res.setHeader('Cache-Control', 'public, max-age=60');
  res.setHeader('Expires', new Date(Date.now() + (1000 * 60)).toUTCString());

  const requestId = req.headers['x-request-id']

  // This needs to be generated in the request, not a callback
  const timingHeader = newrelic.getBrowserTimingHeader()

  if (canPrerenderRequest(req)) {
    // Ensure the cache gets busted when new JS is deployed
    const cacheKey = cacheKeyForRequest(req, stats.hash)
    console.log(`[${requestId}][handler] Attempting to serve pre-rendered markup for path`, req.url, cacheKey)
    memcacheClient.get(cacheKey, (err, value) => {
      if (value) {
        console.log(`[${requestId}][memcache] Cache hit!`, req.url)
        const { body, postIds, postTokens, streamKind, streamId } = JSON.parse(value)
        trackPostViews(requestId, postIds, postTokens, streamKind, streamId)
        res.send(body)
      } else {
        renderFromServer(req, res, cacheKey, timingHeader)
      }
    })
  } else {
github meetup / meetup-web-platform / packages / mwp-app-render / src / components / Dom.jsx View on Github external
*/

	// stringify the whole object so that it can be escaped in one pass
	const initialStateJson = JSON.stringify(initialState);
	// escape the string
	const escapedState = escapeHtml(initialStateJson);

	const APP_RUNTIME = {
		appContext,
		escapedState,
	};

	// strip 
github deltaepsilon / quiver-cms / content-server.js View on Github external
deferred.promise.then(function() {
        var port = ConfigService.get('private.content.port');
        app.listen(port);

        if (NewRelic) {
            LogService.info('New Relic enabled for production');
            app.locals.NewRelic = NewRelic.getBrowserTimingHeader();
        } else {
            LogService.info('New Relic disabled for development');
            app.locals.NewRelic = "";
        }

        LogService.info('Serving on port ' + port);

    }, function(err) {
        LogService.error('App not listening', err);
github dexteryy / Project-WebCube / packages / webcube / server / ssrRoute.js View on Github external
logger.error(`[WEBCUBE] [${requestId}] Failed to inject inistal state tag`);
    logger.error(ex);
  }
  try {
    if (styleTags) {
      entryHtml = entryHtml.replace(RE_LAST_IN_HEAD, `${styleTags}`);
    }
  } catch (ex) {
    logger.error(
      `[WEBCUBE] [${requestId}] Failed to inject styled-component tag`
    );
    logger.error(ex);
  }
  try {
    const afterTitle = (isProductionEnv && getDeployConfig().enableNewRelic
      ? [newrelic.getBrowserTimingHeader()]
      : []
    ).concat(
      helmet
        ? [
            helmet.meta.toString(),
            helmet.link.toString(),
            helmet.style.toString(),
            helmet.script.toString(),
            helmet.noscript.toString(),
          ]
        : []
    );
    if (helmet) {
      entryHtml = entryHtml.replace(RE_TITLE, helmet.title.toString());
    }
    entryHtml = entryHtml.replace(