-
Notifications
You must be signed in to change notification settings - Fork 193
fix(router): record operation planning time correctly in plan error case #2070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdjusts sequencing and conditions of planning-phase instrumentation in PreHandler.handleOperation. EndPlanning is now conditional based on ExcludePlannerStats; planningTime is computed after EndPlanning; plan cache-hit attribute is recorded post-EndPlanning; error attachment occurs after planningTime calculation. No changes to exported/public APIs. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
d9f7662 to
cc6fb30
Compare
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
6f9a84a to
72c66c6
Compare
a229d8e to
69c6af3
Compare
1a37ef3 to
a3ea5a4
Compare
a3ea5a4 to
9f6c4a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
router/core/graphql_prehandler.go (1)
985-996: Good fix: compute planningTime and end planning timing before attaching the error
- Ending the planning timing (when enabled) and computing planningTime before attaching the error to the span ensures the reported duration reflects the full planning attempt.
- Attaching the error to enginePlanSpan after timing is computed is the right order.
One consideration: do we want to observe/emit the planning time metric even on planning errors? Right now, the measurement happens only in the success path. If the intent of this PR is to “record operation planning time correctly in plan error case,” you might also want to emit the metric on error. If that matches product expectations, consider this small addition inside the error branch:
Apply this diff inside the error branch (after planningTime is computed and before ending the span):
if err != nil { httpOperation.requestLogger.Debug("failed to plan operation", zap.Error(err)) if !requestContext.operation.traceOptions.ExcludePlannerStats { httpOperation.traceTimings.EndPlanning() } requestContext.operation.planningTime = time.Since(startPlanning) + // Optionally record planning time metric even on error + planningAttrs := *requestContext.telemetry.AcquireAttributes() + planningAttrs = append(planningAttrs, otel.WgEnginePlanCacheHit.Bool(requestContext.operation.planCacheHit)) + planningAttrs = append(planningAttrs, requestContext.telemetry.metricAttrs...) + httpOperation.operationMetrics.routerMetrics.MetricStore().MeasureOperationPlanningTime( + req.Context(), + requestContext.operation.planningTime, + requestContext.telemetry.metricSliceAttrs, + otelmetric.WithAttributeSet(attribute.NewSet(planningAttrs...)), + ) + requestContext.telemetry.ReleaseAttributes(&planningAttrs) + rtrace.AttachErrToSpan(enginePlanSpan, err) enginePlanSpan.End() return err }If the desired behavior is to only emit planning-time metrics on success, feel free to ignore the suggestion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
router/core/graphql_prehandler.go(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: build-router
- GitHub Check: image_scan (nonroot)
- GitHub Check: image_scan
- GitHub Check: build_push_image (nonroot)
- GitHub Check: integration_test (./events)
- GitHub Check: build_push_image
- GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
- GitHub Check: build_test
- GitHub Check: integration_test (./telemetry)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
router/core/graphql_prehandler.go (2)
966-971: Conditional StartPlanning is correct and consistent with other timing sectionsMaking traceTimings.StartPlanning conditional on ExcludePlannerStats aligns with how parse/normalize/validate timings are handled. No issues spotted.
1001-1008: Success path ordering looks good
- EndPlanning is conditional, planningTime is computed after EndPlanning, and the plan cache-hit attribute is set before ending the span. This sequencing avoids skewed timing and ensures attributes are attached to the correct span.
StarpTech
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary by CodeRabbit
Checklist