Filtering & External Data Sources
Add declarative <trace-filter> children to build an interactive filter bar above the views.
Combine instant client-side predicates (source="local") across span attributes and raw log events
with server-driven query parameters or custom async loaders (source="external").
1Local Filter Controls (source="local")
Local filters compile into a single client-side predicate with AND semantics and write a SpanMask into the shared store —
Waterfall highlights matching rows, Flame Graph, Service Map, and Sequence Diagram dim elements with zero matching spans,
Stats scopes its aggregations to matching spans by default (toggleable to dim),
and Lanes dims non-matching spans in place without repacking levels, while collapsed-lane concurrency summaries count only matching spans.
Press Ctrl/⌘+F inside the visualizer to focus the search input, and Escape to return to the timeline.
2Span Target vs. Log Event Target (target="log")
When transformLogs() groups multiple log lines into one span, each raw log record is kept as an OTel Event on that span.
Setting target="span" (default) matches span-level attributes, whereas target="log" inspects every underlying event —
a span passes when at least one of its log events matches.
fintech-logs.json: Pick Card Network = amex, Region = eu-west-1,
or Severity = ERROR to isolate the declined European Amex capture, or type ISO-8583 into Payload Message (log).
<trace-visualizer
data-url="./data/fintech-logs.json"
trace-id-field="trace.id"
span-group-fields="service.name,operation"
span-name-field="operation"
service-name-field="service.name"
timestamp-field="ts"
status-code-field="code"
parent-span-lookup-fields="caller"
show-legend
>
<!-- Span-level match (default target="span") -->
<trace-filter field="spanName" label="Operation (span)" type="text" source="local" target="span"></trace-filter>
<!-- Event-level matches: pass when ANY raw log record inside the span matches -->
<trace-filter field="payload.message" label="Payload Message (log)" type="text" source="local" target="log"></trace-filter>
<trace-filter field="payload.cardNetwork" label="Card Network (log)" type="dropdown" source="local" target="log"
options='["visa","amex","mastercard"]' placeholder="All networks"></trace-filter>
<trace-filter field="service.region" label="Region (log)" type="dropdown" source="local" target="log"
options='["us-east-1","eu-west-1","ap-south-1"]' placeholder="All regions"></trace-filter>
<trace-filter field="severity" label="Severity (log)" type="dropdown" source="local" target="log"
options='["INFO","DEBUG","ERROR"]' placeholder="Any severity"></trace-filter>
</trace-visualizer>
3External Filters & fetchCallback
Filters with source="external" push query parameters to your backend instead of filtering already-loaded spans.
Assign el.fetchCallback = async (url, filters) => ... to query your own API, database gateway, or log search endpoint
and return either TraceData or raw LogEntry[].
4<trace-filter> Attribute Reference
| Attribute | Values / Type | Description |
|---|---|---|
field |
string (required) |
"*" (all fields & events), "spanName", "serviceName", "spanKind", "hasError", "startTime", any span attribute key, or dot-path into log events when target="log". |
label |
string (required) |
Human-readable label displayed alongside the input control. |
type |
text | dropdown | multiselect | checkbox | datetime-range |
UI control rendered in the filter bar and value shape emitted in filter-changed. |
source |
local | external |
local filters in-memory spans immediately; external forwards parameters to data-url or fetchCallback. |
target |
span (default) | log |
For local filters: inspect span attributes (span) or underlying OTel log events (log). |
options-source / options |
auto | static + JSON array |
options-source="auto" populates unique values from loaded data; options accepts JSON ["a","b"] or [{"value":"2","label":"Server"}]. |
required |
boolean attribute | On external filters, blocks fetching until the user provides a non-empty value. |
debounce / width / auto-range |
number (ms) / number (px) / boolean |
debounce delays text filter emission (default 400 ms); width sets control width; auto-range pre-fills min/max bounds on datetime-range. |