insonl
← journal

Trace One AI Processed Order Across the Queue and ERP

date
27 November 2026
by
Insonl
read
8 min read

In this illustrative workflow, a customer emails a purchase order. An extraction worker calls a model and sends the result to an order clerk, who corrects a unit of measure and approves it. The posting worker sends the approved order to the ERP and times out. The clerk asks whether it is safe to try again. The queue acknowledgement and the successful model response leave that question open.

A platform lead needs two ways to follow the order. Start from the workflow record to see its current state and the evidence behind it. Open the traces for that record to see which worker acted, which dependency it called and where the handoff broke. The same lookup should work when a queue redelivers a message or a clerk returns to a review after a shift change.

Start the investigation from the order record

Assign a random internal workflow ID when intake accepts the purchase order. Keep it stable as the order moves between workers and through review. In the access-controlled workflow record, keep the state transitions and timestamps, the approved revision, the posting attempts and the ERP reference once verified. Give responders a way to open retained traces from that record. Store trace and span references for key handoffs as they happen, including the review task creation and posting attempts.

Define what counts as completion for this integration. In the example, the order is posted once the ERP confirms the committed sales order for the approved revision. An acknowledgement that the request was queued leaves the workflow in posting_pending. A timeout without a definitive outcome moves it to posting_unconfirmed. The application records these states even if there is no trace in the backend.

Give a posting operation its own stable idempotency key for the approved revision, where the integration supports it. Use that key again on retries of the same operation. Each delivery or outbound call can have a new span, while the internal workflow ID still identifies the case. The decisions that determine which revision is safe to post belong in the order workflow. From Customer PO Email to ERP Sales Order

Carry trace context through the queue

A span records one operation. OpenTelemetry’s Tracing API defines parent-child relationships within a trace and links between spans in the same or different traces. The Propagators API defines how to inject and extract context across process boundaries. Use these mechanisms for the queue handoff and for work that resumes later in a separate trace. OpenTelemetry Tracing API · OpenTelemetry Propagators API

For the single-message publish in this example, inject the publish span’s trace context into supported message metadata before sending. Check what your messaging library already injects and records before adding instrumentation. At the consumer, extract the context and link the processing span to it. OpenTelemetry’s messaging conventions use links by default. In single-message processing, the instrumentation may use the message context as the parent. Prefer the default link when a local span already covers the work. OpenTelemetry messaging span conventions

If the message has no usable trace context, record the propagation gap. Keep any valid local parent, or start a new trace if there is none. The worker can still resolve the case from the workflow ID in its message.

Record enqueue and processing-start timestamps so the responder can distinguish queue wait from work inside the consumer. On redelivery, give each processing attempt its own span. If the handler creates a fresh retry message, propagate that message’s creation context for the next delivery. For a batch that processes several independent orders together, give the batch span links to the available message contexts so one order’s producer does not appear to own the entire batch.

End the extraction work after the review task is recorded. Store the context for that handoff with the task. When the clerk submits the correction, link the span for that submission to the earlier handoff span. If the review service starts a separate trace, the link can cross the trace boundary. Use the task-created and review-submitted timestamps in the workflow record to calculate time waiting for review. The submission span measures the service work triggered by the clerk’s action.

Walk the illustrative order through a timeout

Use stable operation names and a small set of controlled values. The names below are illustrative application labels.

Operation What the responder looks for
Intake and queue publish Intake accepted the order and the publish operation succeeded. The workflow record has the intake timestamp and the enqueue timestamp.
Worker and model call A consumer started after the queue wait. Its outbound model span shows the dependency, call duration and response class. Validation then sent the case to review with a controlled reason code for an ambiguous unit.
Review submission The clerk corrected the unit of measure and saved an approved revision. The case record holds that revision and the review decision. The linked span shows when the submission service handled it.
ERP create call The outbound client span records the timeout. The workflow records posting_unconfirmed and keeps the posting key available for reconciliation.
ERP lookup The reconciliation worker finds the committed order by the original posting reference and verifies that it corresponds to the approved revision. The workflow records the confirmed ERP reference and moves to posted.

Instrument the outbound calls your services make even when the model provider and ERP return no spans. From your side you can see how long each request took, whether a response arrived and which application decision followed. Keep each dependency’s operation distinct, including the ERP create and read-back calls. An HTTP success for an asynchronous submission still needs a confirmed business outcome. If an ERP lookup is inconclusive, keep the outcome unconfirmed and send the case for reconciliation. Retry a write only when the integration can safely deduplicate it or you have reliable evidence that the original write did not commit.

Keep the order contents out of telemetry

Allow a small set of fields such as workflow stage, configured dependency name, operation, deployment version and a controlled result or error category. Keep the PO, extracted values, prompts, model output, clerk notes and ERP request and response bodies in the systems that already protect them. Review automatically captured URLs, headers and exception messages. A connector error may echo the rejected field value, and a URL path may contain the sales-order number. Keep outbound propagation to external services within the integration’s explicit trust policy and leave business identifiers out of baggage.

Store the trace references on the protected order record so operators can navigate without putting customer order numbers in the trace store. If the telemetry pipeline already has automatic instrumentation, inspect what it emits before export and use Collector filtering or attribute allowlisting as a secondary safeguard. Check span names and event data as well as attributes. OpenTelemetry’s sensitive-data guidance recommends minimizing capture and reviewing data emitted by instrumentation libraries. OpenTelemetry, Handling sensitive data

Test the lookup the responder will actually use

Run the illustrative case in a test environment where the ERP commits and the create response is lost. Start with the workflow ID and confirm that the responder can find intake, the extraction call, the review link, the ERP create call and the reconciliation lookup. Check that the late read-back records exactly one committed order and identifies the approved revision. Redeliver the queue message and verify that a new processing attempt is visible and cannot create a second order.

Repeat with broken queue propagation and with a trace that your sampling policy does not retain. The workflow record should still show the last confirmed business state. Check the exported telemetry with synthetic marker values in the document, prompt and ERP error body. Those markers should be absent while the dependency, timing and error category remain visible.

Sources

Audit one order workflow

Bring a map of one order flow and an example where the ERP outcome was unclear. Insonl can review where the workflow records completion and what evidence follows each handoff. The audit is free. Insonl charges for any subsequent work you commission. Request a free AI workflow audit