You've already forked node_exporter
mirror of
https://github.com/prometheus/node_exporter.git
synced 2026-10-23 08:09:06 +03:00
* [CHORE] adding agents.md Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com> * Address review feedback: link naming conventions, note procfs usage Signed-off-by: Nicolas Takashi <nicolas.takashi@dash0.com> * Trim AGENTS.md per review: drop directory-listing sections, keep non-inferable rules Signed-off-by: Nicolas Takashi <nicolas.takashi@dash0.com> --------- Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com> Signed-off-by: Nicolas Takashi <nicolas.takashi@dash0.com>
3.7 KiB
3.7 KiB
AGENTS.md
Rules
- Collector availability is controlled by Go build tags and OS-specific filenames; check
//go:buildlines before assuming a collector exists on the current OS. - Use
kingpin.Flag(), neverkingpin.Flag().Envar(): the project has a "one-way-to-configure" policy of CLI flags only. Runtime env vars (GOMAXPROCS) and deprecated collectors are the only historical exceptions; maintainers have rejected env var flags for new code. - Collector code must not shell out:
.golangci.ymldeniesos/execoutside tests, andCONTRIBUTING.mdsays collectors may read/proc,/sys, use syscalls, or local sockets only. - Keep metrics in the
nodenamespace, follow the Prometheus metric naming conventions, and update README collector tables when adding, removing, enabling, disabling, or changing collector flags. - Parse
/procfiles via theprocfsdependency rather than adding ad-hoc parsing in a collector; extendprocfsupstream if a needed file isn't covered yet.
Build And Test Commands
- Full CI-like local check is
make; it runs vet, metric/rule checks, shared Prometheus checks, 32-bit tests when supported, and Linux e2e only. - Focused unit tests:
go test ./collector -run TestNameorgo test ./... -run TestName; usemake testwhen tests need unpacked fixtures. make testunpackscollector/fixtures/sys.ttarandcollector/fixtures/udev.ttar, then runsgo test -short $(test-flags) ./....make buildusespromuand writes./node_exporter, whichmake test-e2eexpects; root tests innode_exporter_test.goskip unless a binary exists at$GOPATH/bin/node_exporter.make test-e2eis Linux-only from the main Makefile path; it depends onmake build, fixture unpacking, andmake tools.make checkmetricsdownloads/usespromtooland checkscollector/fixtures/e2e-output*.txt; run it after metric output changes.- Lint/format shortcuts:
make format,make lint,make lint-fix,make yamllint,make unused.
Fixtures And Generated Outputs
- Do not edit unpacked
collector/fixtures/sys/orcollector/fixtures/udev/as source of truth; updatecollector/fixtures/sys.ttarandcollector/fixtures/udev.ttarwithmake update_fixtures. - To refresh e2e metric golden files, run
make build toolsfirst, then./end-to-end-test.sh -u; it writes the appropriatecollector/fixtures/e2e-output*.txt. end-to-end-test.shfilters collector flags by OS/build context usingtools/tools match, so an ignored flag in e2e may mean the collector is build-tag-gated for that platform rather than broken (seeRules).
Toolchain Notes
go.mod's Go directive is not the source of truth for the toolchain version CI actually uses; check the workflow'ssetup-gostep and.promu.yml/.promu-cgo.yml, which can each pin a different version.Makefile.commonis shared Prometheus infrastructure; comments say to open PRs againstprometheus/prometheus/Makefile.commonfor generic changes.- golangci-lint version comes from
make print-golangci-lint-version(GOLANGCI_LINT_VERSIONinMakefile.common), not from a locally installed default. - Docker builds produce per-arch images named
$(DOCKER_REPO)/node-exporter-linux-<arch>:$(DOCKER_IMAGE_TAG)and coverDockerfileplusDockerfile.*variants.
Node Mixin
- Mixin checks are separate: CI runs
make promtool,make -C docs/node-mixin clean,make -C docs/node-mixin jb_install, thenmake -C docs/node-mixinand expectsgit diff --exit-code. docs/node-mixinrequiresjsonnet,jsonnetfmt, andjb; generated files arenode_alerts.yaml,node_rules.yaml, anddashboards_out/.