Skip to content

feat(java): dashboard settings, overrides, metrics, ops#388

Open
pratyush618 wants to merge 2 commits into
masterfrom
feat/java-dashboard-ops
Open

feat(java): dashboard settings, overrides, metrics, ops#388
pratyush618 wants to merge 2 commits into
masterfrom
feat/java-dashboard-ops

Conversation

@pratyush618

@pratyush618 pratyush618 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Builds on the session-auth foundation to bring the read/write and platform surface to parity. Everything rides the settings KV store — no schema changes.

Endpoints

  • Settings KV APIGET/PUT/DELETE /api/settings[/<key>], with reserved auth:/webhooks: prefixes hidden, a 256-char key / 64 KiB value cap, and control-char rejection.
  • Task/queue overridesGET/PUT/DELETE /api/{tasks,queues}/<name>/override (rate-limit, concurrency, retries, timeout, priority, paused), validated and merge-on-write; setting a queue's paused also pauses/resumes it live. /api/tasks and /api/queues list the known names.
  • Metrics/api/metrics now returns the aggregated per-task summary the SPA expects (count, success/failure, avg, p50/p95/p99, min/max) instead of raw rows, plus /api/metrics/timeseries. Percentiles are computed in pure Java (nearest-rank).
  • Circuit breakers/api/circuit-breakers.
  • Event types/api/event-types.
  • KEDA scaler/api/scaler (queue depth, live workers, capacity, per-queue).
  • Probes/health (public), /readiness and a Prometheus /metrics exposition, both gated by TASKITO_DASHBOARD_METRICS_TOKEN.

WorkerInfo now also carries threads in the contract (feeds the scaler capacity math).

Tests

Settings API, overrides store, and an ops integration suite covering metrics/scaler/probes. Full Java suite + checkstyle + Spotless clean.

Summary by CodeRabbit

  • New Features

    • Added dashboard endpoints for readiness, Prometheus metrics, aggregated metrics, and time-bucketed timeseries.
    • Added operational APIs including circuit breakers, event types, scaler info, and worker/job metrics.
    • Added settings key-value APIs with validation and protected-key handling, plus task/queue override CRUD.
  • Bug Fixes

    • Protected sensitive settings keys from being listed, read, or deleted.
    • Improved probe/metrics handling with token-gated authorization.
    • Added stricter query parameter parsing with 400 responses for malformed non-numeric inputs.

Adds the settings KV API (reserved auth:/webhooks: prefixes, size caps), per-task/queue overrides with live queue pause, aggregated /api/metrics + /api/metrics/timeseries (raw rows replaced), and circuit-breakers/event-types/scaler endpoints plus /readiness and Prometheus /metrics probes (metrics-token gated). Task/queue listings are derived from observable state since the SDK has no registry.
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 649e8344-dfba-4846-a3be-ac7555827601

📥 Commits

Reviewing files that changed from the base of the PR and between c392402 and 19b385e.

📒 Files selected for processing (6)
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/CoreHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/MetricsHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OpsHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OverridesHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/support/Http.java
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/DashboardOpsTest.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/DashboardOpsTest.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OverridesHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OpsHandlers.java

📝 Walkthrough

Walkthrough

This PR adds dashboard ops, metrics, settings, and overrides APIs in Java, wires them into DashboardServer, adds /readiness and /metrics probe handling with token gating, and expands test coverage with new in-memory and endpoint-level support.

Changes

Dashboard Ops/Metrics/Settings/Overrides

Layer / File(s) Summary
Metrics aggregation engine
sdks/java/.../api/Metrics.java, sdks/java/.../api/MetricsHandlers.java, sdks/java/.../api/Contract.java, sdks/java/.../api/CoreHandlers.java, sdks/java/.../support/Http.java
Adds task-level and time-series metrics aggregation, new metrics endpoints, and numeric query parsing helpers while removing the old metric listing path.
Ops handlers
sdks/java/.../api/OpsHandlers.java, sdks/java/.../api/Contract.java
Adds circuit-breaker mapping, event-type listing, scaler output, readiness status, and Prometheus text exposition.
Settings KV handlers
sdks/java/.../api/SettingsHandlers.java
Adds settings CRUD with protected-key filtering, validation, and value-size enforcement.
Overrides persistence
sdks/java/.../store/OverridesStore.java
Adds normalized task and queue override storage with merge, delete, name listing, and field validation.
Overrides endpoints
sdks/java/.../api/OverridesHandlers.java
Adds task and queue override CRUD plus live queue pause/resume reconciliation on queue override writes.
Dashboard server wiring
sdks/java/.../DashboardServer.java
Wires the new handlers into routing, adds /readiness and /metrics, and applies bearer-token gating for probe and metrics responses.
Test support and coverage
sdks/java/src/test/.../InMemorySettings.java, DashboardClient.java, AuthStoreTest.java, DashboardOpsTest.java, SettingsHandlersTest.java, OverridesStoreTest.java
Adds test support for new HTTP verbs and in-memory settings plus coverage for settings, overrides, ops, probes, and invalid numeric parameters.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant DashboardServer
  participant OpsHandlers

  Client->>DashboardServer: GET /readiness
  DashboardServer->>DashboardServer: metricsTokenOk(request)
  DashboardServer->>OpsHandlers: readiness()
  OpsHandlers-->>DashboardServer: readiness JSON
  DashboardServer-->>Client: 200 JSON

  Client->>DashboardServer: GET /metrics
  DashboardServer->>DashboardServer: metricsTokenOk(request)
  DashboardServer->>OpsHandlers: prometheus()
  OpsHandlers-->>DashboardServer: Prometheus text
  DashboardServer-->>Client: 200 text/plain
