npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apm-nodejs-agent

v1.0.99

Published

APM的nodejs探针,通过实时采集接口调用、外部调用以及各种中间件的指标、调用链数据,帮助用户全面掌握 nodejs 应用的运行情况,快速定位线上故障的根源。

Downloads

12,488

Readme

NodejsAgent

APM的nodejs探针,通过实时采集接口调用、外部调用以及各种中间件的指标、调用链数据,帮助用户全面掌握 nodejs 应用的运行情况,快速定位线上故障的根源。

无修改接入

npm install -S apm-nodejs-agent && APM_APP_NAME=apm-nodejs-demo APM_AK=* APM_SK=* APM_MASTER_ADDRESS=* node -r apm-nodejs-agent/tracing app.js

自定义接入

  1. 安装依赖包
npm install -S apm-nodejs-agent
  1. 启动文件中增加代码
const process = require('process');
const agent = require('apm-nodejs-agent');

agent.start({
  appName: 'apm-nodejs-demo',
  masterAddress: '*',
  AK: '*',
  SK: '*'
}).then(()=>{
  console.log('Agent trace start');
}).catch((error)=>{
  console.log('Error agent trace',error);
})

process.on('SIGTERM',()=>{
  agent.stop();
})

使用说明

推荐node版本V14版本以上。
支持node版本v10版本以上。

参数说明

const agentDefaultConfig = {
  AK: '', // 必传字段
  SK: '', // 必传字段
  appName: '', // 必传字段
  masterAddress: '',// 必传字段
  business: '', // 不传是default
  subBusiness: '', // 多层子应用使用/分割
  env: '',
  envTag: '',
  instanceName: '',
  accessAddress:'', // 如果传递上报地址就用这个,不用masterAddress返回的地址
  appType: 'NODEJS',
  agentVersion: '1.0.0', // 版本
  logOut: 'file', // file文件或者console控制台
  logFilePath:'', // 默认放在~/apm/instances/{appName}-{instanceName}/logs/
  logFileName: 'apm.log', // 日志文件名
  logLevel: 'info', // 日志等级
  maxLogSize: 10 * 1024 * 1024, // 日志文件大小,字节
  logBackups: 4, // 日志循环覆盖个数
  registerUrl: '/apm2/master/v1/register', // 注册地址
  heartbeatUrl: '/apm2/master/v1/heartbeat', // 心跳地址
  heartBeatInterval: 60 * 1000, // 心跳间隔,毫秒
  metricInterval: 60*1000, // 指标间隔,毫秒
  maxMessageSize: 1000000, // webscoket,最大数据大小
  maxGlobalPathLength: 1000, // 最大GlobalPath的长度
  maxSpanLength: 200, // 最大span数
  maxEventLength: 200, // 最大event数
  debug: false, // 是否调试状态
  active: true,
  disablePlugins:'', // 禁用的组件,组件包括axios,egg,express,http-client,http-server,ioredis,koa,mongodb,mysql,redis多个禁用,分隔
};

组件维护者

[email protected]
[email protected]

支持插件

  • express >=4.0.0
  • koa >=2.0.0
  • mysql >=2.18.1
  • mysql2 >=2.3.3
  • ioredis >=2.0.0
  • http >=12.17
  • https >=12.17
  • axios >=0.26.0
  • request >=2.88.2
  • request-promise >=4.2.6

目录

src 源代码
./metric 指标数据
./plugins 拦截插件
./process 心跳,指标,调用链处理
./trace 调用链
./utils 方法集合
./agent.js 入口文件
./config.js 配置文件
test 单元测试
index.js 入口文件
tracing.js 无感知引入文件

DEV

npm install

TEST

整体 test,需要在配置文件/test/test.js
npm run test 调试 test,断点调试
mocha test.js

changelog

  • 1.0.99 修复axios拦截bug

  • 1.0.92 删除敏感词