Skip to content

Commit

Permalink
Merge pull request #22 from Altruistiq/feat/sc-00000/faster-way-to-ge…
Browse files Browse the repository at this point in the history
…t-trace-id

Feat/sc 00000/faster way to get trace
  • Loading branch information
gremp authored Apr 24, 2024
2 parents caad136 + 72c85c6 commit e167808
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helpers/trace-id.helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export function getTraceId(): string | undefined {
import type { Response } from "express";

export function getTraceId(res?: Response): string | undefined {
if (res?.locals?.reef?.traceId) return res.locals.reef.traceId;
const err = new Error();
const traceIdSearch = /\[as __REEF_CALL_STACK_(.+?)__END_OF_REEF__]/gm.exec(
err.stack as string,
Expand Down

0 comments on commit e167808

Please sign in to comment.