Skip to content

Commit

Permalink
Synchronize with Elastic's private repo
Browse files Browse the repository at this point in the history
Co-Authored-By: Christos Kalkanis <[email protected]>
Co-Authored-By: Damien Mathieu <[email protected]>
Co-Authored-By: Florian Lehner <[email protected]>
Co-Authored-By: Francesco Gualazzi <[email protected]>
Co-Authored-By: Joel Höner <[email protected]>
Co-Authored-By: Joseph Kruskal <[email protected]>
Co-Authored-By: Tim Rühsen <[email protected]>
Co-Authored-By: Timo Teräs <[email protected]>
  • Loading branch information
8 people committed Jun 19, 2024
1 parent 319d980 commit daec9d3
Show file tree
Hide file tree
Showing 443 changed files with 16,126 additions and 12,003 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/unit-test-on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ jobs:
- 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
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2
make lint
test:
name: Test
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
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
run: sudo apt-get install -y llvm clang-16 dwz cmake curl unzip
- name: Install Zydis
shell: bash
run: |
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
/.idea
/go
otel-profiling-agent
tracer.ebpf
tracer.ebpf.arm64
tracer.ebpf.x86
7 changes: 3 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ linters:
- depguard
- dupword
- durationcheck # might be worth fixing
- errname # might be worth fixing
- errorlint # might be worth fixing
- exhaustive
- exhaustivestruct
Expand All @@ -50,16 +49,16 @@ linters:
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocyclo
- godot
- godox # complains about TODO etc
- goerr113
- gofumpt
- goimports # might be worth fixing
- golint # might be worth fixing
- gomnd
- gomoddirectives
- ifshort
- inamedparam
- interfacebloat
- ireturn
- maintidx
Expand All @@ -73,6 +72,7 @@ linters:
- nonamedreturns
- nosnakecase
- paralleltest
- protogetter
- scopelint # might be worth fixing
- sqlclosecheck # might be worth fixing
- tagalign
Expand Down Expand Up @@ -115,7 +115,6 @@ linters-settings:
- octalLiteral
- whyNoLint
- wrapperFunc
- sloppyTestFuncName
- sloppyReassign
- uncheckedInlineErr # Experimental rule with high false positive rate.

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ 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 unzip jq
curl wget cmake dwz lsb-release software-properties-common gnupg git clang-16 llvm \
golang unzip jq && apt-get clean autoclean && apt-get autoremove --yes

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
RUN wget -qO- https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2


# gRPC dependencies
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ clean:
@chmod -Rf u+w go/ || true
@rm -rf go .cache

generate: protobuf
generate:
go install github.com/florianl/[email protected]
go generate ./...

Expand All @@ -31,7 +31,7 @@ test: generate ebpf test-deps
go test ./...

TESTDATA_DIRS:= \
libpf/nativeunwind/elfunwindinfo/testdata \
nativeunwind/elfunwindinfo/testdata \
libpf/pfelf/testdata \
reporter/testdata

Expand All @@ -40,9 +40,6 @@ test-deps:
($(MAKE) -C "$(testdata_dir)") || exit ; \
)

protobuf:
cd proto && ./buildpb.sh

# Detect native architecture.
UNAME_NATIVE_ARCH:=$(shell uname -m)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ devfiler spins up a local server that listens on `0.0.0.0:11000`.

To run it, simply download and unpack the archive from the following URL:

https://upload.elastic.co/d/0891b6a006b1ee8224e638d2454b967f7c1ac596110b5c149ac7c98107655d9b
https://upload.elastic.co/d/308473059574c7b2855dc9a26e86f81336f51ad03d1792050eccf096d319f0af

Authentication token: `a217abfdd7c438e9`
Authentication token: `c9ecd93c7de4f032`

The archive contains a build for each of the following platforms:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strconv"
"strings"

"github.com/elastic/otel-profiling-agent/libpf/stringutil"
"github.com/elastic/otel-profiling-agent/stringutil"
aa "golang.org/x/arch/arm64/arm64asm"
)

