← Back to Pull requests

fix(latency-reporter): skip TTFT and TPOT on inverted timestamps #4029

Closed
unknown closed this pull request without merging on Nov 07, 2026 22:10 UTC
View on GitHub
unknown unknown commented on Nov 06, 2026 01:26 UTC
Author

What type of PR is this?
/kind bug

What this PR does / why we need it:
latency-reporter checks !IsZero() on ReceivedTimestamp, FirstTokenTimestamp, and CompleteTimestamp before observing llm_d_epp_latency_ttft_seconds and llm_d_epp_latency_tpot_seconds. Without a timestamp ordering check, inverted or equal timestamps produce a negative or zero duration in the histograms, whereas RecordRequestTTFT and RecordRequestTPOT in pkg/epp/metrics/metrics.go require strictly positive elapsed time via .After(...) and compute per-token duration in floating-point seconds.

Require response.FirstTokenTimestamp.After(response.ReceivedTimestamp) before recording TTFT, and require both response.FirstTokenTimestamp.After(response.ReceivedTimestamp) and response.CompleteTimestamp.After(response.FirstTokenTimestamp) in meanTPOT, returning the mean gap in float64 seconds.

The review playbook (docs/review/) caught this bug on PR #3715.

Which issue(s) this PR fixes:
N/A

Release note _(write NONE if no user-facing change)_:
``release-note
latency-reporter skips TTFT and TPOT histogram observations when response timestamps are inverted or equal.
`

Test plan:

  • Verify that completed streaming requests with a positive TTFT duration and a non-positive decode duration record TTFT without recording TPOT, while incrementing llm_d_epp_latency_requests_total.

  • Verify that completed streaming requests with a non-positive TTFT duration record neither TTFT nor TPOT, while incrementing llm_d_epp_latency_requests_total`.
  • Diff: 198 lines (+148 / -50) across 2 files Reviewer: ahg-g Review duration: 2683m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.41) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.41 · 198 lines diff across 2 files
    0.41
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.317
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #4029"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 41.1% (MEDIUM) · Higher = larger blast radius
    41.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%