Skip to content

Commit 66d2398

Browse files
authored
CI: Create darwin universal binary and arm64 binary (#11)
1 parent def45ac commit 66d2398

File tree

2 files changed

+150
-3
lines changed

2 files changed

+150
-3
lines changed

.github/workflows/build.yml

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,70 @@ on:
33
push:
44
branches: [ master ]
55
pull_request:
6+
67
jobs:
78
build:
89
runs-on: ${{ matrix.os }}
910
strategy:
1011
matrix:
11-
os: [ubuntu-22.04, macos-13, macos-14] # linux-x86_64, darwin-x86_64, darwin-arm64
12+
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-13, macos-14] # linux-x86_64, linux-arm64, darwin-x86_64, darwin-arm64
1213
steps:
1314
- uses: actions/checkout@v4
1415
- uses: actions/setup-go@v4
1516
with:
16-
go-version: '1.23.6'
17+
go-version: '1.23.11'
1718
- run: make test
1819
- run: make package
19-
- run: shasum -a 256 node_exporter node_exporter*.tar.gz
20+
- run: shasum -a 256 node_exporter node_exporter*.tar.gz | tee checksums-${{ matrix.os }}.txt
2021
- uses: actions/upload-artifact@v4
2122
with:
2223
name: package-${{ matrix.os }}
2324
path: "*.tar.gz"
25+
- uses: actions/upload-artifact@v4
26+
with:
27+
name: checksums-${{ matrix.os }}
28+
path: "checksums-${{ matrix.os }}.txt"
29+
30+
create-universal-binary:
31+
runs-on: macos-14
32+
needs: build
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Download macOS x86_64 artifact
36+
uses: actions/download-artifact@v4
37+
with:
38+
name: package-macos-13
39+
path: ./macos-x86_64
40+
- name: Download macOS arm64 artifact
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: package-macos-14
44+
path: ./macos-arm64
45+
- name: Extract binaries
46+
run: |
47+
cd macos-x86_64 && tar -xzf *.tar.gz
48+
cd ../macos-arm64 && tar -xzf *.tar.gz
49+
- name: Create universal binary
50+
run: |
51+
lipo -create -output node_exporter_universal \
52+
macos-x86_64/node_exporter \
53+
macos-arm64/node_exporter
54+
- name: Verify universal binary
55+
run: |
56+
file node_exporter_universal
57+
lipo -info node_exporter_universal
58+
- name: Package universal binary
59+
run: |
60+
mv node_exporter_universal node_exporter
61+
PACKAGE_NAME=node_exporter-stable-darwin-universal.tar.gz
62+
tar -czvf ${PACKAGE_NAME} node_exporter
63+
- name: Generate checksum
64+
run: shasum -a 256 node_exporter node_exporter*.tar.gz | tee checksums-darwin-universal.txt
65+
- uses: actions/upload-artifact@v4
66+
with:
67+
name: package-darwin-universal
68+
path: "*.tar.gz"
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: checksums-darwin-universal
72+
path: "checksums-darwin-universal.txt"

CLAUDE.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a fork of the Prometheus Node Exporter that includes an additional **gateway collector** for Algod with buffering and other features. The Node Exporter is a Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors.
8+
9+
The key distinguishing feature of this fork is the `gateway.go` collector in the `collector/` directory, which provides enhanced functionality for Algorand's needs.
10+
11+
## Development Commands
12+
13+
### Building
14+
```bash
15+
make # Build with all checks (style, vet, staticcheck, checkmetrics, build, package, test)
16+
make build # Build binaries only
17+
make package # Create tarball package
18+
```
19+
20+
### Testing
21+
```bash
22+
make test # Run all tests
23+
make test-short # Run short tests only
24+
make test-e2e # Run end-to-end tests (Linux only)
25+
make test-32bit # Cross-architecture testing (when supported)
26+
```
27+
28+
### Code Quality
29+
```bash
30+
make style # Check code formatting
31+
make vet # Run go vet
32+
make staticcheck # Run staticcheck linter
33+
make checkmetrics # Validate metrics with promtool
34+
make format # Format code
35+
```
36+
37+
### Docker
38+
```bash
39+
make docker # Build Docker image
40+
make test-docker # Test Docker image
41+
```
42+
43+
## Code Architecture
44+
45+
### Core Components
46+
47+
1. **Main Entry Point** (`node_exporter.go`): HTTP server that exposes metrics at `/metrics` endpoint
48+
2. **Collector Framework** (`collector/collector.go`): Plugin architecture for metric collectors
49+
3. **Gateway Collector** (`collector/gateway.go`): Algorand-specific collector with buffering and POST handling
50+
4. **Individual Collectors** (`collector/*_*.go`): Platform-specific metric collectors
51+
52+
### Collector System
53+
54+
The Node Exporter uses a plugin-based collector system:
55+
- Collectors are registered via `registerCollector()` with default enabled/disabled state
56+
- Each collector implements the `Collector` interface with `Update(ch chan<- prometheus.Metric) error`
57+
- Collectors can be enabled/disabled via `--collector.<name>` and `--no-collector.<name>` flags
58+
- The main collector orchestrates concurrent collection from all enabled collectors
59+
60+
### Gateway Collector Architecture
61+
62+
The gateway collector (`collector/gateway.go`) provides unique functionality:
63+
- Acts as HTTP middleware, intercepting POST requests to `/metrics`
64+
- Parses Prometheus format metrics from POST body
65+
- Maintains internal counters and gauges with automatic expiration
66+
- Implements buffering with configurable sample intervals
67+
- Provides metric lifecycle management (creation, updating, expiration)
68+
69+
## Platform Support
70+
71+
Collectors have varying support across operating systems:
72+
- **Linux**: Full support for most collectors
73+
- **Darwin/macOS**: Limited support for core metrics
74+
- **BSD variants**: Platform-specific implementations
75+
- **Windows**: Use WMI exporter instead
76+
77+
## Build System
78+
79+
- Uses Go modules (`go.mod`) with Go 1.23+
80+
- Makefile-based build system with `Makefile.common` for shared rules
81+
- Cross-compilation support via `GOOS`/`GOARCH` environment variables
82+
- CGO usage controlled by `.promu-cgo.yml` vs `.promu-no-cgo.yml`
83+
- CI/CD via GitHub Actions (`.github/workflows/build.yml`)
84+
85+
## Testing Infrastructure
86+
87+
- Extensive fixture-based testing in `collector/fixtures/`
88+
- Mock `/proc` and `/sys` filesystem data for reproducible tests
89+
- End-to-end testing with expected output validation
90+
- Platform-specific test execution based on build environment
91+
92+
## Key Design Principles
93+
94+
1. **Machine Metrics Only**: Focus on hardware/OS metrics, not application metrics
95+
2. **No External Commands**: Use only system calls, proc/sys files, and local sockets
96+
3. **No Root Privileges**: All metrics must be accessible without elevated permissions
97+
4. **Hardware Agnostic**: Expose raw values without vendor-specific transformations
98+
5. **Performance First**: Concurrent collection with minimal overhead

0 commit comments

Comments
 (0)