Skip to content

[superlog] Warn on tracking health ClickHouse timeouts#516

Merged
izadoesdev merged 1 commit into
stagingfrom
codex/superlog-warn-tracking-health-timeouts
Jun 30, 2026
Merged

[superlog] Warn on tracking health ClickHouse timeouts#516
izadoesdev merged 1 commit into
stagingfrom
codex/superlog-warn-tracking-health-timeouts

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Jun 30, 2026

Copy link
Copy Markdown
Member

Clean replacement for #468, based on staging.\n\nWhat changed:\n- Adds a tested tracking-health log-level helper.\n- Downgrades only the canonical ClickHouse tracking-health timeout to WARN.\n- Keeps unexpected tracking event / blocked-traffic failures at ERROR.\n- Reuses one timeout message constant for both tracking-health ClickHouse probes.\n\nVerification:\n- cd packages/rpc && bun test src/routers/tracking-health-errors.test.ts\n- bunx ultracite check packages/rpc/src/routers/websites.ts packages/rpc/src/routers/tracking-health-errors.ts packages/rpc/src/routers/tracking-health-errors.test.ts\n- cd packages/rpc && bun run check-types\n- cd packages/rpc && bun run test\n- bun run lint\n- bun run check-types\n- bun run test


Summary by cubic

Downgraded the canonical ClickHouse tracking-health timeout to warn to reduce noisy error logs. Added a small helper and constant to centralize log-level handling while keeping unexpected failures at error.

  • Bug Fixes
    • Websites router logs tracking-health ClickHouse timeouts as warn; unexpected/blocked-traffic errors stay at error.
    • Introduced CLICKHOUSE_TRACKING_HEALTH_TIMEOUT_MESSAGE and getTrackingHealthErrorLogLevel() and applied to both probes.
    • Added tests for log-level behavior.

Written for commit 3b5da1d. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboard Ready Ready Preview, Comment Jun 30, 2026 4:25pm
databuddy-status Ready Ready Preview, Comment Jun 30, 2026 4:25pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
documentation Skipped Skipped Jun 30, 2026 4:25pm

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 77895bea-1f83-4619-b0f3-fd03f531c9e3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/superlog-warn-tracking-health-timeouts

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.

❤️ Share

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

@unkey-deploy

unkey-deploy Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
api (preview) Failed Visit Preview Inspect Jun 30, 2026 4:25pm

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extracts the ClickHouse tracking-health timeout into a shared constant and a small getTrackingHealthErrorLogLevel helper that downgrades exact-match timeout errors from ERROR to WARN, keeping all other failures at ERROR.

  • tracking-health-errors.ts: New module exporting CLICKHOUSE_TRACKING_HEALTH_TIMEOUT_MESSAGE and the pure log-level classifier; replaces two identical hardcoded string literals in websites.ts.
  • websites.ts: Both getTrackingEventsStatus and getRecentBlockedTrackingIssue now use the shared constant in their setTimeout rejections and route their catch blocks through the helper.
  • tracking-health-errors.test.ts: Covers the WARN path, the non-matching Error path, and the non-Error value path.

Confidence Score: 4/5

Safe to merge — changes are narrowly scoped to log-level routing for a known, self-generated timeout error; no data path or return value is affected.

Both catch blocks now resolve log level through a pure, unit-tested helper, and the only call-sites of the new constant are the same setTimeout rejections that produced the original hardcoded string. The one rough edge is a hardcoded string literal in the test file that duplicates the constant's value — minor and non-blocking, but worth tidying before the constant is ever renamed.

No files require special attention; the test file has a minor literal duplication worth a quick fix.

Important Files Changed

Filename Overview
packages/rpc/src/routers/tracking-health-errors.ts New helper module: exports a constant for the timeout message and a pure getTrackingHealthErrorLogLevel function that downgrades exact-match timeout errors to "warn". Logic is tight and correct.
packages/rpc/src/routers/tracking-health-errors.test.ts Three-case unit test suite for the new helper; the third test duplicates the constant's string value as a literal rather than using the imported constant.
packages/rpc/src/routers/websites.ts Replaces two hardcoded timeout-string literals with the shared constant and routes both catch-blocks through getTrackingHealthErrorLogLevel for consistent WARN/ERROR classification.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ClickHouse query / Promise.race] --> B{Race resolves?}
    B -- yes --> C[Return result]
    B -- no / timeout --> D["reject(new Error(CLICKHOUSE_TRACKING_HEALTH_TIMEOUT_MESSAGE))"]
    D --> E[catch block]
    E --> F[getTrackingHealthErrorLogLevel]
    F --> G{error instanceof Error\nAND message === constant?}
    G -- yes --> H["level = 'warn'"]
    G -- no --> I["level = 'error'"]
    H --> J["logger.warn(...)"]
    I --> K["logger.error(...)"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[ClickHouse query / Promise.race] --> B{Race resolves?}
    B -- yes --> C[Return result]
    B -- no / timeout --> D["reject(new Error(CLICKHOUSE_TRACKING_HEALTH_TIMEOUT_MESSAGE))"]
    D --> E[catch block]
    E --> F[getTrackingHealthErrorLogLevel]
    F --> G{error instanceof Error\nAND message === constant?}
    G -- yes --> H["level = 'warn'"]
    G -- no --> I["level = 'error'"]
    H --> J["logger.warn(...)"]
    I --> K["logger.error(...)"]
Loading

Reviews (1): Last reviewed commit: "fix(rpc): warn on tracking health timeou..." | Re-trigger Greptile

Comment on lines +22 to +26
it("keeps non-Error values at error", () => {
expect(getTrackingHealthErrorLogLevel("ClickHouse query timeout")).toBe(
"error"
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The third test passes the raw string literal "ClickHouse query timeout" rather than the already-imported CLICKHOUSE_TRACKING_HEALTH_TIMEOUT_MESSAGE constant. If the constant's value is ever updated, the literal won't track the change and the test may silently stop exercising the intended edge-case (exact-match string as non-Error).

Suggested change
it("keeps non-Error values at error", () => {
expect(getTrackingHealthErrorLogLevel("ClickHouse query timeout")).toBe(
"error"
);
});
it("keeps non-Error values at error", () => {
expect(getTrackingHealthErrorLogLevel(CLICKHOUSE_TRACKING_HEALTH_TIMEOUT_MESSAGE)).toBe(
"error"
);
});

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@izadoesdev
izadoesdev merged commit 58876a2 into staging Jun 30, 2026
19 checks passed
@izadoesdev
izadoesdev deleted the codex/superlog-warn-tracking-health-timeouts branch June 30, 2026 16:26
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