Skip to content

Surface staging/production commit drift on the infra dashboard #596

@SgtPooki

Description

@SgtPooki

Description

There's no way to see how far the deployed environments lag main without manually comparing commits. We want the infra dashboard (618457) to show, at a glance, how many commits staging and production are behind main, plus each environment's current commit, so the drift spotcheck becomes self-service.

Proposed approach

Do the git math at build time and let BetterStack do the subtraction. BetterStack already scrapes /metrics, so no exporter or external service is needed.

  1. At image build, compute commit height with git rev-list --count HEAD and bake it into the image alongside the commit SHA and version.
  2. Emit Prometheus gauges from the backend:
    • dealbot_build_commit_height (integer height)
    • dealbot_build_info{commit, version} (info metric, value 1)
    • optionally dealbot_build_commit_timestamp for a "time behind" readout
  3. On the dashboard, a metric expression height{env="staging"} - height{env="production"} gives the exact commits production is behind. Display each env's commit as a github.com/.../commit/<sha> link.

This is exact because every push to main deploys to staging and production is a release-please promotion of an older main commit, so production is always an ancestor of main on a linear squash history. Height delta equals commit count.

Implementation notes

  • The env label (staging/production) must come from runtime config, not the image. Production reuses the staging-built image via retag (release-please.yml), so a baked-in label would be wrong.
  • actions/checkout defaults to a shallow clone; set fetch-depth: 0 so rev-list --count sees full history.

Definition of done

  • Dashboard 618457 shows commits-behind for staging and production and a clickable current-commit link per env.
  • The number is verified against a known deploy (e.g. production N commits behind staging matches git rev-list --count).

Context: Slack thread

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-workTriaged: scope, plan, and DoD are clear; contributor can pick up

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    📌 Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions