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

Function init_span

common/trace.c:107–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105static struct span *current;
106
107static void init_span(struct span *s, size_t key, const char *name,
108 struct span *parent)
109{
110 struct timeabs now =
111 time_now(); /* discouraged: but tracing wants non-dev time */
112
113 s->key = key;
114 s->id = pseudorand_u64();
115 s->start_time = (now.ts.tv_sec * 1000000) + now.ts.tv_nsec / 1000;
116 s->parent = parent;
117 s->name = name;
118 s->suspended = false;
119 for (size_t i = 0; i < SPAN_MAX_TAGS; i++)
120 s->tags[i].name = NULL;
121
122 /* If this is a new root span we also need to associate a new
123 * trace_id with it. */
124 if (!s->parent) {
125 s->trace_id_hi = pseudorand_u64();
126 s->trace_id_lo = pseudorand_u64();
127 } else {
128 s->trace_id_hi = current->trace_id_hi;
129 s->trace_id_lo = current->trace_id_lo;
130 }
131 span_htable_add(spans, s);
132}
133
134/* FIXME: forward decls for minimal patch size */
135static struct span *trace_span_slot(void);

Callers 2

trace_inject_traceparentFunction · 0.85
trace_span_start_Function · 0.85

Calls 1

time_nowFunction · 0.85

Tested by

no test coverage detected