diff --git a/lib/trace_mgr.js b/lib/trace_mgr.js index 7572e77f3cd..047ccd88d82 100644 --- a/lib/trace_mgr.js +++ b/lib/trace_mgr.js @@ -157,6 +157,9 @@ function createTraceLogTarget(tracename) { var traceRootDir = emitOptions.localTraceDirectory || path.dirname(process.mainModule.filename); + // Add the PID to the trace name + tracename = `${tracename}_pid${process.pid}`; + var resolvedTracePath = path.resolve(traceRootDir, '_diagnosticTraces', tracename); diff --git a/src/node.cc b/src/node.cc index 9921ba921be..cae0e695c8c 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4981,6 +4981,15 @@ int Start(int argc, char** argv) { #if ENABLE_TTD_NODE bool chk_debug_enabled = debug_options.inspector_enabled(); + std::string envDoRecordVar; + bool envDoRecord = SafeGetenv("DO_TTD_RECORD", &envDoRecordVar) && + envDoRecordVar[0] == '1'; + + if (!s_doTTRecord && !s_doTTReplay) { + // Apply the value from the environment variable + s_doTTRecord = envDoRecord; + } + TTDFlagWarning_Cond(!s_doTTRecord || !s_doTTReplay, "Cannot enable record & replay at same time.\n"); @@ -5010,6 +5019,11 @@ int Start(int argc, char** argv) { TTDFlagWarning_Cond(s_ttoptReplayUri != nullptr, "Must set replay source info when replaying.\n"); } + + if (s_doTTRecord) { + // Apply the environment variable to be inherited by child processes. + putenv("DO_TTD_RECORD=1"); + } #endif