cosmo
cosmo copied to clipboard
feat: expose timing of planning in the report
We want to expose query planning time to make easier and more precise to track query planner's performance regressions.
Summary by CodeRabbit
-
New Features
- Query plan results now include per-operation timing metrics (parse, normalize, validate, plan, post-process) aggregated per file and included in result objects — timings are present for both successes and failures.
-
Tests
- Tests and benchmarks updated to handle the new timing data and to compare structured plan results rather than raw JSON strings.
Checklist
- [ ] I have discussed my proposed changes in an issue and have received approval to proceed.
- [ ] I have followed the coding standards of the project.
- [ ] Tests or benchmarks have been added or updated.
- [ ] Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
- [ ] I have read the Contributors Guide.
Walkthrough
Instruments the planning pipeline with per-operation timing via a new public OperationTimes type; updates planner function signatures to return and propagate timing data through parse, normalize, validate, and plan phases (including error paths); exposes per-result timings in the plan generator and adjusts tests/benchmarks.
Changes
| Cohort / File(s) | Summary |
|---|---|
Core Planning Instrumentation router/core/plan_generator.go |
Adds public OperationTimes (ParseTime, NormalizeTime, ValidateTime, PlanTime) with TotalTime() and Merge(). Updates PlanOperation, ParseAndPrepareOperation, PrepareOperation, and PlanPreparedOperation signatures to return OperationTimes; measures and accumulates timings around each phase and returns timings on success and error paths. |
Planner Tests & Benchmarks router/core/plan_generator_test.go, router/internal/planningbenchmark/benchmark_test.go |
Updates call sites to handle the additional OperationTimes return value from ParseAndPrepareOperation and PlanPreparedOperation (captured or ignored), preserving existing control flow and error handling. |
Plan Generator Result & Generator router/pkg/plan_generator/plan_generator.go |
Adds Timings core.OperationTimes to QueryPlanResult and populates it from Planner.PlanOperation so per-file timing data is included in results. |
Plan Generator Tests Refactor router/pkg/plan_generator/plan_generator_test.go |
Replaces raw JSON string equality checks with unmarshalling into QueryPlanResults and per-entry comparisons of Plan, Error, and Warning; minor import formatting change. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
- Verify that
OperationTimesvalues are correctly captured, merged, and returned on all success and error paths inrouter/core/plan_generator.go. - Confirm
QueryPlanResult.Timingsis populated consistently and that JSON marshaling still behaves as expected. - Check updated tests/benchmarks properly ignore or validate timing data where intended.
Possibly related PRs
- wundergraph/cosmo#2236 — Related signature changes to
Planner.PlanOperation(addsoutputFormat) that overlap with this PR's signature adjustments. - wundergraph/cosmo#2303 — Refactors the planning pipeline functions (
ParseAndPrepareOperation,PrepareOperation,PlanPreparedOperation) which this PR further augments to propagate timing data.
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'feat: expose timing of planning in the report' directly and clearly describes the main change: adding timing information to planning reports for tracking performance. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
Comment @coderabbitai help to get the list of available commands and usage tips.
Router-nonroot image scan passed
:white_check_mark: No security vulnerabilities found in image:
ghcr.io/wundergraph/cosmo/router:sha-1f43bba1fe504a2709bc39544e26508f95949d2c-nonroot
This PR was marked stale due to lack of activity. It will be closed in 14 days.