Loading

Possibly related PRs

  • ByteVeda/taskito#383: Adds the circuit-breaker model and listing plumbing that Contract::circuitBreaker and OpsHandlers.circuitBreakers() consume.
  • ByteVeda/taskito#385: Touches the same dashboard ops/probes/settings/overrides surface and route families.

Suggested labels: docs, tests

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main scope: dashboard settings, overrides, metrics, and ops work in Java.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/java-dashboard-ops

Comment @coderabbitai help to get the list of available commands.

@pratyush618 pratyush618 self-assigned this Jul 7, 2026
@pratyush618

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OpsHandlers.java (1)

64-72: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Readiness check doesn't actually check anything.

storage is hardcoded true and status is always "ready"; the endpoint never derives its result from a real health signal, so it can't detect an actual outage (e.g., unreachable settings/storage backend). This could mask real problems for anything consuming /readiness for traffic/orchestration decisions.

Consider performing a lightweight probe (e.g., a settings read) before reporting storage: true, or clarify if this is an intentional stub for this phase.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OpsHandlers.java`
around lines 64 - 72, The readiness endpoint in OpsHandlers.readiness is
hardcoded to report healthy state, so replace the static storage=true and
always-ready status with a real lightweight health probe before building the
response. Use an actual settings/storage check (or another minimal backend read)
to determine the storage check result, and derive the top-level status from the
collected checks instead of always returning "ready". If this is meant to remain
a stub, make that explicit in the method name or response so callers do not
treat it as a real readiness signal.
sdks/java/src/main/java/org/byteveda/taskito/dashboard/store/OverridesStore.java (1)

117-121: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

rate_limit validation only checks for a / character.

Values like "/" or "abc/def" pass this check but are meaningless as a rate limit, potentially breaking whatever downstream code parses count/period.

♻️ Proposed tightening
             case "rate_limit" -> {
-                if (!(value instanceof String s) || s.isEmpty() || !s.contains("/")) {
+                if (!(value instanceof String s) || !s.matches("\\d+/\\d+[a-zA-Z]*")) {
                     throw DashboardError.badRequest("rate_limit must look like '<count>/<period>'");
                 }
             }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@sdks/java/src/main/java/org/byteveda/taskito/dashboard/store/OverridesStore.java`
around lines 117 - 121, The rate_limit validation in OverridesStore currently
only checks for a non-empty string containing “/”, so invalid values like “/” or
“abc/def” still pass. Tighten the validation in the rate_limit case to require a
well-formed count/period value with both sides present and meaningful (for
example, non-empty numeric count and non-empty period), using the same
DashboardError.badRequest path when the format is invalid.
sdks/java/src/test/java/org/byteveda/taskito/dashboard/DashboardOpsTest.java (1)

102-114: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add coverage for the metrics-token-configured case.

Given the shared-gate concern raised in DashboardServer.java (readiness incorrectly requiring the metrics bearer token), consider adding a test that sets TASKITO_DASHBOARD_METRICS_TOKEN and verifies /readiness and /health behavior, to lock in the intended contract once fixed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/java/src/test/java/org/byteveda/taskito/dashboard/DashboardOpsTest.java`
around lines 102 - 114, Add a test case in DashboardOpsTest to cover the
metrics-token-configured behavior: set TASKITO_DASHBOARD_METRICS_TOKEN, start
DashboardServer via DashboardServer.start, and verify that /health and
/readiness still return the expected ok/ready responses while /metrics remains
protected by the bearer token. Use the existing probes in probesAreServed and
the same server/queue setup to lock in the intended contract around
DashboardServer and its readiness/metrics gating.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/MetricsHandlers.java`:
- Around line 21-34: The query parameter parsing in MetricsHandlers.longParam is
not validating malformed numeric input, so invalid since/bucket values can
surface as uncaught NumberFormatException. Update aggregated and timeseries to
parse these params through a guarded path that catches format errors and returns
DashboardError.badRequest, matching the other handlers in this PR. Use longParam
as the locating symbol, and ensure both since and bucket report a clean 400
instead of bubbling up a 500.

