Correlation IDs connect logs and traces across a distributed request. A service that drops or regenerates the ID splits one incident into disconnected fragments.
Design a CorrelationIdPropagationAuditor class:
CorrelationIdPropagationAuditor() creates a stateless auditor.String[] brokenHops(...) returns every service whose propagation rule is broken, in input order.int firstBrokenHop(...) returns the first broken service index, or -1 when the chain is valid.
Arrays describe one ordered request path. At hop i:
receivedIds[i] must be non-empty.forwardedIds[i] must exactly equal receivedIds[i].- For
i > 0, receivedIds[i] must equal forwardedIds[i - 1].
A service is returned once if any applicable rule fails. A later service that consistently receives and forwards a regenerated ID is not automatically broken.
Example 1:
Input:
Output:
Explanation: Payments received xyz, which differs from the abc forwarded by orders. Its local receive-to-forward behavior alone would not reveal that broken boundary.
Example 2:
Input:
Output:
Explanation: Orders changes abc to def. Payments then receives exactly what orders forwarded and preserves it, so payments is not another broken hop.
Constraints
1 <= services.length == receivedIds.length == forwardedIds.length <= 10^5- Service names are unique non-empty lowercase strings.
- IDs contain printable characters and may be empty to represent lost context.
- ID comparison is exact and case-sensitive.
- Return broken services in input order without duplicates.
- At most
100 total method calls are made.