1.2.4 • Published 10 years ago
oneapm-cheniu v1.2.4
OneAPM Agent for Node.js
安装
- 在需要监控的APP中安装
oneapm模块npm install oneapm --registry http://npm.oneapm.com - 拷贝
node_modules/oneapm/oneapm.js到APP根目录 - 修改配置文件
oneapm.js,将license_key的值修改为您的OneAPM帐号中的license_key - 将
var oneapm = require('oneapm');写到APP主模块文件的第一行
浏览器性能监控
将 oneapm.getBrowserTimingHeader() 写到html模板的 <head> 标签的开头。(如果<head>中存在X-UA-COMPATIBLE HTTP-EQUIV等meta tags,请将语句写到meta tags之后,以便监控的更加精准。)
例子
app.js
var oneapm = require('oneapm');
var app = require('express')();
app.locals.oneapm = oneapm;
app.get('/user/:id', function (req, res) {
res.render('user');
});
app.listen(process.env.PORT);layout.jade:
doctype html
html
head
!= oneapm.getBrowserTimingHeader()
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content