Designing Distributed Integration Tracing with GUID, UUID, HOP, and SEQ
Debugging a distributed Integration is not a matter of finding one log line. A request enters through a Listener, crosses a Mapper and an Adapter, and returns as a response or error while several processes and retries may participate. If each component creates a different request ID, it becomes impossible to decide which records belong to the same business flow.
This article distinguishes and propagates GUID, UUID, HOP, and SEQ in an Integration Runtime. The examples use an anonymized inventory synchronization flow; payload and endpoint information are limited to what is needed for explanation.
Why split trace identity into four fields
Section titled “Why split trace identity into four fields”One identifier cannot express retries and fan-out cleanly.
| Field | Meaning | Creation and change rule |
|---|---|---|
guid | Correlation key for one business exchange | Created once by the first Listener or batch and retained end to end |
uuid | Unique key for one log event or delivery attempt | Created when an event is recorded; a retry may have a new value |
hop | Position across logical Integration boundaries | Incremented by one at each logical component and never reset by a process restart |
seq | Event order within one guid | Incremented by one for every recorded event |
guid searches for “all traces of this request,” while uuid identifies “this one record.” hop represents the logical location and seq represents recording order. Do not infer order from timestamps alone or group a Trace using uuid alone.
What matters is that the two increment at different granularity. When one hop records several events, hop stays put and only seq advances. Conversely, a record that skips seq values while bumping hop breaks the rule, and the diagram below follows the rule exactly.
Trace propagation flow
Section titled “Trace propagation flow”hop advances continuously as 0, 1, 2, 3 only when crossing a logical component, while seq advances 1, 2, 3 with no gaps for every recorded event. hop=2 repeating twice in the Adapter section is intentional, not an error: two events (TXST and TXEN) are recorded inside the same logical boundary.
A boundary creates a new event uuid but retains the guid. hop should represent a logical boundary, not a process name. If every internal function call increments hop, query results become coupled to implementation details.
Projecting one fictional inventory-sync-v1 request into an operations view produces the minimal sequence below. Every row shares one guid and has a distinct uuid; hop changes only when the flow crosses a logical component.
| seq | eventType | component | hop | Observed fact |
|---|---|---|---|---|
| 1 | IFST | Listener | 0 | Received an inventory-sync request and started the Trace |
| 2 | SEND | Mapper / Producer | 1 | Sent the canonical message |
| 3 | TXST | Adapter | 2 | Started the target inventory transaction |
| 4 | TXEN | Adapter | 2 | Received the target response and ended the transaction |
| 5 | RECV | Listener / Consumer | 3 | Received the correlated result message |
| 6 | IFEN | Listener | 3 | Completed the caller response and ended the Interface |
The event order for this request is therefore IFST → SEND → TXST → TXEN → RECV → IFEN. TXST and TXEN share a hop, as do RECV and IFEN, because each pair records start/end events inside one component. A Runtime may add bus-consume or retry events, but it should insert their new seq and uuid values at the appropriate point without violating this base order.
Common envelope and structured log
Section titled “Common envelope and structured log”Separate business payload from observability Metadata. This keeps Runtime Metadata without changing an external Contract.
The envelope below is exactly the TXST step in the diagram above, where the Adapter invokes the Target at hop=2, seq=4.
{ "meta": { "guid": "g-demo-7f2c", "uuid": "u-demo-0004", "seq": 4, "hop": 2, "interfaceId": "inventory-sync-v1", "eventType": "TXST", "occurredAt": "2024-03-18T09:30:00Z" }, "payload": { "itemId": "ITEM-2042", "quantity": 3 }}A normalized log schema should keep at least time, appName, eventType, guid, uuid, hop, seq, interfaceId, statusCode, and message as fixed fields. message may contain JSON or XML, but searchable fields must not be hidden inside a string. Store only required fields or a hash instead of the complete payload, and mask tokens, cookies, and personal data.
Typical event types map directly to Runtime stages:
| eventType | Meaning | Example boundary |
|---|---|---|
IFST / IFEN | Interface receive start/end | Listener |
TXST / TXEN | Target transaction start/end | Adapter |
SEND / RECV | Message delivery/receipt | Bus or connector |
ERR | Exception and normalized error | Any boundary |
Creation and propagation rules
Section titled “Creation and propagation rules”- The first entry point creates a cryptographically random
guid. Validate an incoming correlation header and preserve it as a separateparentCorrelationId; do not blindly replace the internalguid. - Create a
uuidfor every event. A retry keeps the sameguid, uses a newuuid, and incrementsattempt. - Increment
hopwhen the envelope crosses a logical component. Do not increment it again in exception handling, so the location of an error event stays stable. seqmust increase without gaps inside oneguid. That requirement is more expensive in a distributed system than it looks, and the next section covers it separately.- When both producer and consumer log, represent the relationship with
parentUuidrather than reusing the same event. This distinguishes delivery attempts from consumption.
Do not confuse guid with a business idempotency key. Whether a repeated business operation is allowed must be decided by a separate key and the destination’s side-effect policy.
Incrementing seq in a distributed system
Section titled “Incrementing seq in a distributed system”A process-local counter for seq collides or moves backwards the moment one guid crosses several pods. There are three realistic options, and they differ in latency, storage cost, and failure behaviour.
| Option | Latency | Storage cost | Failure behaviour |
|---|---|---|---|
| Store atomic sequence | One network round trip per event. Typically 1–3 ms in the same zone, more across zones | The counter itself is tiny, but a per-guid counter makes key count scale with event count | If the store is down, the business path stalls with it. Proceeding after a timeout to avoid that reintroduces gaps anyway |
| Producer partition offset | No extra call. It reads the result of an append that already happened, so effectively zero | Nothing extra to store; the broker already retains offsets | Resilient to broker restarts, but the value is monotonic only within a partition. Once a guid crosses partitions or topics it is not a global order |
Per-guid monotonic allocator | Near zero when the allocator is in-process; identical to an atomic sequence when it is remote | State must be held for every in-flight guid, requiring TTL and cleanup | An allocator restart loses the counter for those guid values. Making the state durable fixes that and immediately costs the same as the first option |
All three add a synchronous dependency to the business path in exchange for an exact global order. A Trace exists for observability and is not a business success condition, so ask first whether that price is worth paying.
The pragmatic alternative is to declare seq best-effort. Each component emits a value monotonic only within itself, and queries sort by (hop, time) as the primary key. hop guarantees the order of logical boundaries and therefore orders events across components, while time orders events inside the same hop. seq is used only as a tie-breaker within the same hop and identical timestamp.
This exposes ordering to clock skew, but with working NTP the error inside a single hop is usually negligible, and events in different hops never compare time in the first place. Most importantly it adds nothing to the business path. A mixed strategy (an atomic sequence for the few Interface flows that genuinely need an exact global order, best-effort everywhere else) is usually the most reasonable answer.
OpenSearch query model
Section titled “OpenSearch query model”A Trace API first narrows candidates by guid and time range, then limits eventType. A detail view queries one guid with ascending hop and time pagination. A recent-flow view filters by interfaceId, then uses a terms aggregation by guid.
A guid bucket can calculate the min start time, the max end time, a top_hits last event, and sub-aggregations for event and error counts. A dashboard nests these buckets under interfaceId to calculate total count, error count, latency, and TPM.
{ "query": { "bool": { "filter": [ { "terms": { "interfaceId": ["inventory-sync-v1"] } }, { "range": { "time": { "gte": "2024-03-18T00:00:00Z", "lt": "2024-03-19T00:00:00Z" } } } ] } }, "aggs": { "by_guid": { "terms": { "field": "guid" }, "aggs": { "first": { "min": { "field": "time" } }, "last": { "top_hits": { "sort": [{ "time": "desc" }], "size": 1 } }, "errors": { "filter": { "term": { "eventType": "ERR" } } } } } }}How time relates to @timestamp
Section titled “How time relates to @timestamp”This query uses time for a reason that ties directly to the collection configuration. Because the Fluent Bit parser declares Time_Key time, the timestamp string written by the application is read from the time field and promoted to the record timestamp. When the OpenSearch output has Logstash_Format On, that record timestamp is written to the @timestamp field and simultaneously selects the date suffix of the index name.
So time is when the application produced the event, and @timestamp is the standard time field derived from it. On the healthy path they point at the same instant. If parsing fails or Time_Format does not match, however, Fluent Bit substitutes the collection time, and @timestamp slips forward by the ingestion delay. Keeping the original time field in the mapping lets you detect that divergence by comparing the two directly.
In practice it is safest to use @timestamp for dashboard time axes and index selection, and time for business flow ordering and latency calculation. Whichever you pick, fix one choice across the whole model and never mix the two fields inside a single query.
Aggregations are convenient, but high cardinality and bucket counts increase memory and shard cost. Restrict the time range, apply the Interface filter first, and consider composite aggregation for deep bucket pagination. Do not hide shard failures behind a successful response; return an explicit API error. Designing OpenSearch Hot/Cold Storage and Index Lifecycles on Kubernetes covers how templates, backing indexes, and retention determine query-result availability.
Failure and operating rules
Section titled “Failure and operating rules”- An event without
guidis excluded from the normal Trace and counted by a quarantine Metrics value. - A reversed
seqmay result from network delay or from the best-effort policy above, so distinguish storage order from business order. Validate by readinghopfirst andtimesecond. - Do not put oversized error messages directly in the search index. Apply a size limit and use an object reference plus a redacted summary.
- Store timestamps in UTC and apply the user’s timezone only when rendering a dashboard.
- Keep logging backpressure separate from the business path so ingestion failure does not block a business call. Expose a drop counter as an Alert target rather than hiding Trace loss.
Summary
Section titled “Summary”guid represents a business flow, uuid an event, hop a logical boundary, and seq order within the flow. Propagating these fields in a fixed schema and storing structured events makes Listener, Mapper, Adapter, batch, and message boundaries queryable as one Trace. Global monotonicity for seq is an expensive requirement, so leave it best-effort for most Interface flows and first confirm that (hop, time) ordering is sufficient. In OpenSearch, separate guid-focused detail queries from interfaceId and time-based aggregations to achieve both performance and operational visibility.