UNPKG

@eggjs/tracer

Version:
19 lines (15 loc) 340 B
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; } }