Skip to content

fix(beyla): Inject Beyla version into binary via ldflags#5735

Merged
marctc merged 2 commits into
grafana:mainfrom
pratik50:fix/beyla-version-build-info
Mar 25, 2026
Merged

fix(beyla): Inject Beyla version into binary via ldflags#5735
marctc merged 2 commits into
grafana:mainfrom
pratik50:fix/beyla-version-build-info

Conversation

@pratik50
Copy link
Copy Markdown
Contributor

@pratik50 pratik50 commented Mar 10, 2026

Brief description of Pull Request

When Beyla is used as a library inside Alloy, the beyla_build_info metric was reporting version="unset" because Beyla's build-time version flags were never passed during Alloy's build process.

This PR injects the Beyla version into the Alloy binary via -ldflags at compile time, so the correct version is exposed via the beyla_build_info metric.

Pull Request Details

Alloy builds Beyla as a Go library dependency. Unlike standalone Beyla builds, Alloy's build system was not passing the ldflags needed to set pkg/buildinfo.Version, causing it to fall back to its default value of "unset".

The fix retrieves the Beyla version directly from go.mod using go list -m and injects it at build time.

Issue fixed by this Pull Request

Fixes grafana/beyla#2584
Fixes #4385

Changes are minimal and focused:

  • Makefile — fetch Beyla version from go.mod and inject via ldflags
  • common/metric.go — add Version field to parse the version label
  • beyla_test.go — add test to verify version is not "unset"

PR Checklist

  • Tests updated

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alloy integration: reporting beyla_build_info{version="unset"} beyla_internal_build_info

4 participants