Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ddprof-lib/src/main/cpp/flightRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading