Back to Egg

@eggjs/tracer

plugins/tracer/README.md

4.0.101.9 KB
Original Source

@eggjs/tracer

tracer plugin for egg.

Install

bash
npm i @eggjs/tracer

Usage

Enable tracer plugin:

js
// config/plugin.ts
import tracerPlugin from '@eggjs/tracer';

export default {
  ...tracerPlugin(),
};

Build my own Tracer Class

ts
// ./path/to/my_tracer.ts
import { Tracer } from '@eggjs/tracer';

const counter = 0;

export class MyTracer extends Tracer {
  get traceId() {
    return `${counter++}-${Date.now()}-${process.pid}`;
  }
}

Change the config to use MyTracer:

ts
// config/config.default.ts
import { defineConfig } from 'egg';

import { MyTracer } from './path/to/my_tracer.ts';

export default defineConfig({
  tracer: {
    Class: MyTracer,
  },
});

Questions & Suggestions

Please open an issue here.

License

MIT

Contributors

Made with contributors-img.