gnodet opened a new pull request, #24591: URL: https://github.com/apache/camel/pull/24591
## Summary Fixes [CAMEL-23993](https://issues.apache.org/jira/browse/CAMEL-23993). `SpanPropagationUpstreamTest` is flaky (~20% failure rate on Develocity, 35/175 runs) across all telemetry modules. The root cause is that `SpanComparator` sorts spans only by `startEpochNanos`. When multiple spans start in the same nanosecond (common on fast CI systems), the sort is non-deterministic relative to the creation order that test assertions expect. **Root cause:** Java's `TimSort` is stable, so when start times tie it preserves the `InMemorySpanExporter` insertion order — which is *end-order* (innermost/leaf spans end first). This reverses the expected hierarchy (parent-first) ordering that `spans.get(0)`, `spans.get(1)`, etc. assume. **Fix:** Add `endEpochNanos` descending as a secondary sort key. Parent spans always end after their children, so this deterministically places parents first when start times tie. Additionally fixes an integer overflow bug in the mock-based comparators (camel-telemetry, camel-telemetry-dev) that used `(int)(longA - longB)` instead of `Long.compare()`. ### Changed files (4) - `components/camel-micrometer-observability/.../CamelOpenTelemetryExtension.java` - `components/camel-opentelemetry2/.../CamelOpenTelemetryExtension.java` - `components/camel-telemetry/.../mock/MockTrace.java` - `components/camel-telemetry-dev/.../DevTrace.java` ## Test plan - [x] `SpanPropagationUpstreamTest` passes across all 4 modules (camel-telemetry, camel-telemetry-dev, camel-micrometer-observability, camel-opentelemetry2) - [x] Full test suite passes for camel-telemetry (155 tests) and camel-telemetry-dev (13 tests) - [ ] 100x repetition of SpanPropagationUpstreamTest with 0 failures (running) - [ ] CI green _Claude Code on behalf of gnodet_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
