Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - DO NOT REVIEW RFC: Integrate Beyla without eBPF binaries #2734

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ steps:
- make lint
image: grafana/alloy-build-image:v0.1.8
name: Lint
volumes:
- name: docker
path: /var/run/docker.sock
trigger:
event:
- pull_request
type: docker
volumes:
- host:
path: /var/run/docker.sock
name: docker
---
kind: pipeline
name: Test
Expand All @@ -25,10 +32,17 @@ steps:
- make GO_TAGS="nodocker" test
image: grafana/alloy-build-image:v0.1.8
name: Run Go tests
volumes:
- name: docker
path: /var/run/docker.sock
trigger:
event:
- pull_request
type: docker
volumes:
- host:
path: /var/run/docker.sock
name: docker
---
kind: pipeline
name: Test (Full)
Expand Down Expand Up @@ -579,6 +593,6 @@ kind: secret
name: updater_private_key
---
kind: signature
hmac: 26b5613cbd5e5cd42656c10c372d44dc93af565ec2ae212d3b27c2fe366c6aeb
hmac: e6b3e9929f79eab8e5e454b543705e080893abe81ebbd7f47b67dcb6981b0fa8

...
20 changes: 20 additions & 0 deletions .drone/pipelines/test.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ local pipelines = import '../util/pipelines.jsonnet';
steps: [{
name: 'Lint',
image: build_image.linux,
volumes: [{
name: 'docker',
path: '/var/run/docker.sock',
}],
commands: [
'apt-get update -y && apt-get install -y libsystemd-dev',
'make lint',
],
}],
volumes: [{
name: 'docker',
host: {
path: '/var/run/docker.sock',
},
}],
},

pipelines.linux('Test') {
Expand All @@ -23,11 +33,21 @@ local pipelines = import '../util/pipelines.jsonnet';
steps: [{
name: 'Run Go tests',
image: build_image.linux,
volumes: [{
name: 'docker',
path: '/var/run/docker.sock',
}],

commands: [
'make GO_TAGS="nodocker" test',
],
}],
volumes: [{
name: 'docker',
host: {
path: '/var/run/docker.sock',
},
}],
},

pipelines.linux('Test (Full)') {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
jobs:
build_linux:
name: Build on Linux
runs-on: ubuntu-latest
runs-on: github-hosted-ubuntu-x64-large
container: grafana/alloy-build-image:v0.1.8
strategy:
matrix:
Expand All @@ -35,7 +35,7 @@ jobs:

build_linux_boringcrypto:
name: Build on Linux (boringcrypto)
runs-on: ubuntu-latest
runs-on: github-hosted-ubuntu-x64-large
container: grafana/alloy-build-image:v0.1.8-boringcrypto
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- uses: actions/checkout@v4
- name: Build image
run: |
make generate-beyla
docker build -t alloy-test:latest -f Dockerfile .

windows:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
GO_TAGS="netgo builtinassets promtail_journal_enabled" \
GOEXPERIMENT=${GOEXPERIMENT} \
make alloy
make alloy-for-image

FROM public.ecr.aws/ubuntu/ubuntu:noble

Expand Down
35 changes: 27 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ ALLOY_BINARY ?= build/alloy
SERVICE_BINARY ?= build/alloy-service
ALLOYLINT_BINARY ?= build/alloylint
GOOS ?= $(shell go env GOOS)
GOHOSTOS ?= $(shell go env GOHOSTOS)
GOARCH ?= $(shell go env GOARCH)
GOHOSTARCH ?= $(shell go env GOHOSTARCH)
GOARM ?= $(shell go env GOARM)
CGO_ENABLED ?= 1
RELEASE_BUILD ?= 0
Expand All @@ -94,7 +96,7 @@ GOEXPERIMENT ?= $(shell go env GOEXPERIMENT)
# container. USE_CONTAINER must _not_ be included to avoid infinite recursion.
PROPAGATE_VARS := \
ALLOY_IMAGE ALLOY_IMAGE_WINDOWS \
BUILD_IMAGE GOOS GOARCH GOARM CGO_ENABLED RELEASE_BUILD \
BUILD_IMAGE GOOS GOHOSTOS GOARCH GOHOSTARCH GOARM CGO_ENABLED RELEASE_BUILD \
ALLOY_BINARY \
VERSION GO_TAGS GOEXPERIMENT

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

GO_BUILTIN_TAGS := beyla_bpf $(GO_TAGS)
DEFAULT_FLAGS := $(GO_FLAGS)
DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS)" -tags "$(GO_TAGS)"
RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "$(GO_TAGS)"
DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS)" -tags "$(GO_BUILTIN_TAGS)"
RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "$(GO_BUILTIN_TAGS)"

