Prod monitoring: route latency middleware + metrics history snapshots + threshold alerting#1667
Draft
pulzzejason wants to merge 1 commit into
Draft
Prod monitoring: route latency middleware + metrics history snapshots + threshold alerting#1667pulzzejason wants to merge 1 commit into
pulzzejason wants to merge 1 commit into
Conversation
…y populates Registers LatencySpanProcessor on the NodeSDK in instrumentation.ts whose onEnd() records incoming HTTP SERVER-span duration into the in-process latency store (recordLatency), backing the admin Prod Metrics "Request Latency" panel that was permanently empty (recordLatency had zero callers). Key decisions: - Span processor over per-handler wrappers: the OTel HTTP auto-instrumentation already emits one SERVER span per request, so onEnd() captures EVERY route uniformly with no handler edits. - Node runtime only: capture cannot live in edge middleware.ts, which can't reach the ioredis-backed Node in-process store. - SDK now starts REGARDLESS of OTEL_EXPORTER_OTLP_ENDPOINT (shipped empty in .env.example); previously the whole tracing SDK was gated on it, so the processor would have captured nothing in the common deployment. OTLP export is attached as an extra BatchSpanProcessor only when the endpoint is set (NodeSDK uses spanProcessors verbatim and ignores traceExporter). - Route keys normalized via normalize-route.ts (collapses ids/slugs) to bound map cardinality; static assets (_next/static, _next/image, favicon, asset file extensions) excluded. Verified end-to-end: booting the SDK with no OTLP endpoint + real HTTP traffic yields non-empty p50/p95/p99 rows for normalized routes, with static assets and outbound CLIENT spans excluded. Unit tests cover the store, percentile helper, route extraction/normalization, exclusion rules, and the processor. No PM agent config change: this is an admin-ops surface (Prod Metrics dashboard), not agent-visible data or tools. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integration PR for this goal — its tasks commit onto this branch (one PR per goal). Opened automatically by the engine on first push; left as a draft until the goal completes.