Skip to content

fix(metrics): harden collect.go and modules workflow#3738

Merged
mdelapenya merged 2 commits into
testcontainers:mainfrom
mdelapenya:fix-usage-metrics-workflows
Jun 24, 2026
Merged

fix(metrics): harden collect.go and modules workflow#3738
mdelapenya merged 2 commits into
testcontainers:mainfrom
mdelapenya:fix-usage-metrics-workflows

Conversation

@mdelapenya

@mdelapenya mdelapenya commented Jun 24, 2026

Copy link
Copy Markdown
Member

Signed-off-by: mdelapenya mdelapenya@gmail.com

What does this PR do?

Address coderabbit and codex feedback from #3737

Signed-off-by: mdelapenya <mdelapenya@gmail.com>
@mdelapenya mdelapenya requested a review from a team as a code owner June 24, 2026 12:48
@netlify

netlify Bot commented Jun 24, 2026

Copy link
Copy Markdown

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 4329ca5
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/6a3be46b635cc70008599244
😎 Deploy Preview https://deploy-preview-3738--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fe20ad9f-2ffa-4b0b-9d49-a05d42f87be5

📥 Commits

Reviewing files that changed from the base of the PR and between c4c6a12 and 4329ca5.

📒 Files selected for processing (2)
  • usage-metrics/collect.go
  • usage-metrics/collect_test.go
✅ Files skipped from review due to trivial changes (1)
  • usage-metrics/collect_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • usage-metrics/collect.go

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of usage-metrics collection by stopping immediately if CSV output cannot be written.
    • Added a timeout to search requests and return a clearer timeout error when exceeded.
    • Treated timeout/deadline-exceeded errors as retryable to improve resilience.
    • Strengthened CSV processing by validating each row has the expected number of columns before sorting.
    • Improved workflow branch update dependability by using an explicit ref when fetching the target branch.
  • Tests
    • Added coverage to confirm deadline-exceeded errors are considered retryable.

Walkthrough

The workflow's module input handling now uses a step-level environment variable, and branch checkout uses an explicit fetch refspec. The usage-metrics collector adds timeout-based gh api execution, fatal CSV write handling, CSV row validation, and retry coverage for deadline errors.

Changes

Usage metrics robustness improvements

Layer / File(s) Summary
Workflow input and fetch
.github/workflows/usage-metrics-modules.yml
The “Query modules” step reads module input from MODULES_INPUT instead of inline interpolation, and the existing-branch fetch writes the branch into refs/remotes/origin/$BRANCH_NAME.
Collector timeout and validation
usage-metrics/collect.go, usage-metrics/collect_test.go
collect.go adds context, returns an error when appendToCSV fails, runs gh api with a 30-second timeout and deadline-specific handling, treats context.DeadlineExceeded as retryable, and rejects CSV rows with fewer than two columns; the test file adds coverage for the deadline retry case.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

chore, github_actions

Poem

🐇 A bunny hopped through metrics bright,
With timed-out calls and CSVs tight.
If branches fetch and rows don’t fit,
The collector now won’t just skip it.
Hop hop—retry, validate, and rest,
This little PR does its best!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes to metrics collection and the modules workflow.
Description check ✅ Passed The description is related to the PR because it references addressing feedback for the same changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4c6a1259e

ℹ️ 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".

Comment thread usage-metrics/collect.go
Signed-off-by: mdelapenya <mdelapenya@gmail.com>
@mdelapenya mdelapenya self-assigned this Jun 24, 2026
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Jun 24, 2026
@mdelapenya mdelapenya merged commit 6708e33 into testcontainers:main Jun 24, 2026
17 checks passed
@mdelapenya mdelapenya deleted the fix-usage-metrics-workflows branch June 24, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Changes that do not impact the existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant