Skip to content

Commit d70346e

Browse files
Integrate Beyla without eBPF binaries
1 parent 45791cf commit d70346e

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

Makefile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ ALLOY_BINARY ?= build/alloy
8484
SERVICE_BINARY ?= build/alloy-service
8585
ALLOYLINT_BINARY ?= build/alloylint
8686
GOOS ?= $(shell go env GOOS)
87+
GOHOSTOS ?= $(shell go env GOHOSTOS)
8788
GOARCH ?= $(shell go env GOARCH)
89+
GOHOSTARCH ?= $(shell go env GOHOSTARCH)
8890
GOARM ?= $(shell go env GOARM)
8991
CGO_ENABLED ?= 1
9092
RELEASE_BUILD ?= 0
@@ -94,7 +96,7 @@ GOEXPERIMENT ?= $(shell go env GOEXPERIMENT)
9496
# container. USE_CONTAINER must _not_ be included to avoid infinite recursion.
9597
PROPAGATE_VARS := \
9698
ALLOY_IMAGE ALLOY_IMAGE_WINDOWS \
97-
BUILD_IMAGE GOOS GOARCH GOARM CGO_ENABLED RELEASE_BUILD \
99+
BUILD_IMAGE GOOS GOHOSTOS GOARCH GOHOSTARCH GOARM CGO_ENABLED RELEASE_BUILD \
98100
ALLOY_BINARY \
99101
VERSION GO_TAGS GOEXPERIMENT
100102

@@ -114,9 +116,10 @@ GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) \
114116
-X $(VPREFIX).BuildUser=$(shell whoami)@$(shell hostname) \
115117
-X $(VPREFIX).BuildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
116118

119+
GO_BUILTIN_TAGS := beyla_bpf $(GO_TAGS)
117120
DEFAULT_FLAGS := $(GO_FLAGS)
118-
DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS)" -tags "$(GO_TAGS)"
119-
RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "$(GO_TAGS)"
121+
DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS)" -tags "$(GO_BUILTIN_TAGS)"
122+
RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "$(GO_BUILTIN_TAGS)"
120123

121124
ifeq ($(RELEASE_BUILD),1)
122125
GO_FLAGS := $(DEFAULT_FLAGS) $(RELEASE_GO_FLAGS)
@@ -139,7 +142,7 @@ lint: alloylint
139142
# We have to run test twice: once for all packages with -race and then once
140143
# more without -race for packages that have known race detection issues. The
141144
# final command runs tests for all other submodules.
142-
test:
145+
test: generate-beyla
143146
$(GO_ENV) go test $(GO_FLAGS) -race $(shell go list ./... | grep -v /integration-tests/)
144147
$(GO_ENV) go test $(GO_FLAGS) ./internal/static/integrations/node_exporter ./internal/static/logs ./internal/component/otelcol/processor/tail_sampling ./internal/component/loki/source/file ./internal/component/loki/source/docker
145148
$(GO_ENV) find . -name go.mod -not -path "./go.mod" -execdir go test -race ./... \;
@@ -163,7 +166,7 @@ integration-test:
163166
.PHONY: binaries alloy
164167
binaries: alloy
165168

166-
alloy:
169+
alloy: generate-beyla
167170
ifeq ($(USE_CONTAINER),1)
168171
$(RERUN_IN_CONTAINER)
169172
else
@@ -178,7 +181,7 @@ else
178181
$(GO_ENV) go build $(GO_FLAGS) -o $(SERVICE_BINARY) ./internal/cmd/alloy-service
179182
endif
180183

181-
alloylint:
184+
alloylint: generate-beyla
182185
ifeq ($(USE_CONTAINER),1)
183186
$(RERUN_IN_CONTAINER)
184187
else
@@ -273,6 +276,13 @@ drone: generate-drone
273276
drone lint .drone/drone.yml --trusted
274277
drone --server https://drone.grafana.net sign --save grafana/alloy .drone/drone.yml
275278

