-
Notifications
You must be signed in to change notification settings - Fork 180
test: validate metrics compatibility with Grafana scrapper #6150
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds a Go-based Prometheus metrics validator tool, integrates it into calibnet test scripts, documents local usage, and updates CI to set up Go and run the validator's tests. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Script as calibnet_other_check.sh
participant Node as Forest Node (:6116)
participant Validator as prometheus_metrics_validator (go run)
Script->>Node: GET /metrics
Node-->>Script: metrics text
Script->>Validator: go run main.go metrics.log
Validator->>Validator: Validate(metrics)
alt parse ok
Validator-->>Script: exit 0 (valid)
else parse error
Validator-->>Script: exit 1 (invalid)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.5.0)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies" Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tools/README.md (1)
1-10
: Clarify the working directory for test commands.The unit test command
go test -v .
implies it should be run fromtools/prometheus_metrics_validator/
, but this isn't explicitly stated. Consider adding a note about the working directory or using the full path as in the CI workflow.Apply this diff to clarify:
### Unit tests -- run `go test -v .` +Run from the repository root: +```bash +go test -v ./tools/prometheus_metrics_validator +``` + +Or from the `tools/prometheus_metrics_validator/` directory: +```bash +go test -v . +``` ### Validate Forest metricstools/prometheus_metrics_validator/main.go (1)
45-60
: Consider documenting the textparse.New boolean parameters.The
textparse.New
call uses three boolean parameters (false, false, true
) whose purpose is unclear without referring to the Prometheus documentation. Adding a brief comment would improve code maintainability.Apply this diff to add clarity:
func Validate(metrics []byte) error { + // textparse.New parameters: content, contentType, timestamp, parseClassicHistograms, skipMetrics, enableUTF8, symbolTable p, err := textparse.New(metrics, "text/plain", "", false, false, true, labels.NewSymbolTable()) if err != nil { return err
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
go.work
is excluded by!**/*.work
tools/prometheus_metrics_validator/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (7)
.github/workflows/forest.yml
(2 hunks)scripts/tests/calibnet_other_check.sh
(1 hunks)tools/README.md
(1 hunks)tools/prometheus_metrics_validator/.gitignore
(1 hunks)tools/prometheus_metrics_validator/go.mod
(1 hunks)tools/prometheus_metrics_validator/main.go
(1 hunks)tools/prometheus_metrics_validator/main_test.go
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tools/prometheus_metrics_validator/main_test.go (1)
tools/prometheus_metrics_validator/main.go (1)
Validate
(45-60)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: tests-release
- GitHub Check: tests
- GitHub Check: Build forest binaries on Linux AMD64
- GitHub Check: Diff snapshot export checks
- GitHub Check: V1 snapshot export checks
🔇 Additional comments (7)
.github/workflows/forest.yml (2)
86-88
: LGTM! Go test step is correctly configured.The test command targets the correct path and will run the validator's unit tests during CI.
161-163
: LGTM! Go setup is required for metrics validation.The calibnet-check job correctly sets up Go before running the validation script that invokes the metrics validator.
tools/prometheus_metrics_validator/main.go (1)
15-43
: LGTM! CLI implementation is clean and functional.The CLI properly handles file reading, validation, and error reporting. The use of
os.Exit(1)
on validation failure is appropriate for a CLI tool.tools/prometheus_metrics_validator/main_test.go (1)
9-45
: LGTM! Test coverage is appropriate.The tests cover key scenarios:
- Metrics without EOF marker
- Metrics with proper metadata (HELP, TYPE, UNIT) and EOF
- Invalid syntax with unsupported characters
This provides good baseline coverage for the validator's core functionality.
scripts/tests/calibnet_other_check.sh (1)
83-85
: LGTM! Metrics validation is properly integrated.The script correctly:
- Downloads metrics from the Forest node
- Invokes the validator to check compatibility
Using
go run
is appropriate for the CI environment and keeps the script simple.tools/prometheus_metrics_validator/go.mod (2)
6-6
: Prometheus module tag and parser import are correct v0.306.0 maps to Prometheus v3.6.0; import the text parser from "github.com/prometheus/prometheus/model/textparse".
3-3
: Go version 1.25.2 is valid Thego version
command downloads and runs go1.25.2 without error.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #6064
Other information and links
Change checklist
Summary by CodeRabbit