MCPcopy Create free account
hub / github.com/ElementsProject/lightning / trace_inject_traceparent

Function trace_inject_traceparent

common/trace.c:144–174  ·  view source on GitHub ↗

If the `CLN_TRACEPARENT` envvar is set, we inject that as the * parent for the startup. This allows us to integrate the startup * tracing with whatever tooling we build around it. This only has an * effect if the envvar is set, otherwise the startup will create its * own parent. */

Source from the content-addressed store, hash-verified

142 * effect if the envvar is set, otherwise the startup will create its
143 * own parent. */
144static void trace_inject_traceparent(void)
145{
146 const char *traceparent;
147 be64 trace_hi, trace_lo, span;
148
149 traceparent = getenv("CLN_TRACEPARENT");
150 if (!traceparent)
151 return;
152
153 assert(strlen(traceparent) == TRACEPARENT_LEN);
154 current = trace_span_slot();
155 assert(current);
156
157 init_span(current, trace_key(&spans), "", NULL);
158 assert(current && !current->parent);
159
160 if (!hex_decode(traceparent + 3, 16, &trace_hi, sizeof(trace_hi)) ||
161 !hex_decode(traceparent + 3 + 16, 16, &trace_lo,
162 sizeof(trace_lo)) ||
163 !hex_decode(traceparent + 3 + 16 + 16 + 1, 16, &span,
164 sizeof(span))) {
165 /* We failed to parse the traceparent, abandon. */
166 fprintf(stderr, "Failed!");
167 trace_span_clear(current);
168 current = NULL;
169 } else {
170 current->trace_id_hi = be64_to_cpu(trace_hi);
171 current->trace_id_lo = be64_to_cpu(trace_lo);
172 current->id = be64_to_cpu(span);
173 }
174}
175
176static void memleak_scan_spans(struct htable *memtable,
177 struct span_htable *spantable)

Callers 1

trace_initFunction · 0.85

Calls 6

trace_span_slotFunction · 0.85
init_spanFunction · 0.85
trace_keyFunction · 0.85
hex_decodeFunction · 0.85
trace_span_clearFunction · 0.85
be64_to_cpuFunction · 0.85

Tested by

no test coverage detected