279+
# Required by vendored Beyla to build eBPF artifacts prior to building the
280+
# Alloy binary
281+
.PHONY: generate-beyla
282+
generate-beyla:
283+
@go mod vendor
284+
@GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go generate vendor/github.com/grafana/beyla/v2/bpf/build_ebpf.go > /dev/null
285+
276286
.PHONY: clean
277287
clean: clean-dist clean-build-container-cache
278288
rm -rf ./build/*
@@ -285,7 +295,9 @@ info:
285295
@printf "BUILD_IMAGE = $(BUILD_IMAGE)\n"
286296
@printf "ALLOY_BINARY = $(ALLOY_BINARY)\n"
287297
@printf "GOOS = $(GOOS)\n"
298+
@printf "GOHOSTOS = $(GOHOSTOS)\n"
288299
@printf "GOARCH = $(GOARCH)\n"
300+
@printf "GOHOSTARCH = $(GOHOSTARCH)\n"
289301
@printf "GOARM = $(GOARM)\n"
290302
@printf "CGO_ENABLED = $(CGO_ENABLED)\n"
291303
@printf "RELEASE_BUILD = $(RELEASE_BUILD)\n"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ require (
893893
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
894894
)
895895

896-
require github.com/grafana/beyla/v2 v2.0.4-alloy.2
896+
require github.com/grafana/beyla/v2 v2.0.1-0.20250220141223-3107a3218705
897897

898898
// NOTE: replace directives below must always be *temporary*.
899899
//

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,8 +1248,8 @@ github.com/gosnmp/gosnmp v1.38.0/go.mod h1:FE+PEZvKrFz9afP9ii1W3cprXuVZ17ypCcyyf
12481248
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
12491249
github.com/grafana/alloy-remote-config v0.0.10 h1:1Ge7lz2mjXI1rd6SmiZpFHyXeLehBuCi43+XTkdqgV4=
12501250
github.com/grafana/alloy-remote-config v0.0.10/go.mod h1:kHE1usYo2WAVCikQkIXuoG1Clz8BSdiz3kF+DZSCQ4k=
1251-
github.com/grafana/beyla/v2 v2.0.4-alloy.2 h1:f3liglMaxw44IVuJH10GbJvv0BKSAHKsXTwN3guXv7I=
1252-
github.com/grafana/beyla/v2 v2.0.4-alloy.2/go.mod h1:upm4aerYwSs+bQKA1Sp5b2TwjxGVmiWEiZav3qc5Kkc=
1251+
github.com/grafana/beyla/v2 v2.0.1-0.20250220141223-3107a3218705 h1:hRKODZCnUXYG2/m9pdzKWtEZgzDhAXNaJ6Nhr8MwwJg=
1252+
github.com/grafana/beyla/v2 v2.0.1-0.20250220141223-3107a3218705/go.mod h1:MKNkPychrqv6FKK6yI3i3Eqn4QNBGJY9hZGeO7Su+ck=
12531253
github.com/grafana/cadvisor v0.0.0-20240729082359-1f04a91701e2 h1:ju6EcY2aEobeBg185ETtFCKj5WzaQ48qfkbsSRRQrF4=
12541254
github.com/grafana/cadvisor v0.0.0-20240729082359-1f04a91701e2/go.mod h1:8sLW/G7rcFe1CKMaA4pYT4mX3P1xQVGqM6luzEzx/2g=
12551255
github.com/grafana/catchpoint-prometheus-exporter v0.0.0-20250218151502-6e97feaee761 h1:dPJOIEwtQ8uR3Qa79pb/lsSFJQ6j4P9vpCUQ4fKimG4=

internal/component/beyla/ebpf/beyla_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"sync"
1414
"time"
1515

16+
_ "github.com/grafana/beyla/v2/bpf"
1617
"github.com/grafana/beyla/v2/pkg/beyla"
1718
"github.com/grafana/beyla/v2/pkg/components"
1819
beylaCfg "github.com/grafana/beyla/v2/pkg/config"

0 commit comments

Comments
 (0)