fix: preserve sessionId/requestId in middleware-flushed api_metrics#718
fix: preserve sessionId/requestId in middleware-flushed api_metrics#7182witstudios merged 1 commit intomasterfrom
Conversation
…cs (#538) The RequestMetrics type and flush insert were missing sessionId and requestId, so the api_metrics table columns were always null despite the DB schema already supporting them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge Readiness ReviewCode Change VerifiedThe 8-line change in
CI Status
Unit Test Failure — Pre-existing on
|
Closes #538
Summary
sessionIdandrequestIdfields to theRequestMetricsinterface in the monitoring middlewaretrack()callsThis ensures that when metrics are batch-flushed to the
api_metricstable, thesession_idandrequest_idcolumns (which already existed in the DB schema) are now populated.Changes
apps/web/src/middleware/monitoring.tssessionId?: stringandrequestId?: stringtoRequestMetricsinterfacesessionId: context.sessionIdandrequestIdto the success-pathmetricsCollector.track()callsessionId: context.sessionIdandrequestIdto the error-pathmetricsCollector.track()callsessionId: metric.sessionIdandrequestId: metric.requestIdto the flushdb.insert()mappingNotes
apiMetricsDB schema already hadsessionIdandrequestIdcolumns — they were just never populated by the middleware flushMonitoringIngestPayload(separate ingest endpoint) was already passing these fields correctly — only the buffered DB flush was missing themrequestIdcomes fromgetOrCreateRequestId(request)which was already being called for the ingest path and response headerssessionIdcomes fromcontext.sessionIdviaextractRequestContext()— the same source already used in the ingest payloadTest plan
monitoring.tshas zero type errorsapi_metricsrows containsession_idandrequest_idafter deployment🤖 Generated with Claude Code