@eggjs/tracer
Version:
tracer for egg
19 lines (15 loc) • 340 B
text/typescript
import { randomUUID } from 'node:crypto';
import type { Context } from '@eggjs/core';
export class Tracer {
readonly ctx: Context;
#traceId: string | undefined;
constructor(ctx: Context) {
this.ctx = ctx;
}
get traceId() {
if (!this.#traceId) {
this.#traceId = randomUUID();
}
return this.#traceId;
}
}