This guide is for developers who want to build, test, or contribute to the workload-exporter tool.
- Go 1.23 or later
- Git
# Clone the repository
git clone https://github.com/cockroachlabs/workload-exporter.git
cd workload-exporter
# Get dependencies
go mod tidy
# Build
go build -o workload-exporterTo include version information in the binary:
go build -ldflags="-X main.Version=v1.4.0 -X main.Commit=abc12345 -X main.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o workload-exporterThe project includes a Makefile for common tasks:
make help # Show available commands
make build # Build the binary
make test # Run unit tests
make test-integration # Run integration tests
make lint # Run linter
make clean # Clean build artifactsRun the standard test suite:
make test
# or
go test -v ./...See TESTING.md for comprehensive testing documentation.
workload-exporter/
├── cmd/ # CLI commands
│ ├── root.go # Root command
│ ├── export.go # Export command
│ ├── update.go # Update command
│ └── version.go # Version command
├── pkg/
│ ├── export/ # Core export functionality
│ │ ├── exporter.go # Main exporter logic
│ │ └── exporter_test.go # Unit tests
│ └── update/ # Self-update functionality
│ ├── update.go # Update check, caching, and semver comparison
│ ├── selfupdate.go # Binary download, checksum verification, and replacement
│ ├── update_test.go # Unit tests for update checking
│ └── selfupdate_test.go # Unit tests for self-update
├── docs/ # Documentation
├── Makefile # Build automation
└── go.mod # Go dependencies
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run tests:
make test - Run linter:
make lint - Submit a pull request
- Update version in relevant files
- Run integration tests:
make test-integration - Create git tag:
git tag v1.x.x - Push tag:
git push origin v1.x.x - GitHub Actions will build and publish release binaries
The project uses golangci-lint for code quality:
# Run linter
make lint
# Or directly
golangci-lint run --timeout=5mEnable debug logging when running the exporter:
./workload-exporter export -c "connection-string" --debugThis will show detailed information about each step of the export process.