1 Star 0 Fork 0

zhuziyu / egg-apm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

NPM version

安装

npm i egg-apm

配置

apm-server

  • 服务名称:通过环境变量APM_SERVER_NAME传入,不传默认package.json -> name
  • 服务器地址:通过环境变量APM_SERVER_URL传入,不传默认http://localhost:8200

应用

在egg中启用

import { EggPlugin } from 'egg';

const plugin: EggPlugin = {
  apm: {
    enable: true,
    package: 'egg-apm',
    env: [ 'prod' ], // 建议只在生产环境中启用
  },
};

export default plugin;

在应用入口注册APM agent

import 'source-map-support/register';
import 'egg-apm/register'; // 注册APM agent

import * as Egg from 'egg';

Egg.start({ ignoreWarning: true })
    .then(app => {
        app.listen(3000);
    });

捕捉应用错误(可选)

// config 配置
config.onerror = {
    accepts: () => 'json',
    all(err, ctx) {
      ctx.body = { code: ctx.status || 500, msg: err.message || '系统错误' };
      // tslint:disable-next-line: no-unused-expression
      ctx.app.apm && ctx.app.apm.captureError(err);
    },
  };

空文件

简介

暂无描述 展开 收起
JavaScript
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/zhuziyu/egg-apm.git
git@gitee.com:zhuziyu/egg-apm.git
zhuziyu
egg-apm
egg-apm
master

搜索帮助