console analytics: round 2 P2s, and the Overview's request budget
- The Overview waits for the traffic card only until 300 ms after the request started (perf.Started, trafficWait), not a grace after the rest. - "Busiest hour so far" skips hours after the current one, as the chart does. - CI: the card's reads went past the perf session's S3 ceiling and the region-label baseline. Its counts are now held a minute (analyticsMemo, Overview only; the tab and the CLI read fresh, and the setting is read every view), and both baselines name the card's remaining reads. Findings: docs/superpowers/reviews/CODEX-FINDINGS-console-analytics-ui-R2.md (READY AFTER FIXES; both P2s fixed here, no round 3).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/reviews/CODEX-FINDINGS-console-analytics-ui-R2.md+21 −0internal/console/analyticsdisplay.go+5 −0internal/console/analyticsdisplay_test.go+45 −3internal/console/analyticsview.go+96 −8internal/console/regionbudget_test.go+8 −5internal/console/server.go+23 −9internal/console/testdata/perf-session-s3.txt+1 −1internal/perf/middleware.go+10 −0internal/perf/middleware_test.go+17 −0
CI failed — run details
Intent
<task-notification> <task-id>b17qeivxq</task-id> <tool-use-id>toolu_01LJPzEpZLr7Ms65TpsFDCA1</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ce90495f-c7a7-490e-9b84-a6251050e87f/tasks/b17qeivxq.output</output-file> <status>completed</status> <summary>Monitor "Astra branch review round 2" stream ended</summary> <event>round 2 finished by prohibited listening sockets, including the analytics cache witness. No full suites or cross-platform builds ran. No files were edited. Fix the P2s without reopening review. **READY AFTER FIXES**</event> </task-notification>
<task-notification> <task-id>be90gyqcn</task-id> <tool-use-id>toolu_0174f7FRbfhCVfdMESHdvd3v</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ce90495f-c7a7-490e-9b84-a6251050e87f/tasks/be90gyqcn.output</output-file> <status>completed</status> <summary>Background command "until s=$(amadan ci status carlos/platform -branch console-analytics-ui 2>&1); echo "$s" | grep -q -E 'CI (pass|fail|succeeded|failed|green|red)'; do sleep 60; done; echo "$s"" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 65.7 g CO₂e (8,142,212 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on console-analytics-ui, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-console-analytics-ui-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-console-analytics-ui-R2.md| new file mode 100644 |
| index 000000000..d301d9093 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-console-analytics-ui-R2.md |
| @@ -0,0 +1,21 @@ |
| +Round-one findings: |
| + |
| +- P1, before-noon chart tests: **resolved**. |
| +- P2, Overview latency: **partly resolved**, carried forward below. |
| +- P2, missing-count units: **resolved**. |
| +- P2, bot exclusion claim: **resolved**. |
| +- P2, five-minute loss bound: **resolved**. |
| + |
| +1. **P2 — Overview still waits beyond the page’s remaining budget.** |
| + [server.go:4248](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-analytics-ui/internal/console/server.go:4248) starts an additional 250 ms wait after other page work finishes. A cold page otherwise ready at 400 ms can therefore take 650 ms, exceeding its 500 ms budget. The [new test:286](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-analytics-ui/internal/console/analyticsdisplay_test.go:286) only rejects durations above two seconds. |
| + **Fix:** enforce one deadline measured from request start, reserve rendering time, and test the remaining-budget case. **Fault family:** optional data must respect page latency limits. This family remains outstanding for a second round; central enforcement with a guard test is the recommended cut. |
| + |
| +2. **P2 — “Busiest hour so far” can name a future hour.** |
| + [analyticsdisplay.go:187](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-analytics-ui/internal/console/analyticsdisplay.go:187) searches all 24 hours, while the chart excludes future hours. With an ahead-of-time box clock, the insight can name an hour absent from the chart. The passing [test:142](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/console-analytics-ui/internal/console/analyticsdisplay_test.go:142) explicitly expects 14:00 as busiest at 10:00. |
| + **Fix:** exclude hours after the current UTC hour for today, matching the chart; correct the test expectation. **Fault family:** chart and insight must use the same eligible time window. |
| + |
| +No P1 findings. Eleven targeted arithmetic/cache tests passed. HTTP-backed tests were blocked by prohibited listening sockets, including the analytics cache witness. No full suites or cross-platform builds ran. No files were edited. |
| + |
| +Fix the P2s without reopening review. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/internal/console/analyticsdisplay.go b/internal/console/analyticsdisplay.go| index d9f1c8a0e..311ace7ff 100644 |
| --- a/internal/console/analyticsdisplay.go |
| +++ b/internal/console/analyticsdisplay.go |
| @@ -185,6 +185,11 @@ func analyticsInsights(rng string, sum analytics.Summary, now time.Time) []strin |
| d := sum.Days[len(sum.Days)-1] |
| best, at := int64(0), 0 |
| for h, v := range d.Hours { |
| + // The chart's hours: none after the current one, which a box |
| + // with a fast clock could have written. |
| + if d.Date == today && h > now.UTC().Hour() { |
| + break |
| + } |
| if v > best { |
| best, at = v, h |
| } |
diff --git a/internal/console/analyticsdisplay_test.go b/internal/console/analyticsdisplay_test.go| index 1f83d3775..957e40d95 100644 |
| --- a/internal/console/analyticsdisplay_test.go |
| +++ b/internal/console/analyticsdisplay_test.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "io" |
| "net/http" |
| + "strconv" |
| "strings" |
| "sync" |
| "testing" |
| @@ -137,9 +138,11 @@ func TestAnalyticsInsights(t *testing.T) { |
| if got := averageViews(2, 7); got != "0.3 page views" { |
| t.Errorf("averageViews(2, 7) = %q", got) |
| } |
| + // 14:00 is after now (10:00), so it is not a candidate: the chart does |
| + // not draw it either. |
| var d analytics.DaySummary |
| - d.Date, d.Hours[14] = "2026-10-28", 3 |
| - if got := analyticsInsights(rangeToday, analytics.Summary{Days: []analytics.DaySummary{d}}, now); len(got) != 1 || got[0] != "Busiest hour so far: 14:00 UTC, with 3 page views." { |
| + d.Date, d.Hours[9], d.Hours[14] = "2026-10-28", 2, 3 |
| + if got := analyticsInsights(rangeToday, analytics.Summary{Days: []analytics.DaySummary{d}}, now); len(got) != 1 || got[0] != "Busiest hour so far: 09:00 UTC, with 2 page views." { |
| t.Errorf("today insights = %q", got) |
| } |
| } |
| @@ -283,10 +286,49 @@ func TestOverviewTrafficCardSlowRead(t *testing.T) { |
| signUp(t, fx, c, "code-analytics-overview-slow-browser") |
| start := time.Now() |
| status, _, body := get(t, c, fx.u("/apps/titogo")) |
| - if took := time.Since(start); took > overviewTrafficTimeout { |
| + if took := time.Since(start); took >= overviewTrafficTimeout { |
| t.Fatalf("overview took %v: it waited for the traffic read", took) |
| } |
| if status != http.StatusOK || !strings.Contains(body, "Traffic is still loading.") { |
| t.Fatalf("overview = %d, want the card's still-loading line:\n%s", status, body) |
| } |
| } |
| + |
| +// The wait is what is left of one budget counted from the start of the |
| +// page's reads: a page that already spent it does not wait at all. |
| +func TestTrafficWait(t *testing.T) { |
| + t0 := time.Date(2026, 10, 28, 10, 0, 0, 0, time.UTC) |
| + for elapsed, want := range map[time.Duration]time.Duration{ |
| + 0: overviewTrafficBudget, 100 * time.Millisecond: overviewTrafficBudget - 100*time.Millisecond, |
| + overviewTrafficBudget: 0, 450 * time.Millisecond: 0, |
| + } { |
| + if got := trafficWait(t0, t0.Add(elapsed)); got != want { |
| + t.Errorf("after %v: wait %v, want %v", elapsed, got, want) |
| + } |
| + } |
| +} |
| + |
| +// The traffic card's memo answers for a minute, then not; a nil memo (the |
| +// Analytics tab, the CLI) never holds anything. |
| +func TestAnalyticsMemo(t *testing.T) { |
| + t0 := time.Date(2026, 10, 28, 10, 0, 0, 0, time.UTC) |
| + var m analyticsMemo |
| + m.put("k", analytics.Summary{PV: 7}, t0) |
| + if got, ok := m.get("k", t0.Add(59*time.Second)); !ok || got.PV != 7 { |
| + t.Fatalf("within the minute: %+v %v", got, ok) |
| + } |
| + if _, ok := m.get("k", t0.Add(analyticsMemoTTL)); ok { |
| + t.Fatal("held past its minute") |
| + } |
| + var none *analyticsMemo |
| + none.put("k", analytics.Summary{PV: 1}, t0) |
| + if _, ok := none.get("k", t0); ok { |
| + t.Fatal("a nil memo held something") |
| + } |
| + for i := 0; i < analyticsMemoMax+5; i++ { |
| + m.put(strconv.Itoa(i), analytics.Summary{}, t0.Add(time.Duration(i)*time.Millisecond)) |
| + } |
| + if len(m.m) > analyticsMemoMax { |
| + t.Fatalf("memo holds %d entries, cap %d", len(m.m), analyticsMemoMax) |
| + } |
| +} |
diff --git a/internal/console/analyticsview.go b/internal/console/analyticsview.go| index 73ef41457..8880a16d3 100644 |
| --- a/internal/console/analyticsview.go |
| +++ b/internal/console/analyticsview.go |
| @@ -15,6 +15,7 @@ import ( |
| "net/http" |
| "net/url" |
| "sort" |
| + "sync" |
| "time" |
| "github.com/carlosframework/platform/internal/analytics" |
| @@ -267,16 +268,90 @@ const ( |
| range30d = "30d" |
| ) |
| +// analyticsMemo holds the Overview traffic card's counts per app for |
| +// analyticsMemoTTL, so an Overview opened again within a minute reads no |
| +// day files at all: the edge writes them every five minutes, so a minute |
| +// old is as fresh as the bucket. The Analytics tab and the CLI do not use |
| +// it; someone looking at analytics gets the bucket as it is. A held |
| +// Summary is shared between views and must not be changed. |
| +type analyticsMemo struct { |
| + mu sync.Mutex |
| + m map[string]analyticsMemoEntry |
| +} |
| + |
| +type analyticsMemoEntry struct { |
| + at time.Time |
| + sum analytics.Summary |
| +} |
| + |
| +const ( |
| + analyticsMemoTTL = time.Minute |
| + analyticsMemoMax = 512 |
| +) |
| + |
| +// get is key's counts when they were read less than analyticsMemoTTL ago. |
| +// A nil memo holds nothing. |
| +func (c *analyticsMemo) get(key string, now time.Time) (analytics.Summary, bool) { |
| + if c == nil { |
| + return analytics.Summary{}, false |
| + } |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + e, ok := c.m[key] |
| + if !ok || now.Sub(e.at) >= analyticsMemoTTL || now.Before(e.at) { |
| + return analytics.Summary{}, false |
| + } |
| + return e.sum, true |
| +} |
| + |
| +// put keeps key's counts, read at now. Expired entries go first; past |
| +// analyticsMemoMax the oldest goes. |
| +func (c *analyticsMemo) put(key string, sum analytics.Summary, now time.Time) { |
| + if c == nil { |
| + return |
| + } |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + if c.m == nil { |
| + c.m = map[string]analyticsMemoEntry{} |
| + } |
| + for k, e := range c.m { |
| + if now.Sub(e.at) >= analyticsMemoTTL { |
| + delete(c.m, k) |
| + } |
| + } |
| + for len(c.m) >= analyticsMemoMax { |
| + oldest := "" |
| + for k, e := range c.m { |
| + if oldest == "" || e.at.Before(c.m[oldest].at) { |
| + oldest = k |
| + } |
| + } |
| + delete(c.m, oldest) |
| + } |
| + c.m[key] = analyticsMemoEntry{at: now, sum: sum} |
| +} |
| + |
| // overviewTrafficTimeout bounds the Overview's traffic card read, and |
| -// overviewTrafficGrace is how much longer than the rest of the page the |
| -// Overview waits for it (handleApp). A warm read takes a few GETs, well |
| -// inside the grace; a cold one past it shows the card as still loading, |
| -// and its settled days are in the cache for the next view. |
| +// overviewTrafficBudget is the latest, counted from the start of the |
| +// request (perf.Started), that the Overview waits for it (handleApp): |
| +// inside the 500 ms cold budget with room to render. A warm |
| +// read takes a few concurrent GETs, well inside it; a cold one past it |
| +// shows the card as still loading, and leaves its settled days in the |
| +// cache for the next view. |
| const ( |
| overviewTrafficTimeout = 2 * time.Second |
| - overviewTrafficGrace = 250 * time.Millisecond |
| + overviewTrafficBudget = 300 * time.Millisecond |
| ) |
| +// trafficWait is how long the Overview may still wait for the traffic card |
| +// at now, for a request that started at start: what is left of |
| +// overviewTrafficBudget, never negative. A page whose other reads already |
| +// used the budget does not wait at all. |
| +func trafficWait(start, now time.Time) time.Duration { |
| + return max(0, overviewTrafficBudget-now.Sub(start)) |
| +} |
| + |
| func validRange(s string) bool { return s == rangeToday || s == range7d || s == range30d } |
| // analyticsSpan turns a range name into a UTC span. Truncate(24h) lands on |
| @@ -301,6 +376,14 @@ func analyticsSpan(rng string, now time.Time) (from, to time.Time) { |
| // shown after an owner turns counting off, because they were collected while |
| // it was on and hiding them would read as data loss. |
| func (s *Server) readAnalytics(ctx context.Context, sqid, app, rng string, now time.Time) (analyticsWindow, error) { |
| + return s.readAnalyticsVia(ctx, sqid, app, rng, now, nil) |
| +} |
| + |
| +// readAnalyticsVia is readAnalytics, with the counts taken from memo when |
| +// it holds them for this window (the Overview's traffic card). The setting |
| +// is read every time either way: an owner who turns analytics on sees it |
| +// on at once. |
| +func (s *Server) readAnalyticsVia(ctx context.Context, sqid, app, rng string, now time.Time, memo *analyticsMemo) (analyticsWindow, error) { |
| out := analyticsWindow{Range: rng} |
| res, err := telemetry.Resolve(ctx, s.cfg.Releases, sqid, app) |
| if err != nil { |
| @@ -314,9 +397,14 @@ func (s *Server) readAnalytics(ctx context.Context, sqid, app, rng string, now t |
| return out, nil |
| } |
| from, to := analyticsSpan(rng, now) |
| - sum, err := s.readAnalyticsRange(ctx, sqid, app, from, to, now) |
| - if err != nil { |
| - return out, err |
| + key := sqid + "/" + app + "/" + rng + "/" + to.Format("2006-01-02") |
| + sum, hit := memo.get(key, now) |
| + if !hit { |
| + sum, err = s.readAnalyticsRange(ctx, sqid, app, from, to, now) |
| + if err != nil { |
| + return out, err |
| + } |
| + memo.put(key, sum, now) |
| } |
| out.Sum = sum |
| out.Span = analyticsSpanText(rng, now) |
diff --git a/internal/console/regionbudget_test.go b/internal/console/regionbudget_test.go| index da63d591b..2ba2bc7a0 100644 |
| --- a/internal/console/regionbudget_test.go |
| +++ b/internal/console/regionbudget_test.go |
| @@ -152,11 +152,14 @@ var regionBudgetBaseline = map[string]map[string]int{ |
| "CLI /api/cli/apps/{sqid}/shop/regions": {"Get apps": 1, "Get control": 9, "Get status": 4, "List control": 3, "List status": 2}, |
| "CLI /api/cli/apps/{sqid}/shop/routes": {"Get status": 2, "List status": 1}, |
| "GET /a/{sqid}/": {"Get apps": 5, "Get status": 2, "List apps": 2, "List status": 1}, |
| - "GET /a/{sqid}/apps/shop": {"Get accounts": 1, "Get apps": 4, "Get metrics": 48, "List alerts": 1, "List apps": 2, "List metrics": 1}, |
| - "GET /a/{sqid}/apps/shop/releases": {"Get accounts": 1, "Get apps": 6, "List apps": 3}, |
| - "GET /a/{sqid}/apps/shop/instances": {"Get accounts": 1, "Get apps": 4, "Get control": 3, "Get status": 2, "List apps": 1, "List control": 1, "List status": 1}, |
| - "GET /a/{sqid}/apps/shop/instances/eu.shop.example.com": {"Get accounts": 1, "Get apps": 3, "List apps": 1}, |
| - "GET /a/{sqid}/apps/shop/settings": {"Get accounts": 1, "Get apps": 10, "Get status": 2, "List apps": 5, "List control": 1, "List domains": 1, "List status": 1}, |
| + // The Overview's traffic card (console-analytics-ui, 2026-10-28) adds the |
| + // account's analytics setting and the listing of the app's analytics |
| + // boxes; the labels add nothing. |
| + "GET /a/{sqid}/apps/shop": {"Get accounts": 2, "Get apps": 4, "Get metrics": 48, "List alerts": 1, "List apps": 2, "ListDirs apps": 1, "List metrics": 1}, |
| + "GET /a/{sqid}/apps/shop/releases": {"Get accounts": 1, "Get apps": 6, "List apps": 3}, |
| + "GET /a/{sqid}/apps/shop/instances": {"Get accounts": 1, "Get apps": 4, "Get control": 3, "Get status": 2, "List apps": 1, "List control": 1, "List status": 1}, |
| + "GET /a/{sqid}/apps/shop/instances/eu.shop.example.com": {"Get accounts": 1, "Get apps": 3, "List apps": 1}, |
| + "GET /a/{sqid}/apps/shop/settings": {"Get accounts": 1, "Get apps": 10, "Get status": 2, "List apps": 5, "List control": 1, "List domains": 1, "List status": 1}, |
| } |
| // TestRegionLabelsAddNoStoreReads (spec §7, labels R2-1): no request makes a |
diff --git a/internal/console/server.go b/internal/console/server.go| index e9a42a8fe..cb240d491 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -1173,6 +1173,9 @@ type Server struct { |
| // reads (usagedays.go), so a cold view reads only today and yesterday; |
| // the hourly economics pass fills it as it reads. |
| usageDays usageDayCache |
| + // trafficMemo holds the Overview traffic card's counts for a minute |
| + // (analyticsview.go, analyticsMemo). |
| + trafficMemo analyticsMemo |
| // storeSizer is the storage pass's test seam for sizing a provisioned |
| // tenant object store: nil means "use the real S3 sizer" |
| // (sizeProvisionedStore, economicspass.go); tests inject a fake so a |
| @@ -4184,17 +4187,22 @@ func (s *Server) handleApp(w http.ResponseWriter, r *http.Request) { |
| return |
| } |
| app := p.Detail.App |
| - // The traffic card reads beside everything else this page reads. Once |
| - // the rest is ready the page waits at most overviewTrafficGrace more, |
| - // then renders the card as still loading: a slow bucket costs the card |
| - // its numbers, never the page its budget. The read is under the |
| - // request's context, so it stops when the handler returns, and the |
| - // channel is buffered, so a late result is dropped, not leaked. |
| + // The traffic card reads beside everything else this page reads. The |
| + // page waits for it only until overviewTrafficBudget after the request |
| + // started (trafficWait), then renders the card as still loading: a slow |
| + // bucket costs the card its numbers, never the page its budget. |
| + // The read is under the request's context, so it stops when the |
| + // handler returns, and the channel is buffered, so a late result is |
| + // dropped, not leaked. |
| + start, measured := perf.Started(r.Context()) |
| + if !measured { |
| + start = time.Now() |
| + } |
| traffic := make(chan *analyticsWindow, 1) |
| go func() { |
| ctx, cancel := context.WithTimeout(r.Context(), overviewTrafficTimeout) |
| defer cancel() |
| - win, err := s.readAnalytics(ctx, acct.Sqid, app, range7d, time.Now()) |
| + win, err := s.readAnalyticsVia(ctx, acct.Sqid, app, range7d, time.Now(), &s.trafficMemo) |
| if err != nil { |
| log.Printf("console: overview traffic %s/%s: %v", acct.Sqid, app, err) |
| traffic <- nil |
| @@ -4245,11 +4253,17 @@ func (s *Server) handleApp(w http.ResponseWriter, r *http.Request) { |
| p.Pending = s.pendingChangeViews(pcs, p.Detail.Pipeline) |
| } |
| end = perf.Span(r, "s3") |
| + wait := time.NewTimer(trafficWait(start, time.Now())) |
| select { |
| case p.Traffic = <-traffic: |
| - case <-time.After(overviewTrafficGrace): |
| - p.TrafficSlow = true |
| + case <-wait.C: |
| + select { |
| + case p.Traffic = <-traffic: |
| + default: |
| + p.TrafficSlow = true |
| + } |
| } |
| + wait.Stop() |
| end() |
| s.render(w, http.StatusOK, "app_overview", p) |
| } |
diff --git a/internal/console/testdata/perf-session-s3.txt b/internal/console/testdata/perf-session-s3.txt| index 090b46a84..1e73bcc33 100644 |
| --- a/internal/console/testdata/perf-session-s3.txt |
| +++ b/internal/console/testdata/perf-session-s3.txt |
| @@ -1 +1 @@ |
| -401 after console-perf-hot-routes, 2026-10-27: the fixture now has seven boxes, six edges files and four live apps, one with 30 instances (320 before on the old fixture); the concurrent reads add no request |
| +415 after console-analytics-ui, 2026-10-28: the Overview's traffic card reads the app's analytics (one listing, the week's day files through the settled-day cache, the two settings objects); its counts are held a minute, so each later Overview view adds only the two settings reads (401 before) |
diff --git a/internal/perf/middleware.go b/internal/perf/middleware.go| index 5bf4eee26..bc8b6cee0 100644 |
| --- a/internal/perf/middleware.go |
| +++ b/internal/perf/middleware.go |
| @@ -161,6 +161,16 @@ func fromContext(ctx context.Context) *writer { |
| return q |
| } |
| +// Started is when the middleware began measuring the request: what a |
| +// handler holding part of its page to a latency budget counts from. ok is |
| +// false on a request the middleware did not measure. |
| +func Started(ctx context.Context) (t time.Time, ok bool) { |
| + if q := fromContext(ctx); q != nil { |
| + return q.start, true |
| + } |
| + return time.Time{}, false |
| +} |
| + |
| // Span starts timing one named part of the request's work and returns |
| // the func that ends it; call it with defer. Spans of the same name add |
| // up, so a loop of queries is one "db" span. Each name becomes a |
diff --git a/internal/perf/middleware_test.go b/internal/perf/middleware_test.go| index 469ef8161..22556f6fb 100644 |
| --- a/internal/perf/middleware_test.go |
| +++ b/internal/perf/middleware_test.go |
| @@ -971,3 +971,20 @@ func TestFlushAndHijackStillWork(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +func TestStarted(t *testing.T) { |
| + if _, ok := perf.Started(context.Background()); ok { |
| + t.Fatal("an unmeasured context reported a start") |
| + } |
| + var c perf.Recorder |
| + var got time.Time |
| + var ok bool |
| + h := perf.Middleware(&c, perf.Options{Logger: quiet})(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + got, ok = perf.Started(r.Context()) |
| + })) |
| + before := time.Now() |
| + h.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest("GET", "/apps", nil)) |
| + if !ok || got.Before(before.Add(-time.Second)) || got.After(time.Now()) { |
| + t.Fatalf("Started = %v, %v", got, ok) |
| + } |
| +} |