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. */
| 142 | * effect if the envvar is set, otherwise the startup will create its |
| 143 | * own parent. */ |
| 144 | static 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 | |
| 176 | static void memleak_scan_spans(struct htable *memtable, |
| 177 | struct span_htable *spantable) |
no test coverage detected