Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 15 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,23 @@ go.work.sum
# Editor/IDE
.idea/
.vscode/
.DS_Store
.cursorrules

# Binaries
/databricks-exporter
databricks-exporter
bin/
data-alloy/

# Test & development scripts
test_tables.sh
lefthook.yml
lefthook.yml

# build artifacts from `promu crossbuild`
.build

# build artifacts for mixin
mixin/prometheus_alerts.yaml

# Dependency directories (remove the comment below to include it)
# vendor/
33 changes: 33 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# golangci-lint configuration
# https://golangci-lint.run/usage/configuration/

run:
timeout: 5m

linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- goimports

linters-settings:
errcheck:
# Ignore log.Log() return values - standard Go logging pattern
exclude-functions:
- (github.com/go-kit/log.Logger).Log
- (*github.com/go-kit/log.Logger).Log
- (github.com/go-kit/log/level.Logger).Log

issues:
# Don't limit the number of issues
max-issues-per-linter: 0
max-same-issues: 0
exclude-dirs:
- mixin
- vendor

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG ARCH="amd64"
ARG OS="linux"
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:4eb7e9b

ARG ARCH="amd64"
ARG OS="linux"
Expand Down
107 changes: 102 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,107 @@
DOCKER_ARCHS ?= amd64 armv7 arm64
DOCKER_IMAGE_NAME ?= databricks-exporter
# Databricks Prometheus Exporter Makefile

ALL_SRC := $(shell find . -name '*.go' -o -name 'Dockerfile*' -type f | sort)

all:: vet common-all
# Docker settings
DOCKER_ARCHS ?= amd64 armv7 arm64
DOCKER_IMAGE_NAME ?= databricks-exporter

# Build settings
BIN_DIR := bin
BINARY_NAME := databricks-exporter
GO := go
GOFLAGS :=
pkgs := ./...

# Include common Prometheus Makefile targets
include Makefile.common

.PHONY: all
all: check build

# ============================================================================
# Quality checks
# ============================================================================

.PHONY: check
check: vet lint fmt test-exporter-unit ## Run all quality checks (vet, lint, fmt, unit-tests)

.PHONY: vet
vet: ## Run go vet
@echo ">> running go vet"
$(GO) vet $(GOFLAGS) $(pkgs)

.PHONY: lint
lint: ## Run golangci-lint (includes deadcode analysis)
@echo ">> running golangci-lint"
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run $(pkgs); \
else \
echo "golangci-lint not installed, skipping (install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)"; \
fi

.PHONY: fmt
fmt: ## Run gofmt and check for formatting issues
@echo ">> checking code formatting"
@fmtRes=$$(gofmt -l $$(find . -name '*.go' -not -path './vendor/*' -not -path './mixin/*')); \
if [ -n "$${fmtRes}" ]; then \
echo "gofmt found issues in:"; echo "$${fmtRes}"; \
echo "Run 'make fmt-fix' to fix"; \
exit 1; \
fi
@echo ">> formatting OK"

.PHONY: fmt-fix
fmt-fix: ## Auto-fix formatting issues
@echo ">> fixing code formatting"
$(GO) fmt $(pkgs)

.PHONY: test
test: test-exporter-unit test-exporter-e2e ## Run all tests (unit + e2e)

.PHONY: test-exporter-unit
test-exporter-unit: ## Run unit tests only
@echo ">> running unit tests"
$(GO) test -race $(GOFLAGS) $(pkgs)

.PHONY: test-exporter-e2e
test-exporter-e2e: ## Run e2e/integration tests only (requires Databricks credentials)
@echo ">> running e2e/integration tests (exporter + Databricks connection)"
$(GO) test -tags=integration -v -timeout 10m ./collector/...

.PHONY: test-coverage
test-coverage: ## Run tests with coverage report
@echo ">> running tests with coverage"
$(GO) test -race -coverprofile=coverage.out $(GOFLAGS) $(pkgs)
$(GO) tool cover -html=coverage.out -o coverage.html
@echo ">> coverage report: coverage.html"

# ============================================================================
# Build
# ============================================================================

.PHONY: build
build: $(BIN_DIR)/$(BINARY_NAME) ## Build the exporter binary

$(BIN_DIR)/$(BINARY_NAME):
@echo ">> building $(BINARY_NAME)"
@mkdir -p $(BIN_DIR)
$(GO) build $(GOFLAGS) -o $(BIN_DIR)/$(BINARY_NAME) ./cmd/databricks-exporter/

.PHONY: build-all
build-all: promu ## Build for all platforms using promu
@echo ">> building binaries for all platforms"
$(PROMU) crossbuild

.PHONY: clean
clean: ## Remove build artifacts
@echo ">> cleaning build artifacts"
rm -rf $(BIN_DIR)
rm -f coverage.out coverage.html

# ============================================================================
# Help
# ============================================================================

.PHONY: help
help: ## Show this help
@echo "Available targets:"
@grep -E '^[a-zA-Z0-9_-]+:.*##' Makefile | sed 's/:.*##/:/' | awk -F: '{printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
Loading