cosmo
cosmo copied to clipboard
feat: operations overview
Summary by CodeRabbit
- New Features
- Full Operations analytics page: searchable, filterable, sortable (requests/latency/errors) list with pagination and detailed right‑hand panel.
- Client Usage view showing per‑client metrics and totals.
- Operation Content modal to view operation source.
- Deprecated‑fields detection with a table and quick "Show Usage" navigation.
- UI updates: "Operations" nav item, configurable metrics cards, reusable scrollable area and list/table components.
Checklist
- [x] I have discussed my proposed changes in an issue and have received approval to proceed.
- [x] I have followed the coding standards of the project.
- [x] Tests or benchmarks have been added or updated.
- [ ] Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
- [x] I have read the Contributors Guide.
Walkthrough
Adds two RPCs (GetOperationClients, GetOperationDeprecatedFields), enhances operations proto (paging, sorting, metric oneof, fetchBasedOn), implements server analytics handlers and repository queries, adds tests, and ships a new Operations UI (hooks, components, page), ScrollArea UI primitive, and related layout updates.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Proto & generated clients proto/wg/cosmo/platform/v1/platform.proto, connect/src/wg/cosmo/platform/v1/platform_pb.ts, connect/src/wg/cosmo/platform/v1/platform_connect.ts, connect/src/wg/cosmo/platform/v1/platform-PlatformService_connectquery.ts |
Added OperationsFetchBasedOn enum; extended GetOperationContentRequest and GetOperationsRequest (offset, includeDeprecatedFields, fetchBasedOn, sortDirection, includeContent, range/dateRange, searchQuery, clientNames); reworked GetOperationsResponse.Operation (moved type, added hasDeprecatedFields, added metric oneof); added messages and RPCs for GetOperationClients and GetOperationDeprecatedFields. |
Service wiring controlplane/src/core/bufservices/PlatformService.ts |
Registered and exported handlers getOperationClients and getOperationDeprecatedFields; added imports. |
New analytics handlers controlplane/src/core/bufservices/analytics/getOperationClients.ts, controlplane/src/core/bufservices/analytics/getOperationDeprecatedFields.ts |
New server handlers: auth checks, analytics availability checks, date-range validation, ClickHouse parameterized queries (getOperationClients), schema retrieval/parsing and deprecated-field detection (getOperationDeprecatedFields), mapping and error handling. |
Analytics updates controlplane/src/core/bufservices/analytics/getOperations.ts, controlplane/src/core/bufservices/analytics/getOperationContent.ts |
Extended getOperations for fetchBasedOn/offset/sortDirection/includeDeprecatedFields/includeContent and deprecated-field awareness; parameterized getOperationContent queries and optional operationName filtering. |
Repositories — metrics & usage controlplane/src/core/repositories/analytics/MetricsRepository.ts, controlplane/src/core/repositories/analytics/UsageRepository.ts |
MetricsRepository.getOperations signature/logic expanded (offset, fetchBasedOn, sortDirection, searchQuery, fetchAll) with multi-branch ClickHouse queries and normalized output; UsageRepository adds getOperationsUsingDeprecatedFields and getDeprecatedFieldsUsedInOperation. |
Controlplane util controlplane/src/core/util.ts |
validateDateRanges adds end-date guard to reject invalid/too-old end dates. |
Tests — analytics controlplane/test/analytics/get-operations.test.ts, controlplane/test/analytics/get-operation-clients.test.ts, controlplane/test/analytics/get-operation-deprecated-fields.test.ts |
New test suites with ClickHouse client mocks covering error paths and success cases, including date ranges, escaping, deprecated-field flows, sorting and pagination. |
Studio — Operations UI & pages studio/src/pages/.../operations.tsx, studio/src/components/operations/* studio/src/components/operations/client-usage-table.tsx, studio/src/components/operations/deprecated-fields-table.tsx, studio/src/components/operations/operation-content-modal.tsx, studio/src/components/operations/operations-list.tsx, studio/src/components/operations/operations-search.tsx |
New Operations page and components: searchable/sortable operations list, client-usage table, deprecated-fields table, operation content modal; components call new RPCs and implement selection/search/sort/pagination UX. |
Studio — Hooks & filters studio/src/hooks/use-operations-filters.tsx |
Added useOperationsFilters for URL-backed operation filters (includeDeprecatedFields, clientNames, searchQuery, fetchBasedOn/sortDirection mapping and actions). |
Studio — Layout & UI primitives studio/src/components/layout/graph-layout.tsx, studio/src/components/ui/scroll-area.tsx |
Added "Operations" nav item; GraphPageLayout accepts className; introduced ScrollArea and ScrollBar components. |
Studio — Analytics & minor UI changes studio/src/components/analytics/metrics.tsx, studio/src/components/analytics/field-usage.tsx, studio/src/components/analytics/data-table-primary-filter-menu.tsx, studio/src/components/analytics/filters.tsx |
Metrics cards gain showTopList and chartClassName props; FieldUsage no longer clears range URL param on close; primary filter menu gains boolean-option support and className plumbing; AnalyticsFilters accepts className. |
Studio — Dropdown/Menu studio/src/components/ui/dropdown-menu.tsx |
DropdownMenuCheckboxItem gains `checkboxPosition?: "left" |
Misc & deps package.json |
DevDependency bump: prettier ^3.0.3 → ^3.6.2. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
- Areas needing extra attention:
- ClickHouse query construction, parameterization, and multi-branch logic in MetricsRepository, getOperationClients, and UsageRepository.
- Date-range validation and analytics-retention enforcement (validateDateRanges and callers).
- Schema retrieval/parsing and SchemaGraphPruner usage for deprecated-field detection.
- Mapping between proto oneof
metricand server/UI representations; pagination/offset/fetchAll semantics. - New tests that mock query behavior — ensure mocks align with production parameterization.
Possibly related PRs
- wundergraph/cosmo#2107 — modifies the operation-content path and GetOperationContentRequest handling; likely overlaps with proto/client changes in this PR.
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 20.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: operations overview' clearly summarizes the main feature being added across the changeset: a comprehensive operations overview interface. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
Comment @coderabbitai help to get the list of available commands and usage tips.
Adding tests
Router-nonroot image scan passed
:white_check_mark: No security vulnerabilities found in image:
ghcr.io/wundergraph/cosmo/router:sha-890d06f893513f1c9a6af69bf49b088bb529f776-nonroot