Illustrative scenario, not a report of a real deployment. This article was produced with AI assistance as a draft; no code was executed and no deployment was observed.

Consider a document-processing job that moves from a hosted endpoint to a self-hosted model behind a gateway. The cutover can look clean: trace dashboards show successful child spans. The risk is that the output queue later contains duplicates. Nothing in the traces is red, but traces were never designed to answer whether a downstream write was applied once, twice, or not at all.

The practical point: retries and idempotency, not tracing, decide whether work happens twice. Tracing can show where retries happened and whether the retrying party was instrumented.

A timeout is an ambiguous answer

A timeout tells you the caller gave up. It does not tell you whether the dependency stopped working or whether it applied the write before the connection dropped. Those are different facts. A timeout alone is not permission to retry.

Per RFC 9110, HTTP idempotency concerns the intended effect on the server, and responses to repetitions can differ. A non-idempotent request should be retried automatically only when you know its semantics permit replay or that the original was never applied (RFC 9110 §9.2.2). In practice, that means you need either an idempotent operation, a dedupe mechanism, or a read-back that confirms the original did not land.

When you swap a hosted endpoint for something you control, you can change three things at once:

  • who owns the retry loop (SDK, gateway, or job runner);
  • what the per-attempt timeout is;
  • whether an idempotency key survives the swap.

If any of those moves without being written down, the duplicate rate can change even if the success rate looks unchanged.

What a trace can and cannot settle

Per the OpenTelemetry documentation, a span describes one operation with a span ID, trace ID, timestamps, and optional attributes or events; a parent span ID relates a child to its parent inside the trace. A trace describes instrumented work. It is not proof of external delivery (OpenTelemetry traces).

That matters because a child span with status OK means your instrumentation recorded a completed operation. It does not prove the downstream system applied the write once, twice, or not at all before the connection dropped.

The invisible fan-out

There is a subtler problem. If retries move into your gateway but the gateway does not export spans, your client-side trace can show one attempt. The amplification still exists; the evidence is missing.

The custody register

Before changing anything, write down who owns each concern. 'Both' is not an answer.

Concern Client-side retries Gateway / self-hosted retries Risk if undefined
Retry loop owner SDK or job runner Gateway in front of the model Two loops multiply attempts
Per-attempt timeout Caller config Gateway config Worst case exceeds caller deadline
Backoff + jitter Library default Gateway policy Lockstep retries under load
Idempotency key Generated and sent by client Must be forwarded, not regenerated Downstream cannot dedupe
Evidence of effect Application read-back Gateway logs or read-back Green spans, unknown truth

Each blank cell is a decision made by accident.

A five-step approach

1. Start from the caller deadline, not the retry count

Retry counts are a symptom. The deadline is the constraint.

Worked arithmetic with hypothetical config: 2s per-attempt timeout, 3 attempts, backoff base 0.3s, cap 1s, caller budget 8s.

  • Worst case without jitter: 2 + 0.3 + 2 + 0.6 + 2 = 6.9s.
  • Worst case with backoff pinned at the 1s cap: 2 + 1 + 2 + 1 + 2 = 8s.

The second line consumes the entire caller budget. The caller has no time left for post-processing, so it can hit its own timeout, and that failure may look like a different bug.

Reserve headroom. A practical heuristic is to budget less than the full deadline for the dependency; the exact fraction is a policy choice. If you use 80% of an 8s deadline, the dependency budget is 6.4s. The config above is then too large: drop to two attempts, or reduce the per-attempt timeout to about 1.4s if the 1s cap is retained. The arithmetic is the check, not a performance claim.

2. Choose one backoff distribution and document it