ifeq ($(RELEASE_BUILD),1)
GO_FLAGS := $(DEFAULT_FLAGS) $(RELEASE_GO_FLAGS)
Expand All @@ -139,7 +142,7 @@ lint: alloylint
# We have to run test twice: once for all packages with -race and then once
# more without -race for packages that have known race detection issues. The
# final command runs tests for all other submodules.
test:
test: generate-beyla
$(GO_ENV) go test $(GO_FLAGS) -race $(shell go list ./... | grep -v /integration-tests/)
$(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
$(GO_ENV) find . -name go.mod -not -path "./go.mod" -execdir go test -race ./... \;
Expand All @@ -163,13 +166,16 @@ integration-test:
.PHONY: binaries alloy
binaries: alloy

alloy:
alloy: generate-beyla
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
$(GO_ENV) go build $(GO_FLAGS) -o $(ALLOY_BINARY) .
endif

alloy-for-image:
$(GO_ENV) go build $(GO_FLAGS) -o $(ALLOY_BINARY) .

# alloy-service is not included in binaries since it's Windows-only.
alloy-service:
ifeq ($(USE_CONTAINER),1)
Expand All @@ -178,7 +184,7 @@ else
$(GO_ENV) go build $(GO_FLAGS) -o $(SERVICE_BINARY) ./internal/cmd/alloy-service
endif

alloylint:
alloylint: generate-beyla
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
Expand All @@ -198,8 +204,8 @@ endif
.PHONY: images alloy-image
images: alloy-image

alloy-image:
DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) -t $(ALLOY_IMAGE) -f Dockerfile .
alloy-image: generate-beyla
DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) --debug -t $(ALLOY_IMAGE) -f Dockerfile .

.PHONY: images-windows alloy-image-windows
images: alloy-image-windows
Expand Down Expand Up @@ -273,6 +279,17 @@ drone: generate-drone
drone lint .drone/drone.yml --trusted
drone --server https://drone.grafana.net sign --save grafana/alloy .drone/drone.yml

# Required by vendored Beyla to build eBPF artifacts prior to building the
# Alloy binary
# go mod vendor is required for GH workflows, as we cannot mount directories
# outside of the source dir inside the beyla ebpf builder image
# GOHOSTOS and GOHOSTARCH are required to ensure that the tool runs on the
# host context, rather than building target binaries when cross-compiling
.PHONY: generate-beyla
generate-beyla:
if [ -n "$$GITHUB_WORKSPACE" ] || [ -n "$$DRONE_SYSTEM_HOST" ]; then go mod vendor; fi; \
GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go run github.com/grafana/beyla/v2/cmd/beyla-genfiles@generate_tool

