common: Add a tree checker for trace spans

Trace spans form a tree, but we don't actually check that the
structure doesn't break. Breakage can for example come if we use the
same key accidentally, making a new span its own ancestor.
This commit is contained in:
Christian Decker 2024-11-21 15:40:29 +01:00 committed by Rusty Russell
parent 2e59ab8f15
commit a6c81d4174

View File

@ -264,6 +264,7 @@ void trace_span_start(const char *name, const void *key)
current = s;
DTRACE_PROBE1(lightningd, span_start, s->id);
trace_check_tree();
}
void trace_span_remote(u8 trace_id[TRACE_ID_SIZE], u8 span_id[SPAN_ID_SIZE])
@ -283,6 +284,8 @@ void trace_span_end(const void *key)
DTRACE_PROBE1(lightningd, span_end, s->id);
trace_emit(s);
trace_check_tree();
/* Reset the context span we are in. */
current = s->parent;