Backoff spaces attempts out. Jitter reduces clients retrying in lockstep, which matters most when the dependency is already struggling. Neither mechanism proves that the preceding call had no side effects (AWS Builders' Library: timeouts, retries, and backoff with jitter). Retries also add load to an overloaded dependency.

Pick one distribution, write it into the custody register, and do not treat it as a safety property it is not.

3. Propagate an idempotency key that you do not regenerate

The edge case that bites: the client generates a key, the gateway retries, and the gateway builds a new key per attempt. The downstream system now has three distinct requests that are semantically one.

The key must be stable across attempts. Record a hash of the key in telemetry, not the key itself, and never put document content into span attributes.

An observation-based test for key propagation: use a non-production document, a stable job ID and chunk index, a gateway retry policy, and a downstream store that records the idempotency key it receives. Observe the number of downstream records, the key values, and the spans emitted by the gateway and client. If you see one record with the same key, dedupe is working in that path. If you see multiple records with different keys, the retrying layer regenerated the key. If you see multiple records with the same key, the downstream did not dedupe, or its dedupe was not atomic. Interpret a mismatch by fixing the layer that owns the key, not by adding more retries.

Stripe's API v1 is one concrete example of why the header alone is not a universal guarantee: it stores the result once endpoint execution begins, even for a 500; it compares parameters when a key is reused; and reusing a pruned key starts a new request. Those are Stripe v1 semantics, not a property of sending an idempotency header to any service (Stripe idempotent requests).

4. Mark ambiguous outcomes explicitly

A timeout should be recorded as ambiguous, not as a plain error. The distinction matters: error invites a retry, ambiguous invites a read-back first. That is a design convention, not a guarantee that every consumer of the trace will honor it.

5. Add a read-back verification step

After a retry of an ambiguous call, read the downstream state before assuming anything:

  • Does the record exist already?
  • Does its idempotency key match yours?
  • Was it written by attempt 1 or attempt 3?

If the downstream cannot answer those questions, the retry policy is ahead of the system's ability to reconcile it.

Proposed checks for whether the swap changed anything

These checks are described, not performed. Run them against your own data.

  1. Amplification ratio. Group spans by trace ID and count children per logical operation. A ratio above 1 suggests retries or duplicate instrumentation. A jump after the cutover may indicate a custody change, but confirm it against retry config and read-back; the ratio alone does not prove ownership moved.
  2. Unconfirmed-retry count. Query for spans where retry.attempt > 1 and no matching confirmation record exists within the deadline window.
  3. Trace coverage of the retrying party. Confirm that whichever component owns the retry loop emits spans at all. If the gateway is silent, checks 1 and 2 measure only the client side.
  4. Deadline overruns. Look for parent spans that end after the declared caller budget. That is arithmetic you can audit, not a performance claim.

Failure modes to watch for

  • Two loops. Client and gateway both retry. Attempts multiply instead of adding.
  • Key regeneration. The retrying layer mints a fresh idempotency key per attempt.
  • Error/ambiguous conflation. Timeouts get retried instead of reconciled.
  • Silent fan-out. Retries move to a component that exports no traces.
  • Jitter as an excuse. Teams cite jitter to justify retry counts they never budgeted against the deadline.

When this does not apply

Reads, pure lookups, and genuinely idempotent operations do not need the key machinery. Retrying is cheap when a repeat has no side effect. Skip the read-back step when you have no persistent store and no dedupe surface downstream; in that case the honest move is to reduce attempts, not to add reconciliation you cannot complete.

If your downstream cannot dedupe at all, no retry policy will save you. One attempt plus a clear failure is a defensible architecture.

The break-even to write down

Retries pay for themselves when the expected value of a rescued call exceeds the expected cost of a duplicate side effect:

p_transient × value(saved_success) > p_ambiguous × cost(duplicate)

Illustrative fill: 0.08 × 1 unit > 0.02 × 5 units gives 0.08 > 0.10, which is false. In that configuration, retrying without dedupe is a net loss. Change cost(duplicate) to 1 unit and the inequality flips. That flip, not the retry count, is the decision. The numbers are hypothetical.

What would reverse this

If duplicate cost is near zero and transient failure rate is high, more retries may be reasonable, subject to load and idempotency. If the opposite is true, the interesting question is not how many retries but which single variable — duplicate cost, deadline, or key stability — are we willing to change? Answer that before adjusting the config.

Drafting note: This article was produced with AI assistance as a draft. The examples are illustrative prose; no code was executed and no deployment was observed. The arithmetic examples are hypothetical configurations, not measurements. A human should verify the technical claims, check the linked primary sources, and confirm the destination platform's current policy before any public posting.

Sources: OpenTelemetry — Traces; AWS Builders' Library — Timeouts, retries, and backoff with jitter; RFC 9110 §9.2.2 — Idempotent methods; Stripe — Idempotent requests.