Repository navigation
✨ feat(operations): complete v0.8 observability - #73
Conversation
biggest-littlest
left a comment
There was a problem hiding this comment.
Reviewed the v0.8 operations contract, tests, and deployment examples. Approving.
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds structured Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ 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 |
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Reviewed the health/metrics/audit surface and generated documentation artifacts. Approving.
060c638
biggest-littlest
left a comment
There was a problem hiding this comment.
Re-reviewed the integration-test correction on the latest commit. Approval remains.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Re-reviewed the latest commit and typed operational-health integration assertions. Approval remains.
8014d93
biggest-littlest
left a comment
There was a problem hiding this comment.
Reviewed the latest 8014d93 commit, including the focused YAML document-separator fix and passing local Qlty validation.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Approved the current 8014d93 head after the Kubernetes YAML fix and exact CI-quality validation.
245755e
biggest-littlest
left a comment
There was a problem hiding this comment.
Reviewed current head 245755e: operations contract coverage now passes the unchanged 96% CI floor, with focused tests for audit, metrics, and edge health semantics.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Approved 245755e after verifying the new runtime contract tests and unchanged quality thresholds.
e3eb9b2
biggest-littlest
left a comment
There was a problem hiding this comment.
Reviewed current e3eb9b2 head. The added live-tail failure-path tests lift exact aggregate statement coverage to 96.31% without changing the 96% floor.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Approved e3eb9b2 after deterministic cross-platform coverage headroom and full local quality/pre-push validation.
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (8)
examples/observability/docker-compose.yml (2)
29-37: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueFluent Bit pinned slightly behind latest patch.
v5.0.6is a few patch releases behind the currentv5.0.9. Not urgent, but worth tracking for the maintenance/hardening fixes in later 5.0.x releases.🤖 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 `@examples/observability/docker-compose.yml` around lines 29 - 37, Update the image tag and digest in the x-audit-forwarder-runtime definition to the current Fluent Bit 5.0.9 release, ensuring the digest matches that exact image while preserving the existing runtime hardening settings.
80-87: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winEphemeral Fluent Bit state risks duplicate audit forwarding on restart.
audit-forwarder-runtimemounts/var/lib/fluent-bitastmpfs; the tail-position DB is lost on every container restart, and withRead_from_Head truethe sidecar will re-tail and re-forward already-shipped audit records to whatever downstream sink replaces the demostdoutoutput. See root-cause note on the shared config template.Also applies to: 119-126
🤖 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 `@examples/observability/docker-compose.yml` around lines 80 - 87, Update the audit-forwarder-runtime configuration and both standard and alternate audit-forwarder services so Fluent Bit’s tail-position database is persisted on the host rather than mounted as tmpfs. Preserve the existing database path and volume intent, ensuring restart recovery retains offsets and prevents re-forwarding previously shipped audit records.examples/kubernetes/standard.yaml (1)
156-192: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSidecar config mounted via
subPathwon't hot-reload; DB is ephemeral.
subPath: fluent-bit.conf(line 169) disables Kubelet's automatic ConfigMap update propagation — editing theportwing-audit-forwarderConfigMap silently has no effect until the pod is manually restarted. Worth a comment for operators.audit-forwarder-stateis anemptyDir(also true for Compose'stmpfs), so Fluent Bit's tail-position DB is lost on every restart; combined withRead_from_Head truethis re-forwards already-shipped audit records downstream after a crash/reschedule.🤖 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 `@examples/kubernetes/standard.yaml` around lines 156 - 192, Document the audit-forwarder configuration behavior near the `audit-forwarder-config` volume mount and `audit-forwarder-state` usage: note that mounting `fluent-bit.conf` through `subPath` requires a pod restart for ConfigMap changes to take effect, and that the ephemeral state volume loses Fluent Bit’s tail-position database on restart, causing `Read_from_Head` to re-forward existing audit records. Keep the deployment behavior unchanged.internal/server/metrics_prom.go (1)
22-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse
elapsedSeconds; rawtime.Sincereports ~1.7e9 on a zerostartTime.
http.gojust added the guarded helper in this same package — use it so uptime is consistent across/health,/ready, and/metrics.♻️ Proposed fix
- fmt.Fprintf(&b, "portwing_uptime_seconds %g\n", time.Since(s.startTime).Seconds()) + fmt.Fprintf(&b, "portwing_uptime_seconds %g\n", elapsedSeconds(s.startTime))Drop the
timeimport if nothing else in the file uses it.🤖 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 `@internal/server/metrics_prom.go` around lines 22 - 24, Update the metrics uptime output in the metrics handler to use the package-level elapsedSeconds helper instead of calculating time.Since(s.startTime) directly, preserving consistent guarded uptime behavior across endpoints. Remove the time import if it becomes unused.internal/metrics/runtime_prom.go (1)
85-120: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winPer-call timeouts don't bound total scrape latency.
With 8 workers and a 10s per-request timeout, a slow daemon and many containers make this run
ceil(N/8) × 10s. A scrape can outlive Prometheus' own timeout while holding goroutines and a Docker connection each. Derive one collection deadline and let each stats call inherit it.♻️ Bound the whole collection
const maxWorkers = 8 + collectCtx, cancelCollect := context.WithTimeout(ctx, 10*time.Second) + defer cancelCollect() results := make([]containerResult, len(containers)) @@ - statsCtx, cancel := context.WithTimeout(ctx, 10*time.Second) - defer cancel() - stats, err := client.ContainerStats(statsCtx, id) + stats, err := client.ContainerStats(collectCtx, id) if err != nil { return }Dropped
ContainerStatserrors are also invisible here; aslog.Debugon the error path would make partial metric output diagnosable.As per coding guidelines, "use
log/slogfor structured logging only."🤖 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 `@internal/metrics/runtime_prom.go` around lines 85 - 120, Update the container stats collection around the goroutine loop to derive one shared collection deadline from ctx, and have each ContainerStats call use that deadline instead of creating an independent 10-second timeout. Preserve bounded concurrency and partial-result behavior, and add a structured slog.Debug entry on the ContainerStats error path including the container identifier and error details.Source: Coding guidelines
internal/server/http.go (1)
257-261: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win
/readyadds a second unauthenticated, un-rate-limited Docker probe path.Each hit costs a Docker daemon round-trip bounded only by the request context.
/_portwing/healthalready had this shape, so no new capability, but the surface doubles. Consider wrapping both withs.rateLimiter.rateLimitOnlyand givingPingits own short timeout so a wedged Docker socket cannot pin probe handlers.As per path instructions,
internal/**is a "Security-critical proxy path with a default-deny posture. Flag new Docker API surface or endpoints that bypass explicit filtering."🤖 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 `@internal/server/http.go` around lines 257 - 261, Update registerRoutes and the health handlers so both unauthenticated Docker-backed probe endpoints, /_portwing/health and /ready, pass through s.rateLimiter.rateLimitOnly. Give the Docker Ping operation in the relevant handler its own short timeout instead of relying solely on the request context, while preserving the existing health responses and keeping /health behavior unchanged.Source: Path instructions
internal/metrics/appmetrics_test.go (1)
253-288: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a case asserting edge metrics are hidden when
edgeModeis false.Only the edge-enabled path is tested. The gating in
WritePrometheusexists specifically to keep standard-mode output free of a misleading disconnected gauge — worth a negative assertion so a regression there doesn't slip through silently.♻️ Suggested addition
reg2 := metrics.NewRegistry() body2 := output(reg2) for _, unwanted := range []string{ "portwing_edge_controller_connected", "portwing_edge_reconnects_total", "portwing_edge_backpressure_events_total", } { if strings.Contains(body2, unwanted) { t.Errorf("standard-mode output should omit %q:\n%s", unwanted, body2) } }🤖 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 `@internal/metrics/appmetrics_test.go` around lines 253 - 288, Extend TestRegistryOperationalMetrics with a standard-mode case using a fresh metrics.NewRegistry without SetEdgeMode, then assert output(reg2) omits the edge metric names portwing_edge_controller_connected, portwing_edge_reconnects_total, and portwing_edge_backpressure_events_total. Keep the existing edge-enabled assertions unchanged.internal/edge/client.go (1)
1047-1051: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse the existing Prometheus label-value escape helper.
internal/edge/client.gocurrently definesescapePrometheusLabelseparately even though the same escaping exists asinternal/server/metrics_prom.go:escapeLabelValue. Move this helper to a sharedinternalpackage with tests and use it frominternal/edge/client.goandinternal/server/metrics_prom.goto avoid divergent label escaping.🤖 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 `@internal/edge/client.go` around lines 1047 - 1051, Move the duplicate escapePrometheusLabel logic into a shared internal helper, reusing the existing escapeLabelValue behavior, and add tests covering its escaping. Update internal/edge/client.go and internal/server/metrics_prom.go to call the shared helper, removing their local implementations so label escaping remains consistent.
🤖 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 `@api/openapi.yaml`:
- Around line 109-139: The health response examples for /_portwing/health must
satisfy the schema’s full required set. Update the compatibility-alias examples
and the 503 example to include live, ready, mode, version, uptimeSeconds, and
controller alongside their existing fields, or remove those examples and rely on
the schema.
In `@examples/kubernetes/observability-edge.yaml`:
- Around line 14-18: Replace the portwing-edge static target in the
portwing-edge scrape job with Kubernetes pod discovery for namespace portwing,
selecting pods labeled app: portwing-edge and scraping their metrics endpoint on
port 3000. Update Prometheus RBAC to grant read-only list access to pods and
endpoints, preserving the existing observability configuration and permissions
scope.
In `@examples/kubernetes/standard.yaml`:
- Around line 26-49: Define the referenced Fluent Bit parser in each
configuration by adding a [PARSER] block named json to standard.yaml, edge.yaml,
and fluent-bit.conf. Ensure the parser is included in the active parsers
configuration used by the existing Parser json input setting.
In `@examples/observability/docker-compose.yml`:
- Around line 20-27: Update the x-prometheus-runtime image reference to a
patched Prometheus tag and matching SHA that includes the sanitize-html fix. In
the prometheus-standard and prometheus-edge services, remove direct 9090 host
publishing or place it behind the existing authentication mechanism while
preserving container access on port 9090.
In `@examples/README.md`:
- Around line 12-18: Remove the kubectl namespace creation command from the
shared setup block in the README so Compose workflows do not require Kubernetes
or modify a cluster. Add the equivalent namespace setup command before each
Kubernetes-mode workflow, while leaving the token generation and Docker socket
group setup shared.
In `@internal/server/audit_export.go`:
- Around line 40-49: Remove the audit-export metric updates from the plain
audit-read handler handleAudit, including both the failed JSON encoding path and
the successful recordAuditExport call. Keep export metric accounting exclusively
in handleAuditExport while preserving the existing audit response behavior.
---
Nitpick comments:
In `@examples/kubernetes/standard.yaml`:
- Around line 156-192: Document the audit-forwarder configuration behavior near
the `audit-forwarder-config` volume mount and `audit-forwarder-state` usage:
note that mounting `fluent-bit.conf` through `subPath` requires a pod restart
for ConfigMap changes to take effect, and that the ephemeral state volume loses
Fluent Bit’s tail-position database on restart, causing `Read_from_Head` to
re-forward existing audit records. Keep the deployment behavior unchanged.
In `@examples/observability/docker-compose.yml`:
- Around line 29-37: Update the image tag and digest in the
x-audit-forwarder-runtime definition to the current Fluent Bit 5.0.9 release,
ensuring the digest matches that exact image while preserving the existing
runtime hardening settings.
- Around line 80-87: Update the audit-forwarder-runtime configuration and both
standard and alternate audit-forwarder services so Fluent Bit’s tail-position
database is persisted on the host rather than mounted as tmpfs. Preserve the
existing database path and volume intent, ensuring restart recovery retains
offsets and prevents re-forwarding previously shipped audit records.
In `@internal/edge/client.go`:
- Around line 1047-1051: Move the duplicate escapePrometheusLabel logic into a
shared internal helper, reusing the existing escapeLabelValue behavior, and add
tests covering its escaping. Update internal/edge/client.go and
internal/server/metrics_prom.go to call the shared helper, removing their local
implementations so label escaping remains consistent.
In `@internal/metrics/appmetrics_test.go`:
- Around line 253-288: Extend TestRegistryOperationalMetrics with a
standard-mode case using a fresh metrics.NewRegistry without SetEdgeMode, then
assert output(reg2) omits the edge metric names
portwing_edge_controller_connected, portwing_edge_reconnects_total, and
portwing_edge_backpressure_events_total. Keep the existing edge-enabled
assertions unchanged.
In `@internal/metrics/runtime_prom.go`:
- Around line 85-120: Update the container stats collection around the goroutine
loop to derive one shared collection deadline from ctx, and have each
ContainerStats call use that deadline instead of creating an independent
10-second timeout. Preserve bounded concurrency and partial-result behavior, and
add a structured slog.Debug entry on the ContainerStats error path including the
container identifier and error details.
In `@internal/server/http.go`:
- Around line 257-261: Update registerRoutes and the health handlers so both
unauthenticated Docker-backed probe endpoints, /_portwing/health and /ready,
pass through s.rateLimiter.rateLimitOnly. Give the Docker Ping operation in the
relevant handler its own short timeout instead of relying solely on the request
context, while preserving the existing health responses and keeping /health
behavior unchanged.
In `@internal/server/metrics_prom.go`:
- Around line 22-24: Update the metrics uptime output in the metrics handler to
use the package-level elapsedSeconds helper instead of calculating
time.Since(s.startTime) directly, preserving consistent guarded uptime behavior
across endpoints. Remove the time import if it becomes unused.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b38408e0-dff7-4383-a716-d036282b304b
⛔ Files ignored due to path filters (1)
CHANGELOG.mdis excluded by!CHANGELOG.md
📒 Files selected for processing (42)
DockerfileDockerfile.armv7Dockerfile.devDockerfile.releaseREADME.mdSTABILITY.mdapi/openapi.yamldocs/content/docs/api-reference.mdxdocs/content/docs/audit-logging.mdxdocs/content/docs/observability.mdxdocs/content/docs/stability-policy.mdxexamples/README.mdexamples/kubernetes/edge.yamlexamples/kubernetes/observability-edge.yamlexamples/kubernetes/observability-standard.yamlexamples/kubernetes/standard.yamlexamples/observability/docker-compose.ymlexamples/observability/fluent-bit.confexamples/observability/prometheus.edge.ymlexamples/observability/prometheus.standard.ymlinternal/audit/audit.gointernal/audit/audit_extra_test.gointernal/audit/ring.gointernal/audit/ring_test.gointernal/edge/client.gointernal/edge/client_test.gointernal/edge/harness_test.gointernal/edge/wire_contract_test.gointernal/integration/integration_test.gointernal/metrics/appmetrics.gointernal/metrics/appmetrics_test.gointernal/metrics/runtime_prom.gointernal/metrics/runtime_prom_test.gointernal/server/audit_export.gointernal/server/audit_export_test.gointernal/server/coverage_test.gointernal/server/http.gointernal/server/metrics_prom.gointernal/server/operations_health_test.gowebsite/src/app/data/features.tswebsite/src/app/data/roadmap.tswebsite/vercel.json
Summary
Verification
go test -race ./...golangci-lint rungo build ./cmd/portwingnpm run buildqlty check --no-progressdocker compose ... config -qCloses #68
Changelog
/healthand/readyendpoints with structured liveness, readiness, version, uptime, Docker, and controller state.Concerns
/_portwing/healthto/healthor/readyas intended.409cursor semantics consistently distinguish overwritten history from agent restarts./metricsexposure and ensure deployments restrict it to private networks.