Skip to main content

traceHelper

Workspace API


Workspace API / helpers/traceHelper

helpers/traceHelper

Variables

TRACE_ID_HEADER

const TRACE_ID_HEADER: "x-trace-id" = 'x-trace-id'

Defined in: helpers/traceHelper.ts:17

Header name for trace ID propagation

Functions

getTraceId()

getTraceId(request): string

Defined in: helpers/traceHelper.ts:32

Extract or generate a trace ID for the current request

Priority:

  1. x-trace-id header (for end-to-end client tracing)
  2. New UUID (for meaningful distributed tracing)

Note: We skip Fastify's request.id because it generates short IDs like "req-1" which aren't useful for distributed tracing or debugging.

Parameters

request

FastifyRequest

Fastify request object

Returns

string

Trace ID string (UUID format)


generateTraceId()

generateTraceId(): string

Defined in: helpers/traceHelper.ts:49

Generate a trace ID without request context Use when no request is available (e.g., background jobs, scripts)

Returns

string

New UUID trace ID