-
Notifications
You must be signed in to change notification settings - Fork 0
feat: structured JSON logging + K8s probe docs (COW-994) #87
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
Merged
lgahdl
merged 9 commits into
develop
from
luizhatem/cow-994-f19-k8s-probes-and-json-structured-logging
Jun 8, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
226208b
feat: structured JSON logging + K8s probe docs (COW-994)
lgahdl b7d8838
fix: remove decode-only-for-logging block from settlement.ts cowLog (…
lgahdl 414ae6f
fix: route warn/error to stderr in cowLog, add initialDelaySeconds to…
lgahdl 6e140fd
fix: reduce cowLogger JSDoc to single-line comment per project conven…
lgahdl d873a86
fix: rename cowLog->log/logger.ts, use /health for liveness, clarify …
lgahdl 5469030
Merge origin/develop — keep K8s probes + structured logging, rename P…
lgahdl 843c83c
feat: migrate all src/application/ log calls to structured logger (CO…
lgahdl 960c863
docs: remove specific K8s probe timing values from deployment.md (COW…
lgahdl ccff2de
chore: merge origin/develop into pr87 logger-migration branch
lgahdl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,51 @@ docker compose --profile deploy up -d | |
|
|
||
| The `Dockerfile` in the project root builds the Ponder image: two-stage Node 22 Alpine, installs dependencies with `--frozen-lockfile`, exposes port 3000, runs `pnpm start`. The health check hits `/ready` with a 24-hour start period (initial sync takes hours). | ||
|
|
||
| ### Kubernetes Probes | ||
|
|
||
| The indexer exposes two health endpoints with distinct semantics: | ||
|
|
||
| | Endpoint | Semantic | Returns 200 when | | ||
| |----------|----------|-----------------| | ||
| | `/health` | **Liveness** — is the process alive? | Always, once the server starts | | ||
| | `/ready` | **Readiness** — is the index fully synced? | Only when fully synced | | ||
|
|
||
| Map these to different K8s probe types. The specific timing values (`periodSeconds`, `failureThreshold`, `initialDelaySeconds`) depend on your cluster's SLOs; what matters is which path and port to use: | ||
|
|
||
| ```yaml | ||
| livenessProbe: | ||
| httpGet: | ||
| path: /health | ||
| port: 3000 | ||
| readinessProbe: | ||
| httpGet: | ||
| path: /ready | ||
| port: 3000 | ||
| ``` | ||
|
|
||
| **Do not** use `/ready` as the liveness probe. A pod that is still indexing (which takes hours on a cold start) returns 200 on `/health` but not on `/ready`. Using `/ready` for liveness would kill the pod before it ever finishes syncing. | ||
|
|
||
| A pod in `NotReady` state is not killed — it is simply removed from load-balancer rotation. On a cold start (no existing database), the pod will be `NotReady` for the duration of the historical backfill (hours). That is expected: the old pod (if any) keeps serving traffic during this window, and once the new pod catches up, K8s starts routing to it. | ||
|
|
||
| The Docker Compose health check uses `/ready` with a 24-hour start period as a pragmatic fallback for single-container deployments, not as a K8s-style probe. | ||
|
|
||
| ### Structured Logging | ||
|
|
||
| `pnpm start` runs with `--log-format json`, which makes both Ponder's internal log lines and the handler log lines emit newline-delimited JSON. Each handler log line includes structured fields (e.g. `chainId`, `block`) enabling log aggregators (Datadog, CloudWatch, Loki) to filter and alert by chain. | ||
|
|
||
| `pnpm dev` uses Ponder's default pretty format for readability during local development. | ||
|
|
||
| **Convention:** all code under `src/application/` uses `log()` from `src/application/helpers/logger.ts` instead of `console.log/warn/error` directly. The `src/api/` layer (Hono routes) is exempt — Hono handles its own logging. Example: | ||
|
|
||
| ```ts | ||
| import { log } from "../helpers/logger"; | ||
|
|
||
| log("info", "c2:confirmed", { chainId, orderUid, block: String(event.block.number) }); | ||
| log("warn", "c2:timeout", { chainId, block: String(event.block.number) }); | ||
| ``` | ||
|
|
||
| `warn` and `error` level messages go to `stderr`; `info` goes to `stdout`. The `level` field in the JSON payload is what log aggregators use to route and alert. | ||
|
Comment on lines
+132
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this part is necessary actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lint or pre-commit routine would be more effective |
||
|
|
||
| ### PostgreSQL Memory Flags | ||
|
|
||
| Memory settings are hardcoded in the `command:` block of `docker-compose.yml`, tuned for 1G RAM: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.