Skip to content

Designing Distributed Integration Tracing with GUID, UUID, HOP, and SEQ

Interactive Diagram

새 탭 ↗

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.

One identifier cannot express retries and fan-out cleanly.

FieldMeaningCreation and change rule
guidCorrelation key for one business exchangeCreated once by the first Listener or batch and retained end to end
uuidUnique key for one log event or delivery attemptCreated when an event is recorded; a retry may have a new value
hopPosition across logical Integration boundariesIncremented by one at each logical component and never reset by a process restart
seqEvent order within one guidIncremented 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.

PlantUML Diagram

Two requests between the frontend and product catalog services, showing trace ID and parent ID carried in the traceparent header Source: OpenTelemetry docs, Context propagation, The OpenTelemetry Authors, CC BY 4.0

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.

seqeventTypecomponenthopObserved fact
1IFSTListener0Received an inventory-sync request and started the Trace
2SENDMapper / Producer1Sent the canonical message
3TXSTAdapter2Started the target inventory transaction
4TXENAdapter2Received the target response and ended the transaction
5RECVListener / Consumer3Received the correlated result message
6IFENListener3Completed 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.

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:

eventTypeMeaningExample boundary
IFST / IFENInterface receive start/endListener
TXST / TXENTarget transaction start/endAdapter
SEND / RECVMessage delivery/receiptBus or connector
ERRException and normalized errorAny boundary
  1. The first entry point creates a cryptographically random guid. Validate an incoming correlation header and preserve it as a separate parentCorrelationId; do not blindly replace the internal guid.
  2. Create a uuid for every event. A retry keeps the same guid, uses a new uuid, and increments attempt.
  3. Increment hop when the envelope crosses a logical component. Do not increment it again in exception handling, so the location of an error event stays stable.
  4. seq must increase without gaps inside one guid. That requirement is more expensive in a distributed system than it looks, and the next section covers it separately.
  5. When both producer and consumer log, represent the relationship with parentUuid rather 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.

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.

OptionLatencyStorage costFailure behaviour
Store atomic sequenceOne network round trip per event. Typically 1–3 ms in the same zone, more across zonesThe counter itself is tiny, but a per-guid counter makes key count scale with event countIf the store is down, the business path stalls with it. Proceeding after a timeout to avoid that reintroduces gaps anyway
Producer partition offsetNo extra call. It reads the result of an append that already happened, so effectively zeroNothing extra to store; the broker already retains offsetsResilient 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 allocatorNear zero when the allocator is in-process; identical to an atomic sequence when it is remoteState must be held for every in-flight guid, requiring TTL and cleanupAn 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.

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" } } }
} } }
}

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.

  • An event without guid is excluded from the normal Trace and counted by a quarantine Metrics value.
  • A reversed seq may result from network delay or from the best-effort policy above, so distinguish storage order from business order. Validate by reading hop first and time second.
  • 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.

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.