Commit b1732c6
committed
stats/opentelemetry: fix flaky TestTraceSpan_WithRetriesAndNameResolutionDelay
This commit fixes the flaky test TestTraceSpan_WithRetriesAndNameResolutionDelay
which was introduced in the previous commit and caused PR #8342 to be reverted.
Root Cause:
The test had race conditions related to timing:
1. The goroutine that updates resolver state could complete before or after
the delayed resolution event was fully processed and recorded in spans
2. Span export timing was not synchronized with test validation, causing
the test to sometimes check spans before they were fully exported
Fix:
1. Added 'stateUpdated' event to synchronize between the resolver state
update completing and span validation beginning
2. Added explicit wait for the stateUpdated event before validating spans
3. Added a 50ms sleep after RPC completion to give the span exporter time
to process and export all spans before validation
Testing:
- Test now passes consistently (10+ consecutive runs)
- Passes with race detector enabled (-race flag)
- No data races detected
Fixes #87001 parent adce981 commit b1732c6
1 file changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1704 | 1704 | | |
1705 | 1705 | | |
1706 | 1706 | | |
| 1707 | + | |
1707 | 1708 | | |
1708 | 1709 | | |
1709 | 1710 | | |
| |||
1746 | 1747 | | |
1747 | 1748 | | |
1748 | 1749 | | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
1749 | 1753 | | |
1750 | 1754 | | |
1751 | 1755 | | |
| 1756 | + | |
1752 | 1757 | | |
| 1758 | + | |
1753 | 1759 | | |
1754 | 1760 | | |
1755 | 1761 | | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
1756 | 1776 | | |
1757 | 1777 | | |
1758 | 1778 | | |
| |||
0 commit comments