Spans & Distributed Tracing
How Triton builds a parent-child trace out of spans — one level deeper than the transaction id, recording which work happened inside which.
The transaction id answers one question: which logs belong to the same operation? Spans answer the next one: how are they nested? A span marks a single unit of work, and a parent span points at the work that contains it. Chain them together and a flat list of logs becomes a tree — the button click, the backend call it triggered, the step that call ran inside.
Every Triton log carries two span fields:
Span_Id__c
.spanId(String)
Identifies this unit of work.
Parent_Span_Id__c
.parentSpanId(String)
Points at the enclosing unit of work.
Set both across a set of logs and you've described a hierarchy.
Spans in LWC — automatic hierarchy
The LWC logger builds the span tree for you. It keeps a span context stack whose root is the transaction id, and it stamps every log with a freshly generated spanId and a parentSpanId taken from the top of that stack.
You don't call spanId() by hand for ordinary logs — makeBuilder() (and therefore debug(), info(), error(), etc.) already does it:
// Each of these logs gets a unique spanId and, as its parent,
// the current top of the span stack (the transaction root by default).
this.triton.log(
this.triton.info(TYPE.FRONTEND, AREA.ACCOUNTS)
.summary('Loaded account panel')
);Logical steps
For multi-step UIs (wizards, multi-screen flows), enterStep() resets the stack back to the transaction root and pushes a new span for the step. Everything logged afterward hangs off that step:
const stepSpan = this.triton.enterStep(); // start "Step 2"
this.triton.log(
this.triton.info(TYPE.FRONTEND, AREA.ACCOUNTS)
.summary('Entered shipping details')
);
// → this log's parentSpanId is the step spanPerformance calls nest automatically
The profiling helpers — timeBackendCall(...), timeUserInteraction(...), and performance marks — push their own span while they run and pop it when they finish. Their start/complete/failure logs share that span, and any logs you emit during the call become children of it. That's how a backend call and everything it did end up neatly grouped. (See Profiling for the full API.)
Surviving navigation
If a logical operation spans multiple page loads, call enableSpanPersistence() to back the span stack with sessionStorage, so the hierarchy survives navigation instead of resetting.
Spans in Apex
Apex has the same two defaults, one for each situation.
Outside a mark, the shape is the simple one: if you don't set a span id, the builder fills Span_Id__c with the current request id at build time, and Parent_Span_Id__c stays null. Every log in one Apex request shares a span, without any effort and without any change to what you have today.
Marks build the tree
Inside a mark, Apex behaves like LWC. Performance marks keep a span stack, and while a mark is open every log you emit gets its own span id and hangs off the innermost mark:
The rules are short:
The outermost mark parents to the transaction span, so a top-level mark anchors to the same tree everything else in the transaction hangs from. Depth is a fact the framework reads, not something you declare — which is why there's no boundary-specific method.
A nested mark parents to the mark enclosing it.
An ordinary log inside a mark becomes a leaf under the innermost mark.
An id you set yourself always wins.
.spanId(...)/.parentSpanId(...)are never overwritten — that's what keeps LWC → Apex traces intact, because the ids forwarded from the browser arrive already set.A mark filtered out by log levels is transparent: its children re-parent to the nearest surviving ancestor rather than pointing at a span that was never published.
Setting ids by hand
When you want structure without marks — say, a parent log for an operation and child logs for its sub-steps — set the ids yourself:
traceable and tracePoint
Beyond parent/child structure, Triton can mark a log as an explicit trace point for Pharos. Two builder methods control this, and they work as a pair:
.traceable(Boolean)— opts this builder into tracing. Passingtruealso flags the log for issue creation..tracePoint()— records a trace point on the underlying Pharos log builder — but only iftraceableistrue. If tracing wasn't enabled, it's a no-op.
How this maps to OpenTelemetry
This mapping is what people mean when they call a Triton 2.0 org "OpenTelemetry-ready." If you think in OpenTelemetry terms, Triton's model lines up cleanly with the tracing vocabulary — the same trace/span/parent-span shape an observability stack expects. The mapping is conceptual — it helps you reason about the data, and it's a foundation to build an OTel integration on — not a wire-format integration that ships today:
Trace (one end-to-end operation)
The transaction id (Triton.TRANSACTION_ID / this.triton.transactionId) that correlates all the logs.
Span (a unit of work within a trace)
Span_Id__c, set via .spanId(...).
Parent span (the enclosing work)
Parent_Span_Id__c, set via .parentSpanId(...).
Span nesting / trace tree
The span stacks — the LWC span-context stack and the Apex mark stack — plus any ids you set by hand.
Marking a span of interest
.traceable(true) + .tracePoint().
Getting this shape everywhere
The mapping only pays off if your logs actually carry span structure across Apex, LWC, and Flow. That's exactly what the Instrumentation Skills roll out for you: the Apex skill threads one transaction id through async hops, the LWC skill's timeBackendCall carries span context across a backend call, and the Flow skill stitches the Flow leg into the same transaction — so the trace/span/parent-span shape is applied consistently instead of by hand.
Do / Don't
Related reading
Transactions & Platform Cache — the correlation id that spans hang off of.
End-to-End Logging — spans in the context of a full LWC → Apex → Flow trace.
Profiling — performance helpers that create spans automatically.
Instrumentation Skills — slash commands that roll this tracing shape out across Apex, LWC, and Flow.
Last updated