diff --git a/ddprof-lib/src/main/cpp/flightRecorder.cpp b/ddprof-lib/src/main/cpp/flightRecorder.cpp index 3b788efc1..7d4591b5e 100644 --- a/ddprof-lib/src/main/cpp/flightRecorder.cpp +++ b/ddprof-lib/src/main/cpp/flightRecorder.cpp @@ -1699,14 +1699,14 @@ void Recording::writeContextSnapshot(Buffer *buf, Context &context) { void Recording::writeCurrentContext(Buffer *buf) { u64 spanId = 0; u64 rootSpanId = 0; - bool hasContext = ContextApi::get(spanId, rootSpanId); // spanId/rootSpanId are initialized to 0 above; ContextApi::get() only updates them - // on success, so 0s are always written when there is no valid context. + // on success, so 0s are always written when there is no active span. + ContextApi::get(spanId, rootSpanId); buf->putVar64(spanId); buf->putVar64(rootSpanId); size_t numAttrs = Profiler::instance()->numContextAttributes(); - ProfiledThread* thrd = hasContext ? ProfiledThread::currentSignalSafe() : nullptr; + ProfiledThread* thrd = ProfiledThread::currentSignalSafe(); for (size_t i = 0; i < numAttrs; i++) { buf->putVar32(thrd != nullptr ? thrd->getOtelTagEncoding(i) : 0); }