oneapm-cheniu
v1.2.4
Published
OneAPM agent
Downloads
2
Maintainers
Readme
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