Commit 52600bc
authored
processor/tailsampling: stabilize TestDropLargeTraces metric assertions (#46283)
## Description
Fixes #46154
This PR fixes flakiness in `TestDropLargeTraces` within the tail
sampling processor tests.
The test validates that traces exceeding `MaximumTraceSizeBytes` are
dropped and that the correct metrics are emitted. While the sampling
behavior itself is deterministic, metric assertions were intermittently
failing in CI environments.
---
## Root Cause
Metrics in the tail sampling processor are recorded asynchronously via
the OpenTelemetry Metrics SDK.
The test previously performed metric collection synchronously using:
```go
telem.reader.Collect(...)
```
In slower CI environments, metric aggregation had not fully completed at
collection time, leading to intermittent missing datapoints and
assertion failures.
Locally, the test passed consistently due to faster execution timing.
Affected metrics:
- `otelcol_processor_tail_sampling_sampling_trace_dropped_too_early`
- `otelcol_processor_tail_sampling_traces_dropped_too_large`
---
## Fix
Metric collection and assertions are now wrapped in
`require.EventuallyWithT` to account for asynchronous aggregation.
### Key changes
- Retry metric collection for up to **2 seconds**
- Poll interval of **100ms**
- Assertions execute once datapoints stabilize
- Ensures deterministic validation across environments
The retry window aligns with async metric stabilization patterns used in
existing collector tests.
---
## Scope
- **Test-only change**
- No processor logic modified
- No sampling behavior changes
- No production code impact
---
## Testing
Validation performed:
- Repeated local runs (`-count=20`)
- Full module test suite execution
- No regressions observed
All tests pass consistently after stabilization.
---
## Notes
The fix preserves strict metric validation while making the test
resilient to async metric pipeline timing differences between local and
CI environments.1 parent 34b44aa commit 52600bc
1 file changed
Lines changed: 59 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
1277 | 1276 | | |
1278 | 1277 | | |
1279 | 1278 | | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
1283 | | - | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
1290 | | - | |
1291 | | - | |
1292 | | - | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
1293 | 1296 | | |
1294 | 1297 | | |
1295 | | - | |
1296 | | - | |
1297 | | - | |
1298 | | - | |
1299 | | - | |
1300 | | - | |
1301 | | - | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
1306 | | - | |
1307 | | - | |
1308 | | - | |
1309 | | - | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
1310 | 1324 | | |
1311 | 1325 | | |
1312 | | - | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1316 | 1342 | | |
1317 | 1343 | | |
1318 | 1344 | | |
| |||
0 commit comments