Skip to content

Commit

Permalink
Add quickstart build instructions to the README file (#1188)
Browse files Browse the repository at this point in the history
* Update README file

* Add sections for linting and VM tests
  • Loading branch information
rafaelroquetto authored Sep 23, 2024
1 parent 9a13e73 commit 9eb08e4
Showing 1 changed file with 66 additions and 2 deletions.
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ See [Documentation](https://grafana.com/docs/beyla/) and the [tutorials](https:/
## Requirements

- Linux with Kernel 5.8 or higher with [BTF](https://www.kernel.org/doc/html/latest/bpf/btf.html)
enabled. BTF became enabled by default on most Linux distributions with kernel 5.14 or higher.
enabled, or Linux distributions running RedHat Enterprise Linux 4.18 kernels build 348 and above as they have the required kernel backports. These include CentOS, AlmaLinux, and Oracle Linux. BTF became enabled by default on most Linux distributions with kernel 5.14 or higher.
You can check if your kernel has BTF enabled by verifying if `/sys/kernel/btf/vmlinux` exists on your system.
If you need to recompile your kernel to enable BTF, the configuration option `CONFIG_DEBUG_INFO_BTF=y` must be
set.
- Beyla supports Linux distributions running RedHat Enterprise Linux 4.18 kernels build 348 and above as they have the required kernel backports. These include CentOS, AlmaLinux, and Oracle Linux.
- eBPF enabled on the host.
- For instrumenting Go programs, they must have been compiled with at least Go 1.17. We currently
support Go applications built with a major **Go version no earlier than 3 versions** behind the current
Expand Down Expand Up @@ -150,6 +149,71 @@ make generate

Tested in Fedora 35, 38 and Red Hat Enterprise Linux 8.

## Building Beyla from scratch

### Development environment requirements

- go 1.23
- llvm >= 18
- clang >= 18
- clang-tidy >= 18
- clang-format >= 18
- git-lfs
- GNU make

> [!IMPORTANT]
> You need to run `git lfs install` _once_ after installing the _git-lfs_ package to deploy its global configuration
#### Common `Makefile` targets

Beyla's `Makefile` provides several specific-purpose build targets. The most common ones are:
- `prereqs` - install the build pre-requisites
- `generate` - regenerates the eBPF binaries
- `compile` - compiles the `beyla` binary (but does not automatically regenerates the eBPF binaries)
- `dev` - equivalent to `make prereqs && make generate && make compile`
- `test` - runs unit tests
- `integration-tests` - runs integration tests - may require `sudo`

#### Quickstart: cloning the repository and building Beyla

```
$ git clone https://github.com/grafana/beyla.git
$ cd beyla/
$ make dev
```

As described in the previous section, `make dev` takes care of setting up the build pre-requisites, including deploying a `clang-format` pre-commit hook.

After a successful compilation, binaries can be found in the `bin/` subdirectory.

#### Formatting and linting code

Beyla uses linters to enforce our coding style and best practices:
- `golangci-lint` for Go code
- `clang-format` for formatting C code
- `clang-tidy` for static analysis of the C code

All of them are enforced on pull requests as part of the Beyla github workflows. Additionally, you can invoke the linters manually:

- `make lint` invokes `golangci-lint` on the Go code
- `make clang-tidy` invokes `clang-tidy` on the C/eBPF code

`clang-format` is invoked automatically as a `pre-commit` git hook, so there is no explicit `Makefile` target for it.

#### Running VM tests

In addition to the `test` and `integration-test` `Makefile` targets, Beyla also runs select tests on QEMU virtual machines in order to be able to test different kernel versions. These tests are also part of our GitHub workflow, but it is also possible to run them manually using the following command:

```
$ sudo make -C test/vm KERNEL_VER=...
```

where `KERNEL_VER` is one of the supported kernel versions located in `test/vm/kernels`. For example, to run tests against kernel version 5.15.152, simply do:

```
$ sudo make -C test/vm KERNEL_VER=5.15.152
```

## Credits

Part of the code is taken from: https://github.com/open-telemetry/opentelemetry-go-instrumentation

0 comments on commit 9eb08e4

Please sign in to comment.