Manage Lucidic sessions across async boundaries using context helpers. Lucidic uses Node AsyncLocalStorage (ALS) to attach each span to the correct session_id
. This is critical for concurrent servers where multiple requests run in parallel.
autoEnd
.
withSession
for endpoint-based/persistent sessions.withLucidic
for one-shot tasks that should end when work finishes.setActiveSession(sessionId)
in that root or wrap the work with withSession(sessionId, fn)
.lucidic.session_id
(from ALS) and falls back to the global session id for compatibility.autoEnd: true
(default), the SDK ends the session on process exit and shuts down the tracer provider gracefully.autoEnd: false
, the SDK still force-flushes spans on beforeExit
/signals to reduce lost spans. Use explicit endSession
when appropriate.