Summary
We need a globally unique, per-request correlation identifier generated by SimpleL7Proxy and forwarded to backend services for end-to-end tracing. The current x-S7P-ID format is useful for operational debugging but is not suitable as a durable correlation ID in multi-replica deployments (e.g. ECS).
Current behavior
On each inbound request, the proxy assigns:
| Identifier |
Format |
Forwarded to backend? |
MID → x-S7P-ID |
{RequestIDPrefix}-{replicaId}-{sequentialCounter} (e.g. S7P-abc12345-847) |
Yes |
| Guid |
Guid.NewGuid() (internal) |
No (telemetry/async only) |
replicaId = CONTAINER_APP_REPLICA_NAME if set, else Hostname
- Counter is sequential per process/task and resets to 1 on restart/redeploy
Relevant code paths:
- MID generation:
server.cs — IDStr + counter
- Header enrichment:
EventDataBuilder.EnrichRequestHeaders() — sets x-S7P-ID
- Backend forward:
ProxyWorker → ProxyHelperUtils.CopyHeaders()
Problem
1. Uniqueness / counter reset
After an ECS task restart, the counter resets:
Before restart: S7P-abc12345-847
After restart: S7P-abc12345-1
The same x-S7P-ID value can appear again over time for the same Hostname, which breaks long-lived or persisted correlation in downstream systems.
2. Collision risk across replicas
If multiple tasks share the same Hostname, they can emit identical IDs in parallel (e.g. two tasks both sending S7P-llm-proxy-prod-1).
3. User profiles do not address this
UserProfileHeader / user profile JSON provides static per-user configuration. It does not generate a dynamic per-request correlation ID.
Expected behavior (baseline request)
Provide a GUID-based correlation ID per request that is:
- Generated by the proxy when the request is accepted (or when missing from the client)
- Globally unique across replicas, restarts, and time
- Forwarded to the backend on every proxied request
- Included in proxy telemetry/logs (CloudWatch / App Insights) for cross-system lookup
Suggested approach (open to contractor design)
- Use the existing internal
Guid (rd.Guid) or generate a new UUID per request
- Expose it on a standard header forwarded to backend, e.g.:
X-Correlation-ID, and/or
x-ms-client-request-id (already referenced in APIM policies)
- Optionally retain
x-S7P-ID for infrastructure traceability (replica + local sequence), but correlation for backend persistence should be the GUID
Deployment context
- Platform: AWS ECS (Fargate), multiple tasks behind ALB
- Add-in: AWS 2.2.11.2
- Identity segment today:
Hostname in task definition (or container HOSTNAME fallback)
- Not available on ECS:
CONTAINER_APP_REPLICA_NAME (ACA-specific)
ECS examples (current x-S7P-ID behavior)
Good configuration — unique Hostname per task
| ECS Task |
Hostname |
Request # |
x-S7P-ID |
| Task A |
a1b2c3d4e5f6 |
1 |
S7P-a1b2c3d4e5f6-1 |
| Task A |
a1b2c3d4e5f6 |
847 |
S7P-a1b2c3d4e5f6-847 |
| Task B |
f6e5d4c3b2a1 |
1 |
S7P-f6e5d4c3b2a1-1 |
| Task C |
9z8y7x6w5v4u |
1 |
S7P-9z8y7x6w5v4u-1 |
Misconfigured — same Hostname on all tasks
| Task |
Request # |
x-S7P-ID |
| Task A |
1 |
S7P-llm-proxy-prod-1 |
| Task B |
1 |
S7P-llm-proxy-prod-1 (collision) |
| Task C |
15 |
S7P-llm-proxy-prod-15 |
Acceptance criteria
References
- Internal analysis: sequential
x-S7P-ID on ECS and uniqueness limits (counter reset, shared Hostname collisions)
- Docs:
docs/REQUEST_VALIDATION.md (RequiredHeaders=X-Correlation-ID as client-side pattern only today)
- APIM policy maps
x-S7P-id → x-ms-client-request-id (Azure path)
Summary
We need a globally unique, per-request correlation identifier generated by SimpleL7Proxy and forwarded to backend services for end-to-end tracing. The current
x-S7P-IDformat is useful for operational debugging but is not suitable as a durable correlation ID in multi-replica deployments (e.g. ECS).Current behavior
On each inbound request, the proxy assigns:
x-S7P-ID{RequestIDPrefix}-{replicaId}-{sequentialCounter}(e.g.S7P-abc12345-847)Guid.NewGuid()(internal)replicaId=CONTAINER_APP_REPLICA_NAMEif set, elseHostnameRelevant code paths:
server.cs—IDStr + counterEventDataBuilder.EnrichRequestHeaders()— setsx-S7P-IDProxyWorker→ProxyHelperUtils.CopyHeaders()Problem
1. Uniqueness / counter reset
After an ECS task restart, the counter resets:
The same
x-S7P-IDvalue can appear again over time for the sameHostname, which breaks long-lived or persisted correlation in downstream systems.2. Collision risk across replicas
If multiple tasks share the same
Hostname, they can emit identical IDs in parallel (e.g. two tasks both sendingS7P-llm-proxy-prod-1).3. User profiles do not address this
UserProfileHeader/ user profile JSON provides static per-user configuration. It does not generate a dynamic per-request correlation ID.Expected behavior (baseline request)
Provide a GUID-based correlation ID per request that is:
Suggested approach (open to contractor design)
Guid(rd.Guid) or generate a new UUID per requestX-Correlation-ID, and/orx-ms-client-request-id(already referenced in APIM policies)x-S7P-IDfor infrastructure traceability (replica + local sequence), but correlation for backend persistence should be the GUIDDeployment context
Hostnamein task definition (or containerHOSTNAMEfallback)CONTAINER_APP_REPLICA_NAME(ACA-specific)ECS examples (current x-S7P-ID behavior)
Good configuration — unique Hostname per task
a1b2c3d4e5f6S7P-a1b2c3d4e5f6-1a1b2c3d4e5f6S7P-a1b2c3d4e5f6-847f6e5d4c3b2a1S7P-f6e5d4c3b2a1-19z8y7x6w5v4uS7P-9z8y7x6w5v4u-1Misconfigured — same Hostname on all tasks
S7P-llm-proxy-prod-1S7P-llm-proxy-prod-1(collision)S7P-llm-proxy-prod-15Acceptance criteria
x-S7P-IDandParentId)References
x-S7P-IDon ECS and uniqueness limits (counter reset, sharedHostnamecollisions)docs/REQUEST_VALIDATION.md(RequiredHeaders=X-Correlation-IDas client-side pattern only today)x-S7P-id→x-ms-client-request-id(Azure path)