In `@sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OpsHandlers.java`:
- Around line 42-62: The scaler method in OpsHandlers currently parses the
target query parameter with an unguarded Long.parseLong, so invalid input can
throw NumberFormatException and return a 500. Update scaler(Map<String, String>)
to use the same safe parsing pattern as MetricsHandlers.longParam: validate the
target param, handle parse failures gracefully, and return a client error
response instead of letting the exception escape.

In
`@sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OverridesHandlers.java`:
- Around line 62-72: The live queue update in putQueueOverride is using the raw
patch body to decide whether to pause or resume, so clearing the paused override
with null never resumes the queue. Update this method to base the side effect on
the effective paused value returned by store.putQueue (or equivalent computed
row value) instead of body.get("paused"), and use queue.queue(name).resume()
whenever the resolved override is false. Keep the persistence logic and the
live-state synchronization aligned in OverridesHandlers.putQueueOverride.

---

Nitpick comments:
In `@sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OpsHandlers.java`:
- Around line 64-72: The readiness endpoint in OpsHandlers.readiness is
hardcoded to report healthy state, so replace the static storage=true and
always-ready status with a real lightweight health probe before building the
response. Use an actual settings/storage check (or another minimal backend read)
to determine the storage check result, and derive the top-level status from the
collected checks instead of always returning "ready". If this is meant to remain
a stub, make that explicit in the method name or response so callers do not
treat it as a real readiness signal.

In
`@sdks/java/src/main/java/org/byteveda/taskito/dashboard/store/OverridesStore.java`:
- Around line 117-121: The rate_limit validation in OverridesStore currently
only checks for a non-empty string containing “/”, so invalid values like “/” or
“abc/def” still pass. Tighten the validation in the rate_limit case to require a
well-formed count/period value with both sides present and meaningful (for
example, non-empty numeric count and non-empty period), using the same
DashboardError.badRequest path when the format is invalid.

In
`@sdks/java/src/test/java/org/byteveda/taskito/dashboard/DashboardOpsTest.java`:
- Around line 102-114: Add a test case in DashboardOpsTest to cover the
metrics-token-configured behavior: set TASKITO_DASHBOARD_METRICS_TOKEN, start
DashboardServer via DashboardServer.start, and verify that /health and
/readiness still return the expected ok/ready responses while /metrics remains
protected by the bearer token. Use the existing probes in probesAreServed and
the same server/queue setup to lock in the intended contract around
DashboardServer and its readiness/metrics gating.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f629ca58-e24c-455c-9db4-591d746039a9

📥 Commits

Reviewing files that changed from the base of the PR and between 78d4052 and c392402.

📒 Files selected for processing (15)
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/DashboardServer.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/Contract.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/CoreHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/Metrics.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/MetricsHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OpsHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/OverridesHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/SettingsHandlers.java
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/store/OverridesStore.java
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/DashboardClient.java
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/DashboardOpsTest.java
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/InMemorySettings.java
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/api/SettingsHandlersTest.java
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/auth/AuthStoreTest.java
  • sdks/java/src/test/java/org/byteveda/taskito/dashboard/store/OverridesStoreTest.java
💤 Files with no reviewable changes (1)
  • sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/CoreHandlers.java

Comment thread sdks/java/src/main/java/org/byteveda/taskito/dashboard/api/MetricsHandlers.java Outdated
Addresses PR review: malformed numeric query params (since/limit/offset/target/bucket) now return 400 via a shared guarded parser instead of an uncaught NumberFormatException (500); clearing a queue's paused override now resumes the live queue (reconcile from the resulting row, not the request value).
@pratyush618

Copy link
Copy Markdown
Collaborator Author

Addressed all review comments in 19b385e:

  • Query-param validation — malformed numeric params (since/limit/offset/target/bucket) now return 400 via a shared guarded parser (Http.longParam/intParam) instead of an uncaught NumberFormatException (500). Added a regression test.
  • Paused override — clearing a queue's paused override now resumes the live queue; the reconcile reads the resulting override row rather than the request value, so paused: null no longer leaves the queue paused.

Resolving the threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant