Transactions & Platform Cache
How a transaction id ties logs together across LWC, Apex, and Flow — the lifecycle methods that manage it and the platform cache that moves it between contexts.
A transaction id is Triton's correlation key. Every log carrying the same id groups together in Pharos, no matter which context produced it. This page is the reference for the two things that make correlation work: the transaction lifecycle methods (startTransaction, resumeTransaction, stopTransaction) and the platform cache that shuttles the id between contexts (withCache and TritonCacheManager).
If you just want to see it wired up in a real LWC → Apex → Flow chain, start with the End-to-End walkthrough and come back here for the details.
The transaction id
In Apex, the current transaction id lives on a single static field:
public static String Triton.TRANSACTION_ID;Because Apex statics live for the duration of one Apex transaction, this one field is shared by everything you log — every Triton.log(...), every convenience method, every Flow Log action that runs during that transaction. That's the whole reason logs correlate automatically without you threading an id around. (For the bigger picture on static state, see The Static Logging API.)
Managing the lifecycle
Three static methods drive the transaction id.
startTransaction()
Generates a brand-new UUID v4, stores it in TRANSACTION_ID, and returns it. If the cache is enabled (see below), it also writes the id to Org cache.
String id = Triton.startTransaction();
// TRANSACTION_ID is now a fresh UUID like 7fb8c320-e8f9-4f1b-9742-1a5768b9e0d2Call this to begin a new correlation — for example at the top of an entry point that isn't downstream of any other context.
resumeTransaction(String transactionId)
Adopts an existing id instead of minting one. Use it to tie the current context to a transaction that started somewhere else — the classic case being an Apex controller adopting the id its LWC caller already established.
If the cache is enabled, resumeTransaction also re-caches the id — which conveniently extends its time-to-live.
stopTransaction()
Clears TRANSACTION_ID (and removes it from cache when caching is on). After this, the next log that needs an id will start a fresh transaction.
Triton.withCache() — let the id travel on its own
Passing a transaction id through method parameters works, but it gets tedious across many components and calls. Triton.withCache() offers an alternative: park the id in platform Org cache so any later context — even in a separate transaction — can pick it up without you passing anything.
Here's exactly what withCache() does:
Checks whether Org cache is available (
TritonCacheManager.available()).If it isn't available — turns caching off, and starts a transaction if one isn't already running. Everything still works; you just don't get cross-transaction propagation.
If it is available — turns caching on, then:
looks for a cached transaction id and, if found, resumes it;
otherwise, if there's no current id, starts a new one (which gets cached).
The cached id is stored in Org cache under a per-user key, with a time-to-live set by the Cache TTL (minutes) setting — 5 minutes by default. Each resume re-caches it and resets that clock, so an active chain of calls keeps the id alive. Because the key is namespaced by user, two users' transactions never collide in the shared Org cache.
TritonCacheManager — the cache behind it all
TritonCacheManager is the thin layer that centralizes every platform-cache operation. Triton uses a single partition — Org cache — for both things it caches:
Value cache
put, get, getKeys, remove
Storing the transaction id (per-user key) and buffering Flow logs for the deferred flush batch.
Availability
available
Gatekeeper for withCache().
Org cache is the right home for both: it isn't tied to a user session, so the transaction id survives across separate transactions and asynchronous contexts, and Flow logs remain discoverable by a batch job that runs later. Triton namespaces the transaction-id key by user id so entries don't collide in the org-wide cache.
available()
The gatekeeper for withCache(). It probes Cache.Org and returns false if Org cache can't be reached (for example, when no Org cache capacity is allocated). This is what lets Triton degrade gracefully: no cache, no problem — logging continues without cross-context propagation.
When the cache is not available
Because Triton uses Org cache — which is not tied to a user session — cache-backed correlation works in interactive contexts (an LWC calling Apex, a user running a screen Flow) and in asynchronous ones (Batch, Queueable, Scheduled, @future, platform-event triggers). The cache is only "unavailable" when the org has no Org cache capacity allocated or the platform can't reach it.
Triton handles that case for you: withCache() checks available() first and, when the cache is out of reach, quietly falls back to a plain in-memory transaction for that Apex transaction. Nothing breaks; you simply don't get the automatic cross-transaction hand-off.
How the id travels: LWC → Apex → Flow
Putting the pieces together, here's the journey of a single transaction id through the canonical chain:
LWC generates a transaction id (UUID v4), stored in the browser's
sessionStorage, and tags every log with it viathis.triton.transactionId.When those logs flush,
TritonLwc.saveComponentLogscallsTriton.withCache(). If no id is cached for the user yet, it resumes the browser's id and copies it into platform Org cache; if one is already cached (within the TTL), the cached id wins.Your Apex controller calls
Triton.withCache()(orTriton.resumeTransaction(idFromLwc)if you passed it explicitly) and adopts the same id.The controller's DML fires an autolaunched Flow in the same Apex transaction. The Flow's Log action inherits
TRANSACTION_IDautomatically — no parameter needed.Flow logs are drained to
TritonFlowFlushBatchand published shortly after, still under the same id.
The result is one grouped trace in Pharos spanning all three technologies. The step-by-step controller and component code lives in the End-to-End walkthrough.
Quick reference
Related reading
End-to-End Logging — the full LWC → Apex → Flow walkthrough.
Spans & Distributed Tracing — structure within a transaction.
Buffering, Flushing & Deferred Publishing — how Flow logs reach the deferred batch via
drain().The Static Logging API — why the transaction id can live on a static field.
Last updated