diff --git a/component/pyroscope/ebpf/args.go b/component/pyroscope/ebpf/args.go index b43c81a0469e..e3f1be4f5f11 100644 --- a/component/pyroscope/ebpf/args.go +++ b/component/pyroscope/ebpf/args.go @@ -21,4 +21,5 @@ type Arguments struct { CacheRounds int `river:"cache_rounds,attr,optional"` CollectUserProfile bool `river:"collect_user_profile,attr,optional"` CollectKernelProfile bool `river:"collect_kernel_profile,attr,optional"` + Demangle string `river:"demangle,attr,optional"` } diff --git a/component/pyroscope/ebpf/ebpf_linux.go b/component/pyroscope/ebpf/ebpf_linux.go index 3b15d028c20b..6bdbe02d8ccf 100644 --- a/component/pyroscope/ebpf/ebpf_linux.go +++ b/component/pyroscope/ebpf/ebpf_linux.go @@ -17,6 +17,8 @@ import ( "github.com/grafana/pyroscope/ebpf/pprof" "github.com/grafana/pyroscope/ebpf/sd" "github.com/grafana/pyroscope/ebpf/symtab" + "github.com/grafana/pyroscope/ebpf/symtab/elf" + "github.com/ianlancetaylor/demangle" "github.com/oklog/run" ) @@ -81,6 +83,7 @@ func defaultArguments() Arguments { CollectUserProfile: true, CollectKernelProfile: true, TargetsOnly: true, + Demangle: "none", } } @@ -230,6 +233,10 @@ func convertSessionOptions(args Arguments, ms *metrics) ebpfspy.SessionOptions { CollectKernel: args.CollectKernelProfile, SampleRate: args.SampleRate, CacheOptions: symtab.CacheOptions{ + SymbolOptions: symtab.SymbolOptions{ + GoTableFallback: false, + DemangleOptions: convertDemangleOptions(args.Demangle), + }, PidCacheOptions: symtab.GCacheOptions{ Size: args.PidCacheSize, KeepRounds: args.CacheRounds, @@ -246,3 +253,18 @@ func convertSessionOptions(args Arguments, ms *metrics) ebpfspy.SessionOptions { }, } } + +func convertDemangleOptions(o string) []demangle.Option { + switch o { + case "none": + return elf.DemangleNone + case "simplified": + return elf.DemangleSimplified + case "templates": + return elf.DemangleTemplates + case "full": + return elf.DemangleFull + default: + return elf.DemangleNone + } +} diff --git a/docs/sources/flow/reference/components/pyroscope.ebpf.md b/docs/sources/flow/reference/components/pyroscope.ebpf.md index b902d60079ac..fb086500e4de 100644 --- a/docs/sources/flow/reference/components/pyroscope.ebpf.md +++ b/docs/sources/flow/reference/components/pyroscope.ebpf.md @@ -41,18 +41,20 @@ You can use the following arguments to configure a `pyroscope.ebpf`. Only the `forward_to` and `targets` fields are required. Omitted fields take their default values. -| Name | Type | Description | Default | Required | -|---------------------------|--------------------------|--------------------------------------------------------------|---------|----------| -| `targets` | `list(map(string))` | List of targets to group profiles by container id | | yes | -| `forward_to` | `list(ProfilesReceiver)` | List of receivers to send collected profiles to. | | yes | -| `collect_interval` | `duration` | How frequently to collect profiles | `15s` | no | -| `sample_rate` | `int` | How many times per second to collect profile samples | 97 | no | -| `pid_cache_size` | `int` | The size of the pid -> proc symbols table LRU cache | 32 | no | -| `build_id_cache_size` | `int` | The size of the elf file build id -> symbols table LRU cache | 64 | no | -| `same_file_cache_size` | `int` | The size of the elf file -> symbols table LRU cache | 8 | no | -| `container_id_cache_size` | `int` | The size of the pid -> container ID table LRU cache | 1024 | no | -| `collect_user_profile` | `bool` | A flag to enable/disable collection of userspace profiles | true | no | -| `collect_kernel_profile` | `bool` | A flag to enable/disable collection of kernelspace profiles | true | no | +| Name | Type | Description | Default | Required | +|---------------------------|--------------------------|-------------------------------------------------------------------------------------|---------|----------| +| `targets` | `list(map(string))` | List of targets to group profiles by container id | | yes | +| `forward_to` | `list(ProfilesReceiver)` | List of receivers to send collected profiles to. | | yes | +| `collect_interval` | `duration` | How frequently to collect profiles | `15s` | no | +| `sample_rate` | `int` | How many times per second to collect profile samples | 97 | no | +| `pid_cache_size` | `int` | The size of the pid -> proc symbols table LRU cache | 32 | no | +| `build_id_cache_size` | `int` | The size of the elf file build id -> symbols table LRU cache | 64 | no | +| `same_file_cache_size` | `int` | The size of the elf file -> symbols table LRU cache | 8 | no | +| `container_id_cache_size` | `int` | The size of the pid -> container ID table LRU cache | 1024 | no | +| `collect_user_profile` | `bool` | A flag to enable/disable collection of userspace profiles | true | no | +| `collect_kernel_profile` | `bool` | A flag to enable/disable collection of kernelspace profiles | true | no | +| `demangle` | `string` | C++ demangle mode. Available options are: `none`, `simplified`, `templates`, `full` | `none` | no | + ## Exported fields diff --git a/go.mod b/go.mod index b88644e71703..cfa25b797dc9 100644 --- a/go.mod +++ b/go.mod @@ -59,7 +59,7 @@ require ( github.com/grafana/loki v1.6.2-0.20230927083715-42fba5b19183 // k169 branch github.com/grafana/pyroscope-go/godeltaprof v0.1.3 github.com/grafana/pyroscope/api v0.2.0 - github.com/grafana/pyroscope/ebpf v0.2.2 + github.com/grafana/pyroscope/ebpf v0.2.3 github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db github.com/grafana/river v0.1.2-0.20230830200459-0ff21cf610eb github.com/grafana/snowflake-prometheus-exporter v0.0.0-20221213150626-862cad8e9538 @@ -627,6 +627,7 @@ require ( github.com/Workiva/go-datastructures v1.1.0 // indirect github.com/drone/envsubst v1.0.3 // indirect github.com/google/gnostic-models v0.6.8 // indirect + github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab // indirect github.com/julienschmidt/httprouter v1.3.0 // indirect github.com/knadh/koanf/v2 v2.0.1 // indirect github.com/leoluk/perflib_exporter v0.2.0 // indirect diff --git a/go.sum b/go.sum index fbd3bfdaacd7..76270822846a 100644 --- a/go.sum +++ b/go.sum @@ -1108,8 +1108,8 @@ github.com/grafana/pyroscope-go/godeltaprof v0.1.3 h1:eunWpv1B3Z7ZK9o4499EmQGlY+ github.com/grafana/pyroscope-go/godeltaprof v0.1.3/go.mod h1:1HSPtjU8vLG0jE9JrTdzjgFqdJ/VgN7fvxBNq3luJko= github.com/grafana/pyroscope/api v0.2.0 h1:TzOxL0s6SiaLEy944ZAKgHcx/JDRJXu4O8ObwkqR6p4= github.com/grafana/pyroscope/api v0.2.0/go.mod h1:nhH+xai9cYFgs6lMy/+L0pKj0d5yCMwji/QAiQFCP+U= -github.com/grafana/pyroscope/ebpf v0.2.2 h1:AYvBhZTK17CSg3w4jwlRbWlOw8GBjPT27PzeRB7nnyU= -github.com/grafana/pyroscope/ebpf v0.2.2/go.mod h1:sC4X4dizWAP++y9A9xBvd0fpAXNpeXp+ElapWDhSz4c= +github.com/grafana/pyroscope/ebpf v0.2.3 h1:OH7Un2x0UN998U85by4vyvImHs6mkFTo45SnO+PjHdk= +github.com/grafana/pyroscope/ebpf v0.2.3/go.mod h1:NO9mIMKewDuohQlYaj2Q0v3miUmREjGpadz8RuA76Jw= github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db h1:7aN5cccjIqCLTzedH7MZzRZt5/lsAHch6Z3L2ZGn5FA= github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db/go.mod h1:M5qHK+eWfAv8VR/265dIuEpL3fNfeC21tXXp9itM24A= github.com/grafana/river v0.1.2-0.20230830200459-0ff21cf610eb h1:hOblg36rOTgGIOp7A3+53OtlXqq0iNnI9qDcOn7fPfQ= @@ -1320,6 +1320,8 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab h1:BA4a7pe6ZTd9F8kXETBoijjFJ/ntaa//1wiH9BZu4zU= +github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 h1:hk4LPqXIY/c9XzRbe7dA6qQxaT6Axcbny0L/G5a4owQ= github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973/go.mod h1:PoK3ejP3LJkGTzKqRlpvCIFas3ncU02v8zzWDW+g0FY= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=