Skip to content

Add Prometheus metrics for artifact uploads#3738

Draft
catkins wants to merge 1 commit intomainfrom
codex/add-prometheus-metrics-for-artifact-uploads
Draft

Add Prometheus metrics for artifact uploads#3738
catkins wants to merge 1 commit intomainfrom
codex/add-prometheus-metrics-for-artifact-uploads

Conversation

@catkins
Copy link
Contributor

@catkins catkins commented Mar 5, 2026

Motivation

  • Provide Prometheus metrics for artifact uploads similar to existing log upload metrics so uploads and failures can be monitored.
  • Capture both per-artifact counts and uploaded byte totals and ensure failures are reported once per artifact.

Description

  • Added internal/artifact/metrics.go which defines Prometheus counters: buildkite_agent_artifacts_uploaded_total, buildkite_agent_artifacts_bytes_uploaded_total, and buildkite_agent_artifacts_uploads_failed_total.
  • Wired metrics into artifactUploadWorker.stateUpdater in internal/artifact/uploader.go so an artifact transitioning to "finished" increments uploaded counters and bytes, and the first transition to "error" increments the failure counter.
  • Added internal/artifact/metrics_test.go unit tests that exercise successful and failed state transitions and assert metric deltas using Prometheus testutil.
  • Updated internal/artifact/BUILD.bazel to include the new test file and add the Prometheus testutil test dependency.

Testing

  • Ran go test ./internal/artifact -run TestArtifactMetrics -v which passed all tests.
  • Ran go test ./internal/artifact -run TestCollect -v which passed all tests.
  • Tests use prometheus/testutil to assert metric values and verified success for both success and failure code paths.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant