|
| 1 | +# RTT Value Tracing and Investigation |
| 2 | + |
| 3 | +## RTT Journey Flow Diagram |
| 4 | + |
| 5 | +```mermaid |
| 6 | +graph TD |
| 7 | + A[Probe Service] -->|Measure RTT| B[CheckResult] |
| 8 | + B -->|RttMs| C[MonitoringBackgroundService] |
| 9 | + C -->|Update Endpoint| D[OutageDetectionService] |
| 10 | + D -->|Persist LastRttMs| E[StatusService] |
| 11 | + E -->|Serialize RTT| F[API Controller] |
| 12 | + F -->|Response| G[Frontend Service] |
| 13 | + G -->|Render| H[Frontend Components] |
| 14 | +
|
| 15 | + subgraph Potential Failure Points |
| 16 | + A -->|Null/Zero RTT| B |
| 17 | + B -->|Null RttMs| C |
| 18 | + C -->|Ignore Null RTT| D |
| 19 | + D -->|Skip Update| E |
| 20 | + E -->|Empty RTT| F |
| 21 | + F -->|Omit RTT| G |
| 22 | + G -->|Display Placeholder| H |
| 23 | + end |
| 24 | +``` |
| 25 | + |
| 26 | +## RTT Tracing Points |
| 27 | + |
| 28 | +### 1. Probe Service (`ProbeService.cs`) |
| 29 | +- **Probe Types**: |
| 30 | + - ICMP: Uses `reply.RoundtripTime` |
| 31 | + - TCP: Uses `stopwatch.ElapsedMilliseconds` |
| 32 | + - HTTP: Uses `stopwatch.ElapsedMilliseconds` |
| 33 | +- **Failure Handling**: |
| 34 | + - Sets `RttMs` to null on probe failures |
| 35 | + - Different measurement methods may introduce inconsistencies |
| 36 | + |
| 37 | +### 2. Background Monitoring Service |
| 38 | +- Logs RTT with trace: |
| 39 | + ```csharp |
| 40 | + _logger.LogTrace("Probed endpoint {EndpointId} ({Name}): {Status} in {RttMs}ms") |
| 41 | + ``` |
| 42 | +- Converts null RTT to "N/A" |
| 43 | + |
| 44 | +### 3. Outage Detection Service |
| 45 | +- Copies `result.RttMs` to new records |
| 46 | +- Potential loss point if RTT is null |
| 47 | + |
| 48 | +### 4. Status Service |
| 49 | +- Uses `endpoint.LastRttMs` to populate status responses |
| 50 | +- May return null/empty RTT |
| 51 | + |
| 52 | +### 5. Frontend Service and Components |
| 53 | +- Uses optional chaining and nullish coalescing |
| 54 | +- Handles null RTT with placeholders ('-') |
| 55 | + |
| 56 | +## Investigation Steps |
| 57 | + |
| 58 | +### 1. Probe Measurement Verification |
| 59 | +- [ ] Compare RTT measurements across different probe types |
| 60 | +- [ ] Add detailed logging in `ProbeService` |
| 61 | +- [ ] Verify stopwatch and `RoundtripTime` calculations |
| 62 | + |
| 63 | +### 2. Null Value Propagation Analysis |
| 64 | +- [ ] Trace null RTT through each service layer |
| 65 | +- [ ] Add comprehensive logging |
| 66 | +- [ ] Validate null handling in serialization |
| 67 | + |
| 68 | +### 3. API Contract Validation |
| 69 | +- [ ] Inspect API response DTOs |
| 70 | +- [ ] Check JSON serialization of RTT values |
| 71 | +- [ ] Verify optional/nullable field handling |
| 72 | + |
| 73 | +### 4. Frontend Parsing Investigation |
| 74 | +- [ ] Review TypeScript type definitions |
| 75 | +- [ ] Validate RTT parsing in API services |
| 76 | +- [ ] Test display logic for various RTT scenarios |
| 77 | + |
| 78 | +### 5. Comprehensive Test Scenarios |
| 79 | +- [ ] Successful probe with non-zero RTT |
| 80 | +- [ ] Failed probe (null RTT) |
| 81 | +- [ ] Edge cases: zero, very low, very high RTT values |
| 82 | +- [ ] Multiple probe type comparisons |
| 83 | + |
| 84 | +## Potential Improvement Recommendations |
| 85 | +- Standardize RTT measurement across probe types |
| 86 | +- Implement consistent null/zero RTT handling |
| 87 | +- Add more granular logging and tracing |
| 88 | +- Create comprehensive test suite for RTT propagation |
0 commit comments