Skip to main content

Overview

getCurrentTraceId() returns the trace ID of the currently active trace. Useful for correlating logs, passing to external systems, or debugging.

Signature

Basic Usage

Log Correlation

Pass to External Systems

Return to User

Return Value

Returns the current trace ID as a string, or undefined if no trace is active.

Best Practices

  • Use trace IDs for log correlation across services
  • Include trace IDs in API responses for debugging
  • Pass trace IDs to external systems for end-to-end tracing
  • Store trace IDs with error reports for troubleshooting
  • Only call within an active trace (workflow, task, agent, or tool)