Skip to content

Add Prometheus metrics for artifact uploads#3738

Draft
catkins wants to merge 2 commits into
mainfrom
codex/add-prometheus-metrics-for-artifact-uploads
Draft

Add Prometheus metrics for artifact uploads#3738
catkins wants to merge 2 commits into
mainfrom
codex/add-prometheus-metrics-for-artifact-uploads

Conversation

@catkins

@catkins catkins commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

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

@DrJosh9000

Copy link
Copy Markdown
Contributor

Hi @catkins, just wondering if this draft PR is ready for review or no longer needed?

@DrJosh9000 DrJosh9000 added the feature New user-facing feature! label Jun 17, 2026
…metrics-for-artifact-uploads

# Conflicts:
#	internal/artifact/BUILD.bazel
#	internal/artifact/uploader.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex feature New user-facing feature!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants