-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre-OSS Optimyze/Elastic contributors: Co-Authored-By: Adam Gowdiak <[email protected]> Co-Authored-By: Adrien Mannocci <[email protected]> Co-Authored-By: Caue Marcondes <[email protected]> Co-Authored-By: Christos Kalkanis <[email protected]> Co-Authored-By: Damien Mathieu <[email protected]> Co-Authored-By: Daniel Mitterdorfer <[email protected]> Co-Authored-By: Florian Lehner <[email protected]> Co-Authored-By: Francesco Gualazzi <[email protected]> Co-Authored-By: Israel Ogbole <[email protected]> Co-Authored-By: Jan Calanog <[email protected]> Co-Authored-By: Joel Höner <[email protected]> Co-Authored-By: Joe Rowell <[email protected]> Co-Authored-By: Joseph Crail <[email protected]> Co-Authored-By: Joseph Kruskal <[email protected]> Co-Authored-By: M.J. Fieggen (Joni) <[email protected]> Co-Authored-By: Sean Heelan <[email protected]> Co-Authored-By: Stephanie Boomsma <[email protected]> Co-Authored-By: Thomas Dullien <[email protected]> Co-Authored-By: Timo Teräs <[email protected]> Co-Authored-By: Tim Rühsen <[email protected]> Co-Authored-By: Victor Martinez <[email protected]> Co-Authored-By: Victor Michel <[email protected]>
- Loading branch information
Showing
445 changed files
with
67,603 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: otel-profiling-agent | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: ["**"] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
max-parallel: 2 | ||
matrix: | ||
go: ["stable"] | ||
steps: | ||
- name: Install dependencies | ||
run: sudo apt-get install -y llvm clang dwz cmake curl unzip | ||
- name: Install Zydis | ||
shell: bash | ||
run: | | ||
cd /tmp | ||
git clone --depth 1 --branch v3.1.0 --recursive https://github.com/zyantific/zydis.git | ||
cd zydis | ||
rm -rf build | ||
mkdir build | ||
cd build | ||
cmake -DZYDIS_BUILD_EXAMPLES=OFF .. | ||
make -j$(nproc) | ||
sudo make install | ||
cd zycore | ||
sudo make install | ||
- name: Set up Go ${{matrix.go}} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{matrix.go}} | ||
check-latest: true | ||
cache-dependency-path: | | ||
go.sum | ||
id: go | ||
- name: Install gRPC dependencies | ||
env: | ||
PB_URL: "https://github.com/protocolbuffers/protobuf/releases/download/v24.4/" | ||
PB_FILE: "protoc-24.4-linux-x86_64.zip" | ||
INSTALL_DIR: "/usr/local" | ||
run: | | ||
go install google.golang.org/protobuf/cmd/[email protected] | ||
go install google.golang.org/grpc/cmd/[email protected] | ||
curl -LO "$PB_URL/$PB_FILE" | ||
sudo unzip "$PB_FILE" -d "$INSTALL_DIR" 'bin/*' 'include/*' | ||
sudo chmod +xr "$INSTALL_DIR/bin/protoc" | ||
sudo find "$INSTALL_DIR/include" -type d -exec chmod +x {} \; | ||
sudo find "$INSTALL_DIR/include" -type f -exec chmod +r {} \; | ||
rm "$PB_FILE" | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
- name: Linter | ||
run: | | ||
go version | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 | ||
make lint | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
max-parallel: 2 | ||
matrix: | ||
go: ["stable"] | ||
steps: | ||
- name: Install dependencies | ||
run: sudo apt-get install -y llvm clang dwz cmake curl unzip | ||
- name: Install Zydis | ||
shell: bash | ||
run: | | ||
cd /tmp | ||
git clone --depth 1 --branch v3.1.0 --recursive https://github.com/zyantific/zydis.git | ||
cd zydis | ||
rm -rf build | ||
mkdir build | ||
cd build | ||
cmake -DZYDIS_BUILD_EXAMPLES=OFF .. | ||
make -j$(nproc) | ||
sudo make install | ||
cd zycore | ||
sudo make install | ||
- name: Set up Go ${{matrix.go}} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{matrix.go}} | ||
check-latest: true | ||
cache-dependency-path: | | ||
go.sum | ||
id: go | ||
- name: Install gRPC dependencies | ||
env: | ||
PB_URL: "https://github.com/protocolbuffers/protobuf/releases/download/v24.4/" | ||
PB_FILE: "protoc-24.4-linux-x86_64.zip" | ||
INSTALL_DIR: "/usr/local" | ||
run: | | ||
go install google.golang.org/protobuf/cmd/[email protected] | ||
go install google.golang.org/grpc/cmd/[email protected] | ||
curl -LO "$PB_URL/$PB_FILE" | ||
sudo unzip "$PB_FILE" -d "$INSTALL_DIR" 'bin/*' 'include/*' | ||
sudo chmod +xr "$INSTALL_DIR/bin/protoc" | ||
sudo find "$INSTALL_DIR/include" -type d -exec chmod +x {} \; | ||
sudo find "$INSTALL_DIR/include" -type f -exec chmod +r {} \; | ||
rm "$PB_FILE" | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
- name: Build | ||
run: | | ||
echo $PATH | ||
make test | ||
- name: Tests | ||
run: | | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.o | ||
*.pb.go | ||
.idea | ||
otel-profiling-agent | ||
tracer.ebpf | ||
tracer.ebpf.arm64 | ||
tracer.ebpf.x86 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
service: | ||
golangci-lint-version: 1.54.x | ||
|
||
run: | ||
skip-dirs: | ||
- artifacts | ||
- build-targets | ||
- design | ||
- docker-images | ||
- docs | ||
- etc | ||
- experiments | ||
- infrastructure | ||
- legal | ||
- libpf-rs | ||
- mocks | ||
- pf-code-indexing-service/cibackend/gomock_* | ||
- pf-debug-metadata-service/dmsbackend/gomock_* | ||
- pf-host-agent/support/ci-kernels | ||
- pf-storage-backend/storagebackend/gomock_* | ||
- scratch | ||
- systemtests/benchmarks/_outdata | ||
- target | ||
- virt-tests | ||
- vm-images | ||
|
||
linters: | ||
enable-all: true | ||
disable: | ||
# Disabled because of | ||
# - too many non-sensical warnings | ||
# - not relevant for us | ||
# - false positives | ||
# | ||
# "might be worth fixing" means we should investigate/fix in the mid term | ||
- containedctx # might be worth fixing | ||
- contextcheck # might be worth fixing | ||
- cyclop | ||
- depguard | ||
- dupword | ||
- durationcheck # might be worth fixing | ||
- errname # might be worth fixing | ||
- errorlint # might be worth fixing | ||
- exhaustive | ||
- exhaustivestruct | ||
- exhaustruct | ||
- forcetypeassert # might be worth fixing | ||
- funlen | ||
- gci # might be worth fixing | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- gocognit | ||
- gocyclo | ||
- godot | ||
- godox # complains about TODO etc | ||
- goerr113 | ||
- gofumpt | ||
- goimports # might be worth fixing | ||
- golint # might be worth fixing | ||
- gomnd | ||
- gomoddirectives | ||
- ifshort | ||
- interfacebloat | ||
- ireturn | ||
- maintidx | ||
- makezero | ||
- nestif | ||
- nilerr # might be worth fixing | ||
- nilnil | ||
- nlreturn | ||
- noctx # might be worth fixing | ||
- nolintlint | ||
- nonamedreturns | ||
- nosnakecase | ||
- paralleltest | ||
- scopelint # might be worth fixing | ||
- sqlclosecheck # might be worth fixing | ||
- tagalign | ||
- tagliatelle | ||
- testableexamples # might be worth fixing | ||
- testpackage | ||
- tparallel # might be worth fixing | ||
- thelper | ||
- varnamelen | ||
- wastedassign | ||
- wsl | ||
- wrapcheck | ||
- forbidigo | ||
# the following linters are deprecated | ||
- exhaustivestruct | ||
- scopelint | ||
- nosnakecase | ||
- interfacer | ||
- maligned | ||
- ifshort | ||
- structcheck # might be worth fixing | ||
- deadcode | ||
- golint | ||
- varcheck | ||
|
||
linters-settings: | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
- wrapperFunc | ||
- sloppyTestFuncName | ||
- sloppyReassign | ||
- uncheckedInlineErr # Experimental rule with high false positive rate. | ||
|
||
# Broken with Go 1.18 feature (https://github.com/golangci/golangci-lint/issues/2649): | ||
- hugeParam | ||
- rangeValCopy | ||
- typeDefFirst | ||
- paramTypeCombine | ||
gocyclo: | ||
min-complexity: 15 | ||
govet: | ||
enable-all: true | ||
check-shadowing: true | ||
disable: | ||
- fieldalignment | ||
settings: | ||
printf: # analyzer name, run `go tool vet help` to see all analyzers | ||
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer | ||
- debug,debugf,debugln | ||
- error,errorf,errorln | ||
- fatal,fatalf,fataln | ||
- info,infof,infoln | ||
- log,logf,logln | ||
- warn,warnf,warnln | ||
- print,printf,println,sprint,sprintf,sprintln,fprint,fprintf,fprintln | ||
lll: | ||
line-length: 100 | ||
tab-width: 4 | ||
maligned: | ||
suggest-new: true | ||
misspell: | ||
locale: US |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Open-Source contributors | ||
|
||
For contributors statistics that occurred after the profiling agent was open sourced, please refer to [the GitHub statistics](https://github.com/elastic/otel-profiling-agent/pulse). | ||
|
||
## Pre-OSS Optimyze/Elastic contributors | ||
|
||
Adam Gowdiak <[email protected]> | ||
Adrien Mannocci <[email protected]> | ||
Caue Marcondes <[email protected]> | ||
Christos Kalkanis <[email protected]> | ||
Damien Mathieu <[email protected]> | ||
Daniel Mitterdorfer <[email protected]> | ||
Florian Lehner <[email protected]> | ||
Francesco Gualazzi <[email protected]> | ||
Israel Ogbole <[email protected]> | ||
Jan Calanog <[email protected]> | ||
Joel Höner <[email protected]> | ||
Joe Rowell <[email protected]> | ||
Joseph Crail <[email protected]> | ||
Joseph Kruskal <[email protected]> | ||
M.J. Fieggen (Joni) <[email protected]> | ||
Sean Heelan <[email protected]> | ||
Stephanie Boomsma <[email protected]> | ||
Thomas Dullien <[email protected]> | ||
Timo Teräs <[email protected]> | ||
Tim Rühsen <[email protected]> | ||
Victor Martinez <[email protected]> | ||
Victor Michel <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM debian:testing | ||
|
||
WORKDIR /agent | ||
|
||
ARG arch=amd64 | ||
|
||
RUN apt-get update -y && apt-get dist-upgrade -y && apt-get install -y \ | ||
curl wget cmake dwz lsb-release software-properties-common gnupg git clang llvm \ | ||
golang linux-headers-$arch unzip | ||
|
||
RUN git clone --depth 1 --branch v3.1.0 --recursive https://github.com/zyantific/zydis.git && \ | ||
cd zydis && mkdir build && cd build && \ | ||
cmake -DZYDIS_BUILD_EXAMPLES=OFF .. && make -j$(nproc) && make install && \ | ||
cd zycore && make install && \ | ||
cd ../../.. && rm -rf zydis | ||
|
||
RUN wget -qO- https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 | ||
|
||
|
||
# gRPC dependencies | ||
RUN go install google.golang.org/protobuf/cmd/[email protected] | ||
RUN go install google.golang.org/grpc/cmd/[email protected] | ||
|
||
RUN \ | ||
PB_URL="https://github.com/protocolbuffers/protobuf/releases/download/v24.4/"; \ | ||
PB_FILE="protoc-24.4-linux-x86_64.zip"; \ | ||
INSTALL_DIR="/usr/local"; \ | ||
\ | ||
curl -LO "$PB_URL/$PB_FILE" \ | ||
&& unzip "$PB_FILE" -d "$INSTALL_DIR" 'bin/*' 'include/*' \ | ||
&& chmod +xr "$INSTALL_DIR/bin/protoc" \ | ||
&& find "$INSTALL_DIR/include" -type d -exec chmod +x {} \; \ | ||
&& find "$INSTALL_DIR/include" -type f -exec chmod +r {} \; \ | ||
&& rm "$PB_FILE" | ||
|
||
RUN echo "export PATH=\"\$PATH:\$(go env GOPATH)/bin\"\nexport KERNEL_HEADERS=\"/lib/modules/$(ls /lib/modules)\"" >> ~/.bashrc | ||
|
||
ENTRYPOINT ["/bin/bash", "-l", "-c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Known limitations | ||
================= | ||
The Linux kernel is constantly evolving and so is eBPF. To be able to load our eBPF code with older kernel versions we have to write code to avoid some limitations. This file documents the restrictions we ran into while writing the code. | ||
|
||
Number of tracepoints | ||
--------------------- | ||
Affects kernel < 4.15. | ||
|
||
There was a limit of 1 eBPF program per tracepoint/kprobe. | ||
This limit no longer holds and was removed with commit [e87c6bc3852b981e71c757be20771546ce9f76f3](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e87c6bc3852b981e71c757be20771546ce9f76f3). | ||
|
||
|
||
Obtaining Kernel backtrace | ||
-------------------------- | ||
Affects kernel < 4.18 | ||
|
||
It is not possible to get individual backtraces from kernel mode stack with bpf_get_stackid(). It returns hash of the backtrace, and if it collides with another backtrace before the agent has collected it, we might report wrong kernel backtracec. | ||
A more suitable helper bpf_get_stack() was added in commit [c195651e565ae7f41a68acb7d4aa7390ad215de1](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c195651e565ae7f41a68acb7d4aa7390ad215de1). | ||
|
||
|
||
Kernel version check | ||
-------------------- | ||
Affects kernel < 5.0. | ||
|
||
As part of the verification of eBPF programs, the `kern_version` attribute was checked and it needed to match with the currently running kernel version. | ||
This check was removed with commit [6c4fc209fcf9d27efbaa48368773e4d2bfbd59aa](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6c4fc209fcf9d27efbaa48368773e4d2bfbd59aa). | ||
|
||
|
||
eBPF instruction limit | ||
---------------------- | ||
Affects kernel < 5.2. | ||
|
||
The number of eBPF instructions per program was limited to 4096 instructions. | ||
This limit was raised to 1 million eBPF instructions with commit [c04c0d2b968ac45d6ef020316808ef6c82325a82](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c04c0d2b968ac45d6ef020316808ef6c82325a82). | ||
|
||
|
||
eBPF inner arrays (map-in-map) must be of same size | ||
--------------------------------------------------- | ||
Affects kernel < 5.10. | ||
|
||
This restriction was removed with commit[4a8f87e60f6db40e640f1db555d063b2c4dea5f1](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4a8f87e60f6db40e640f1db555d063b2c4dea5f1). |
Oops, something went wrong.