| 364 | } |
| 365 | |
| 366 | void trace_span_end(const void *key) |
| 367 | { |
| 368 | if (disable_trace) |
| 369 | return; |
| 370 | |
| 371 | size_t numkey = trace_key(key); |
| 372 | struct span *s = trace_span_find(numkey); |
| 373 | assert(s && "Span to end not found"); |
| 374 | assert(s == current && "Ending a span that isn't the current one"); |
| 375 | |
| 376 | struct timeabs now = |
| 377 | time_now(); /* discouraged: but tracing wants non-dev time */ |
| 378 | s->end_time = (now.ts.tv_sec * 1000000) + now.ts.tv_nsec / 1000; |
| 379 | DTRACE_PROBE1(lightningd, span_end, s->id); |
| 380 | if (trace_to_file) { |
| 381 | fprintf(trace_to_file, "span_end %016" PRIx64 "\n", s->id); |
| 382 | fflush(trace_to_file); |
| 383 | } |
| 384 | trace_emit(s); |
| 385 | |
| 386 | /* Reset the context span we are in. */ |
| 387 | current = s->parent; |
| 388 | |
| 389 | /* Now reset the span */ |
| 390 | trace_span_clear(s); |
| 391 | } |
| 392 | |
| 393 | void trace_span_tag(const void *key, const char *name, const char *value) |
| 394 | { |