Synchronous spans
Auto-instrumentation wraps every middleware and many library calls in a span. A lot of them start and end without waiting on anything: a CORS check, middleware that calls the next one directly, a template helper. They add rows to every trace and say little about where the time went. Synchronous Span Handling drops them as they end, unless a keep rule matches.
What counts as synchronous
Section titled “What counts as synchronous”A span is synchronous when it starts and ends with no await in between: both happen in the same
microtask. Any await makes a span asynchronous, even one that resolves without doing I/O.
Dropped as it ends
Section titled “Dropped as it ends”A synchronous span is decided the moment it ends, not when its trace does:
- Its children move up to its parent, so the trace stays connected. Spans that start under it later attach to its nearest kept ancestor too.
- It leaves memory at once. It still counts toward Trace Span Count.
- A span a rule already removed with Drop Span or Collapse Span keeps that decision. A rule that only sets attributes doesn’t keep it.
- An errored span is held with its trace instead, so trace rules such as Drop Non-Errors see the error. It’s dropped when the trace is sent unless a keep rule matches it, such as Has Error is true.
Keep rules
Section titled “Keep rules”A synchronous span is kept if any keep rule matches it. The service’s keep rules are checked first, then the project’s. Keep rules can test what’s known once the span ends, without the rest of its trace:
| Condition | Operators |
|---|---|
| Span Name, Library Name, Span Attribute | as in rules |
| Span Duration | =, >, >=, <, <=, between |
| Has Error | is true, is false |
| Is Root Span, Is Child Span | none: whether the span has a parent in this process |
| Has Child Spans | none: whether a child of the span will still be sent |
Has Child Spans is only offered in keep rules. It’s decided from what’s known when the span ends: a
child dropped with its subtree doesn’t count, and a child dropped with its children moved up counts
through those children. In the animation, render is dropped because its only child, escape, was
dropped first.
New projects start with two keep rules:
- Is Root Span, so a trace’s root is never dropped and the trace isn’t split.
- Has Child Spans, so a synchronous span that started asynchronous work stays as that work’s parent.
Turning it off
Section titled “Turning it off”The Drop Synchronous Spans switch on the Synchronous Span Handling page turns dropping off for a service in an environment. Every synchronous span is then kept and goes through your rules like any other.