.PHONY: clean
clean: clean-dist clean-build-container-cache
rm -rf ./build/*
Expand All @@ -285,7 +302,9 @@ info:
@printf "BUILD_IMAGE = $(BUILD_IMAGE)\n"
@printf "ALLOY_BINARY = $(ALLOY_BINARY)\n"
@printf "GOOS = $(GOOS)\n"
@printf "GOHOSTOS = $(GOHOSTOS)\n"
@printf "GOARCH = $(GOARCH)\n"
@printf "GOHOSTARCH = $(GOHOSTARCH)\n"
@printf "GOARM = $(GOARM)\n"
@printf "CGO_ENABLED = $(CGO_ENABLED)\n"
@printf "RELEASE_BUILD = $(RELEASE_BUILD)\n"
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ require (
golang.org/x/sys v0.30.0
golang.org/x/text v0.22.0
golang.org/x/time v0.9.0
golang.org/x/tools v0.29.0
golang.org/x/tools v0.30.0
google.golang.org/api v0.217.0
google.golang.org/grpc v1.70.0
google.golang.org/protobuf v1.36.4
Expand Down Expand Up @@ -574,6 +574,7 @@ require (
github.com/grafana/go-offsets-tracker v0.1.7 // indirect
github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 // indirect
github.com/grafana/jfr-parser v0.9.2 // indirect
github.com/grafana/jvmtools v0.0.3 // indirect
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.0 // indirect
Expand Down Expand Up @@ -870,7 +871,7 @@ require (
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f // indirect
golang.design/x/chann v0.1.2 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
Expand All @@ -892,7 +893,7 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

require github.com/grafana/beyla/v2 v2.0.4-alloy.2
require github.com/grafana/beyla/v2 v2.0.1-0.20250228221137-faa829a3ecb3

// NOTE: replace directives below must always be *temporary*.
//
Expand Down
18 changes: 12 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,12 @@ github.com/gosnmp/gosnmp v1.38.0/go.mod h1:FE+PEZvKrFz9afP9ii1W3cprXuVZ17ypCcyyf
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/grafana/alloy-remote-config v0.0.10 h1:1Ge7lz2mjXI1rd6SmiZpFHyXeLehBuCi43+XTkdqgV4=
github.com/grafana/alloy-remote-config v0.0.10/go.mod h1:kHE1usYo2WAVCikQkIXuoG1Clz8BSdiz3kF+DZSCQ4k=
github.com/grafana/beyla/v2 v2.0.4-alloy.2 h1:f3liglMaxw44IVuJH10GbJvv0BKSAHKsXTwN3guXv7I=
github.com/grafana/beyla/v2 v2.0.4-alloy.2/go.mod h1:upm4aerYwSs+bQKA1Sp5b2TwjxGVmiWEiZav3qc5Kkc=
github.com/grafana/beyla/v2 v2.0.1-0.20250228181844-8db4ab92d492 h1:4J1yKVr7Att990TfkUiVbaBQavJVxZmTM7ODJYumPPs=
github.com/grafana/beyla/v2 v2.0.1-0.20250228181844-8db4ab92d492/go.mod h1:TBliYCPmQIPzUdW325AJDIXReB7kk13HtgUy9BidLIc=
github.com/grafana/beyla/v2 v2.0.1-0.20250228191524-b9d12092ec96 h1:Klloqg3yBljXzaNYShgSh3EDpkmMQjbNlNMHafsWDoE=
github.com/grafana/beyla/v2 v2.0.1-0.20250228191524-b9d12092ec96/go.mod h1:TBliYCPmQIPzUdW325AJDIXReB7kk13HtgUy9BidLIc=
github.com/grafana/beyla/v2 v2.0.1-0.20250228221137-faa829a3ecb3 h1:aFPqI3R5Km/3cHCpeXECQth87hlCFKLJrruXFeeH2zg=
github.com/grafana/beyla/v2 v2.0.1-0.20250228221137-faa829a3ecb3/go.mod h1:TBliYCPmQIPzUdW325AJDIXReB7kk13HtgUy9BidLIc=
github.com/grafana/cadvisor v0.0.0-20240729082359-1f04a91701e2 h1:ju6EcY2aEobeBg185ETtFCKj5WzaQ48qfkbsSRRQrF4=
github.com/grafana/cadvisor v0.0.0-20240729082359-1f04a91701e2/go.mod h1:8sLW/G7rcFe1CKMaA4pYT4mX3P1xQVGqM6luzEzx/2g=
github.com/grafana/catchpoint-prometheus-exporter v0.0.0-20250218151502-6e97feaee761 h1:dPJOIEwtQ8uR3Qa79pb/lsSFJQ6j4P9vpCUQ4fKimG4=
Expand All @@ -1271,6 +1275,8 @@ github.com/grafana/jfr-parser/pprof v0.0.3 h1:GbhF9vVbfSUTpn0TPSdOBnDW8cKFQ3lqgi
github.com/grafana/jfr-parser/pprof v0.0.3/go.mod h1:MccKegViSw2NsyXNww1yuIcaQlw6LxP/DT0CHlsfRgw=
github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32 h1:NznuPwItog+rwdVg8hAuGKP29ndRSzJAwhxKldkP8oQ=
github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32/go.mod h1:796sq+UcONnSlzA3RtlBZ+b/hrerkZXiEmO8oMjyRwY=
github.com/grafana/jvmtools v0.0.3 h1:4uPquep5v+54Z04OQYOCldrv2SR42IRagHQXrNHsc4g=
github.com/grafana/jvmtools v0.0.3/go.mod h1:b0tiPI5zNyIuPUz2DwvxUCI+5bFoG7A4i47F9sc8w98=
github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a h1:jqM4NNdx8LSquKo8bPx+XWn91S2b+sgNvEcFfSJQtHY=
github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a/go.mod h1:ZXGGyeTUMenf/H1CDBK9lv3azjswfa0nVzLoQAYmnDc=
github.com/grafana/loki/pkg/push v0.0.0-20250218135905-f078e0e3f9b6 h1:s4B8mN2RvfKEd3TQRHRMQlfuUAyQ4if8UXnzysH4NSY=
Expand Down Expand Up @@ -3024,8 +3030,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -3390,8 +3396,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 1 addition & 0 deletions internal/component/beyla/ebpf/beyla_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sync"
"time"

_ "github.com/grafana/beyla/v2/bpf"
"github.com/grafana/beyla/v2/pkg/beyla"
"github.com/grafana/beyla/v2/pkg/components"
beylaCfg "github.com/grafana/beyla/v2/pkg/config"
Expand Down
Loading