Skip to content

fix: include metric scrape interval in agent config#223

Merged
jingxiang-z merged 2 commits into
mainfrom
fix/metric-scrape-interval-config
Jun 24, 2026
Merged

fix: include metric scrape interval in agent config#223
jingxiang-z merged 2 commits into
mainfrom
fix/metric-scrape-interval-config

Conversation

@jingxiang-z

@jingxiang-z jingxiang-z commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features

    • Added support for reporting the metric scrape interval in agent configuration data.
    • Health-check timing now uses a consistent default when no custom interval is set.
  • Bug Fixes

    • Added validation to warn on negative metric scrape interval values.
    • Improved consistency when inventory and health settings are sent through the system.
  • Tests

    • Expanded test coverage for the new interval field and default behavior.

@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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 58af7916-0884-474f-b5fa-53b16a28e22b

📥 Commits

Reviewing files that changed from the base of the PR and between c12bd9b and d9a5380.

📒 Files selected for processing (11)
  • internal/backendclient/types.go
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/enrollment/enrollment.go
  • internal/inventory/mapper/backend.go
  • internal/inventory/mapper/backend_test.go
  • internal/inventory/source/source_test.go
  • internal/inventory/types.go
  • internal/server/server.go
  • internal/validation/outbound/validator.go
  • internal/validation/outbound/validator_test.go

📝 Walkthrough

Walkthrough

Adds a MetricScrapeIntervalSeconds field to the AgentConfig struct in both the inventory and backendclient packages. Two new methods, HealthCheckInterval() and MetricScrapeIntervalSeconds(), are added to Config. The server and enrollment paths wire this value into AgentConfig initialization, the outbound validator adds a non-negative check, and all relevant tests are updated.

Changes

MetricScrapeIntervalSeconds field propagation

Layer / File(s) Summary
AgentConfig type definitions and config helpers
internal/inventory/types.go, internal/backendclient/types.go, internal/config/config.go
Adds MetricScrapeIntervalSeconds int64 to both AgentConfig structs. Adds Config.HealthCheckInterval() with a 1-minute fallback and Config.MetricScrapeIntervalSeconds() returning the interval as int64 seconds.
Server, enrollment, and mapper wiring
internal/server/server.go, internal/enrollment/enrollment.go, internal/inventory/mapper/backend.go
getHealthCheckInterval delegates to config.HealthCheckInterval(); startInventoryLoop and syncInventoryOnce populate MetricScrapeIntervalSeconds via cfg.MetricScrapeIntervalSeconds(); mapper passes the field through to the backend DTO.
Validation and tests
internal/validation/outbound/validator.go, internal/validation/outbound/validator_test.go, internal/config/config_test.go, internal/inventory/mapper/backend_test.go, internal/inventory/source/source_test.go
ValidateNodeUpsertRequest gains a validateNonNegative check for metricScrapeIntervalSeconds. Config, mapper, and source tests are updated to include the new field (60 or -1) and assert correct values or warning issues.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A new field hops in, sleek and small,
MetricScrapeIntervalSeconds — that's all!
From config to server it leaps with delight,
Through mapper and validator, the path is just right.
Sixty seconds by default, never negative, you see —
The rabbit has wired it all carefully! 🌿

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding the metric scrape interval to agent config.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/metric-scrape-interval-config

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

@jingxiang-z jingxiang-z requested a review from ooolafhu June 24, 2026 17:59
@jingxiang-z jingxiang-z self-assigned this Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@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: 06d257f8d1

ℹ️ 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 internal/backendclient/types.go
Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
@jingxiang-z jingxiang-z force-pushed the fix/metric-scrape-interval-config branch from 06d257f to d9a5380 Compare June 24, 2026 18:06
@jingxiang-z jingxiang-z merged commit 67cf5cf into main Jun 24, 2026
9 checks passed
@jingxiang-z jingxiang-z deleted the fix/metric-scrape-interval-config branch June 24, 2026 22:40
@coderabbitai coderabbitai Bot mentioned this pull request Jun 26, 2026
3 tasks
jingxiang-z added a commit that referenced this pull request Jun 27, 2026
Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
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.

2 participants