Skip to content

test(obs): tighten missing-key test hygiene per gemini review#598

Open
bootjp wants to merge 1 commit intomainfrom
obs/redis-key-not-found-not-error
Open

test(obs): tighten missing-key test hygiene per gemini review#598
bootjp wants to merge 1 commit intomainfrom
obs/redis-key-not-found-not-error

Conversation

@bootjp
Copy link
Copy Markdown
Owner

@bootjp bootjp commented Apr 23, 2026

  • Log rdb.Close error instead of silently discarding it.
  • Gate dumpErrorMetrics behind the assertion failure so the happy path does not pay for an extra Gather of every metric family.
  • Short-circuit the three per-metric-family loops with a shared metricFamily() helper; missing families yield zero without a second Gather(), replacing the redundant testutil.GatherAndCount precheck.

- Log rdb.Close error instead of silently discarding it.
- Gate dumpErrorMetrics behind the assertion failure so the happy path
  does not pay for an extra Gather of every metric family.
- Short-circuit the three per-metric-family loops with a shared
  metricFamily() helper; missing families yield zero without a second
  Gather(), replacing the redundant testutil.GatherAndCount precheck.
@bootjp bootjp force-pushed the obs/redis-key-not-found-not-error branch from a86bcfd to 804dea0 Compare April 23, 2026 17:14
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@bootjp has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 57 minutes and 36 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 57 minutes and 36 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b466a413-03dd-48a6-aa8a-5043f086a648

📥 Commits

Reviewing files that changed from the base of the PR and between bee7ead and 804dea0.

📒 Files selected for processing (2)
  • adapter/redis_metrics_missing_key_test.go
  • go.mod
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch obs/redis-key-not-found-not-error

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 and usage tips.

@bootjp
Copy link
Copy Markdown
Owner Author

bootjp commented Apr 23, 2026

Addressed Gemini medium-priority items from the review of the #595 series:

  • rdb.Close() error now logged via t.Logf instead of discarded.
  • dumpErrorMetrics is gated behind the assertion-failure branch so the happy path does not pay for an extra Gather() each iteration.
  • Two per-metric-family loops previously kept scanning after finding the target family; extracted a shared metricFamily(mfs, name) *dto.MetricFamily helper and short-circuit at the first match. Three call sites refactored.
  • Removed the redundant testutil.GatherAndCount precheck in countErrorMetrics — the manual loop already handles a missing family by producing zero.

Verified:

  • go test -race ./adapter/... -run TestRedisMetrics_MissingKeyNotCountedAsError -count=3 → 3/3 pass.
  • golangci-lint run ./adapter/... → 0 issues.

/gemini review
@codex review

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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