Expand Down
75 changes: 3 additions & 72 deletions cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ import (
"flag"
"fmt"
"os"
"runtime"
"strings"
"time"

cebpf "github.com/cilium/ebpf"
"github.com/peterbourgon/ff/v3"
log "github.com/sirupsen/logrus"

"github.com/elastic/otel-profiling-agent/config"
"github.com/elastic/otel-profiling-agent/debug/log"
"github.com/elastic/otel-profiling-agent/hostmetadata/host"
"github.com/elastic/otel-profiling-agent/tracer"
)
Expand Down Expand Up @@ -55,7 +52,7 @@ var (
configFileHelp = "Path to the profiling agent configuration file."
projectIDHelp = "The project ID to split profiling data into logical groups. " +
"Its value should be larger than 0 and smaller than 4096."
cacheDirectoryHelp = "The directory where profiling agent can store cached data."
cacheDirectoryHelp = "The directory where the profiling agent can store cached data."
secretTokenHelp = "The secret token associated with the project id."
tagsHelp = fmt.Sprintf("User-specified tags separated by ';'. "+
"Each tag should match '%v'.", host.ValidTagRegex)
Expand Down Expand Up @@ -117,7 +114,7 @@ func parseArgs() error {
fs.IntVar(&argBpfVerifierLogSize, "bpf-log-size", cebpf.DefaultVerifierLogSize,
bpfVerifierLogSizeHelp)

fs.StringVar(&argCacheDirectory, "cache-directory", config.CacheDirectory(),
fs.StringVar(&argCacheDirectory, "cache-directory", "/var/cache/otel/profiling-agent",
cacheDirectoryHelp)
fs.StringVar(&argCollAgentAddr, "collection-agent", "",
collAgentAddrHelp)
Expand Down Expand Up @@ -167,72 +164,6 @@ func parseArgs() error {
return err
}

// parseTracers parses a string that specifies one or more eBPF tracers to enable.
// Valid inputs are 'all', 'native', 'python', 'php', or any comma-delimited combination of these.
// The return value is a boolean lookup table that represents the input strings.
// E.g. to check if the Python tracer was requested: `if result[config.PythonTracer]...`.
func parseTracers(tracers string) ([]bool, error) {
fields := strings.Split(tracers, ",")
if len(fields) == 0 {
return nil, fmt.Errorf("invalid tracer specification '%s'", tracers)
}

result := make([]bool, config.MaxTracers)
tracerNameToType := map[string]config.TracerType{
"v8": config.V8Tracer,
"php": config.PHPTracer,
"perl": config.PerlTracer,
"ruby": config.RubyTracer,
"python": config.PythonTracer,
"hotspot": config.HotspotTracer,
}

// Parse and validate tracers string
for _, name := range fields {
name = strings.ToLower(name)

//nolint:goconst
if runtime.GOARCH == "arm64" && name == "v8" {
return nil, fmt.Errorf("the V8 tracer is currently not supported on ARM64")
}

if tracerType, ok := tracerNameToType[name]; ok {
result[tracerType] = true
continue
}

if name == "all" {
for i := range result {
result[i] = true
}
result[config.V8Tracer] = runtime.GOARCH != "arm64" //nolint:goconst
continue
}
if name == "native" {
log.Warn("Enabling the `native` tracer explicitly is deprecated (it's now always-on)")
continue
}

if name != "" {
return nil, fmt.Errorf("unknown tracer: %s", name)
}
}

tracersEnabled := make([]string, 0, config.MaxTracers)
for _, tracerType := range config.AllTracers() {
if result[tracerType] {
tracersEnabled = append(tracersEnabled, tracerType.GetString())
}
}

if len(tracersEnabled) > 0 {
log.Debugf("Tracer string: %v", tracers)
log.Infof("Interpreter tracers: %v", strings.Join(tracersEnabled, ","))
}

return result, nil
}

func dumpArgs() {
log.Debug("Config:")
fs.VisitAll(func(f *flag.Flag) {
Expand Down
Loading

0 comments on commit daec9d3

Please sign in to comment.