Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
4846a04
build-image: add rust toolchains
korniltsev Mar 6, 2025
ca84882
pyroscope.ebpf: otel implementation
korniltsev Mar 6, 2025
f30538b
go mod tidy
korniltsev Mar 6, 2025
afb4561
revert .gitignore changes
korniltsev Mar 6, 2025
8d31d67
revert .dockerignore changes
korniltsev Mar 6, 2025
0b5a7af
temp: install rust toolchain
korniltsev Mar 10, 2025
de05df5
fix pprof reporter creation
korniltsev Mar 10, 2025
d0b5167
fix
korniltsev Mar 10, 2025
79ac6f1
docs
korniltsev Mar 10, 2025
f4704c4
docs
korniltsev Mar 10, 2025
17cfb0f
use new build-image
korniltsev Mar 10, 2025
6f04247
Merge remote-tracking branch 'origin/main' into korniltsev/otel-profiler
korniltsev Mar 10, 2025
e17b5d6
revert go.mod
korniltsev Mar 10, 2025
17d013e
moar tags
korniltsev Mar 10, 2025
84e266a
test go 1.23 version
korniltsev Mar 10, 2025
1449494
Merge remote-tracking branch 'origin/main' into korniltsev/otel-profiler
korniltsev Mar 11, 2025
b205f65
nl
korniltsev Mar 11, 2025
79b4df6
update dependency
korniltsev Mar 11, 2025
c2bc065
fix build
korniltsev Mar 11, 2025
38cf014
docs
korniltsev Mar 11, 2025
35af2d9
handle verbose mode
korniltsev Mar 18, 2025
60cc204
bump dependency
korniltsev Mar 19, 2025
15281fe
udpate dependency
korniltsev Mar 24, 2025
6c87c1a
Apply suggestions from code review
korniltsev Mar 24, 2025
f201df7
reuire transport security
korniltsev Mar 24, 2025
6cdbdb4
add links to otel profiler in the docs
korniltsev Mar 24, 2025
7e4b5fc
fix pprof filepath
korniltsev Mar 24, 2025
2f80a01
Merge remote-tracking branch 'origin/main' into korniltsev/otel-profiler
korniltsev Mar 24, 2025
e748eef
lint
korniltsev Mar 24, 2025
e87fe4e
udpate dependency
korniltsev Mar 25, 2025
a0d2a7c
udpate dependency
korniltsev Mar 25, 2025
d05a31d
remove symbol {module}+0x{offset} fallback
korniltsev Mar 25, 2025
298c55f
fix
korniltsev Mar 25, 2025
0f95485
test dependency with no mixed native-python frames
korniltsev Mar 25, 2025
c604b2f
skip interpreter trampoline, add interpreter lines
korniltsev Mar 25, 2025
c0a52bb
update dependency
korniltsev Jun 9, 2025
ec296a8
Merge remote-tracking branch 'origin/main' into korniltsev/otel-profiler
korniltsev Jun 9, 2025
aaea20e
fix build
korniltsev Jun 9, 2025
5a699d6
simplify
korniltsev Jun 9, 2025
6d338ac
fix build
korniltsev Jun 9, 2025
5a51cdf
fix build
korniltsev Jun 9, 2025
5dbaf2d
handle controller start errors
korniltsev Jun 10, 2025
5bf3ab9
tracefs automount
korniltsev Jun 11, 2025
e0bf597
Merge remote-tracking branch 'origin/main' into korniltsev/otel-profiler
korniltsev Jun 11, 2025
29a4039
revert go mod
korniltsev Jun 11, 2025
943345a
revert
korniltsev Jun 11, 2025
749f10e
bump dep
korniltsev Jun 11, 2025
845fd7e
increase cache time, increase max stack depth, disable switching from…
korniltsev Jun 12, 2025
6f51fa5
revert cache lifetime changes
korniltsev Jun 13, 2025
df50394
bump
korniltsev Jun 13, 2025
a9c32e4
fix decrease hotspot memory usage
korniltsev Jun 13, 2025
f732425
update ebpf-profiler dependency, remove placeholder function names
korniltsev Jun 17, 2025
bcb76be
set hasFunctions
korniltsev Jun 17, 2025
c2a10ad
update ebpf-profiler dependency
korniltsev Jun 17, 2025
625a50b
Merge remote-tracking branch 'origin/main' into korniltsev/otel-profiler
korniltsev Jun 24, 2025
31eb2f8
fix build
korniltsev Jun 24, 2025
091cf26
cleanup
korniltsev Jun 24, 2025
9dbe9fe
cleanup
korniltsev Jun 24, 2025
c5cf7b8
lint
korniltsev Jun 24, 2025
21cdd37
revert gitignore
korniltsev Jun 24, 2025
f92c399
Update docs/sources/reference/components/pyroscope/pyroscope.ebpf.md
korniltsev Jun 25, 2025
d6778fe
Merge remote-tracking branch 'origin/main' into korniltsev/otel-profiler
korniltsev Jun 25, 2025
b80a7b4
Merge remote-tracking branch 'origin/korniltsev/otel-profiler' into k…
korniltsev Jun 25, 2025
4343497
Update docs/sources/reference/components/pyroscope/pyroscope.ebpf.md
korniltsev Jun 26, 2025
cd10b20
review fixes
korniltsev Jun 26, 2025
9892ce7
deprecate more
korniltsev Jun 26, 2025
d3163b9
FileObserver cleanup
korniltsev Jun 26, 2025
b4d2a96
filenames
korniltsev Jul 2, 2025
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS="$TARGETOS" GOARCH="$TARGETARCH" GOARM=${TARGETVARIANT#v} \
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
GO_TAGS="netgo builtinassets promtail_journal_enabled" \
GO_TAGS="netgo builtinassets promtail_journal_enabled pyroscope_ebpf" \
GOEXPERIMENT=${GOEXPERIMENT} \
make alloy

Expand Down
59 changes: 37 additions & 22 deletions docs/sources/reference/components/pyroscope/pyroscope.ebpf.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ title: pyroscope.ebpf
`pyroscope.ebpf` configures an eBPF profiling job for the current host.
The collected performance profiles are forwarded to the list of receivers passed in `forward_to`.

The `pyroscope.ebpf` component embeds the [`grafana/opentelemetry-ebpf-profiler`][] which is a fork of [`open-telemetry/opentelemetry-ebpf-profiler`][].

[`grafana/opentelemetry-ebpf-profiler`]: https://github.com/grafana/opentelemetry-ebpf-profiler
[`open-telemetry/opentelemetry-ebpf-profiler`]: https://github.com/open-telemetry/opentelemetry-ebpf-profiler

{{< admonition type="note" >}}
To use the `pyroscope.ebpf` component you must run {{< param "PRODUCT_NAME" >}} as root and inside the host PID namespace.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying that using the helm chart, I am getting this error:

ts=2025-03-13T11:13:53.483392128Z level=error msg="node exited with error" node=pyroscope.ebpf.local_pods err="failed to start agent controller: failed to attach scheduler monitor: failed to configure tracepoint on tracer.hookPoint{group:\"sched\", name:\"sched_process_exit\"}: neither debugfs nor tracefs are mounted"

This fixes it:

  mounts:
    extra:
    - name: debugfs
      mountPath: /sys/kernel/debug
      readOnly: true
 controller:
   volumes:
      extra:
     - name: debugfs
       hostPath:
         path: /sys/kernel/debug
         type: Directory

I think as this change might be quite disruptive, we maybe also should investigate, if we do that when the folder is not mounted:

mount -t debugfs -o nosuid,nodev,noexec debugfs /sys/kernel/debug/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can try mounting it ourselves. We're superuser afterall. I remember I did this in a branch for convenience.
https://github.com/grafana/pyroscope/pull/3184/files#diff-ed660caba4be49d0b3854003a14e854719b063ad0141ec736c8e1119a3c7a9a7R30

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I currently run alloy using pyroscope.ebpf with only few capabilities (BFP,PERF,PTRACE), and I believe that the mount syscall at least requires SYS_ADMIN, would there be any workaround or it is mandatory to mount this fs ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can mount the fs yourself and the component will not issue any mount syscalls

{{< /admonition >}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add a note pointing to the underlying profiler being used?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added links 6cdbdb4

{{< admonition type="note" >}}
The profiler requires file system storage at `/tmp/symb-cache` to store symbol cache data. Ensure this directory is accessible and has sufficient storage space.
{{< /admonition >}}

You can specify multiple `pyroscope.ebpf` components by giving them different labels, however it's not recommended as it can lead to additional memory and CPU usage.

## Supported languages

This eBPF profiler only collects CPU profiles. Generally, natively compiled languages like C/C++, Go, and Rust are supported. Refer to [Troubleshooting unknown symbols][troubleshooting] for additional requirements.

Python is the only supported high-level language, as long as `python_enabled=true`.
Other high-level languages like Java, Ruby, PHP, and JavaScript require additional work to show stack traces of methods in these languages correctly.
Currently, the CPU usage for these languages is reported as belonging to the runtime's methods.
- Native code (C/C++, Rust, Zig, Go, etc. without debug symbols on host)
- Broad set of HLLs (Hotspot JVM, Python, Ruby, PHP, Node.JS, V8, Perl).

## Usage

Expand All @@ -44,27 +50,36 @@ The component configures and starts a new eBPF profiling job to collect performa

You can use the following arguments with `pyroscope.ebpf`:

| Name | Type | Description | Default | Required |
| ------------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- |
| `forward_to` | `list(ProfilesReceiver)` | List of receivers to send collected profiles to. | | yes |
| `targets` | `list(map(string))` | List of targets to group profiles by container id | | yes |
| `build_id_cache_size` | `int` | The size of the elf file build id -> symbols table LRU cache | `64` | no |
| `collect_interval` | `duration` | How frequently to collect profiles | `"15s"` | no |
| `collect_kernel_profile` | `bool` | A flag to enable/disable collection of kernelspace profiles | `true` | no |
| `collect_user_profile` | `bool` | A flag to enable/disable collection of userspace profiles | `true` | no |
| `container_id_cache_size` | `int` | The size of the PID -> container ID table LRU cache | `1024` | no |
| `demangle` | `string` | C++ demangle mode. Available options are: `none`, `simplified`, `templates`, or `full` | `"none"` | no |
| `go_table_fallback` | `bool` | A flag to enable symbol lookup in `.sym` / `.dynsym` sections when `.gopclntab` lookup failed. May be useful for `cgo` binaries. | `false` | no |
| `pid_cache_size` | `int` | The size of the PID -> proc symbols table LRU cache | `32` | no |
| `pid_map_size` | `int` | The size of eBPF PID map | `2048` | no |
| `python_enabled` | `bool` | A flag to enable/disable python profiling | `true` | no |
| `same_file_cache_size` | `int` | The size of the elf file -> symbols table LRU cache | `8` | no |
| `sample_rate` | `int` | How many times per second to collect profile samples | `97` | no |
| `symbols_map_size` | `int` | The size of eBPF symbols map | `16384` | no |
| Name | Type | Description | Default | Required |
|---------------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------|----------|----------|
| `forward_to` | `list(ProfilesReceiver)` | List of receivers to send collected profiles to. | | yes |
| `targets` | `list(map(string))` | List of targets to group profiles by container ID. | | yes |
| `build_id_cache_size` | `int` | Deprecated (no-op), previously controlled the size of the elf file build id -> symbols table LRU cache. | `64` | no |
| `cache_rounds` | `int` | Deprecated (no-op), previously controlled the number of cache rounds. | | no |
| `collect_interval` | `duration` | How frequently to collect profiles. | `"15s"` | no |
| `collect_kernel_profile` | `bool` | Deprecated (no-op), previously enabled collection of kernelspace profiles. | `true` | no |
| `collect_user_profile` | `bool` | Deprecated (no-op), previously enabled collection of userspace profiles. | `true` | no |
| `container_id_cache_size` | `int` | The size of the PID -> container ID table LRU cache. | `1024` | no |
| `demangle` | `string` | C++ demangle mode. Available options are: `none`, `simplified`, `templates`, or `full`. | `"none"` | no |
| `dotnet_enabled` | `bool` | A flag to enable or disable .NET profiling. | `true` | no |
| `go_table_fallback` | `bool` | Deprecated (no-op), previously enabled symbol lookup in `.sym` / `.dynsym` sections when `.gopclntab` lookup failed. | `false` | no |
| `hotspot_enabled` | `bool` | A flag to enable ordisable hotspot profiling. | `true` | no |
| `perl_enabled` | `bool` | A flag to enable or disable Perl profiling. | `true` | no |
| `php_enabled` | `bool` | A flag to enable or disable PHP profiling. | `true` | no |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should go_enabled be also documented?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current revision of the go consumes shit ton of memory and cpu and it works much better without it (i.e. using our symbolizer). We may want to add go here after we update our fork to include open-telemetry/opentelemetry-ebpf-profiler#456 which is not straightforward because it removes the rust lib and we rely on it. tldr - yes, but later.

| `pid_cache_size` | `int` | Deprecated (no-op), previously controlled the size of the PID -> proc symbols table LRU cache. | `32` | no |
| `pid_map_size` | `int` | Deprecated (no-op), previously controlled the size of eBPF PID map. | `2048` | no |
| `python_enabled` | `bool` | A flag to enable or disable python profiling. | `true` | no |
| `ruby_enabled` | `bool` | A flag to enable or disable Ruby profiling. | `true` | no |
| `same_file_cache_size` | `int` | Deprecated (no-op), previously controlled the size of the elf file -> symbols table LRU cache. | `8` | no |
| `sample_rate` | `int` | How many times per second to collect profile samples. | `19` | no |
| `symbols_map_size` | `int` | Deprecated (no-op), previously controlled the size of eBPF symbols map . | `16384` | no |
| `v8_enabled` | `bool` | A flag to enable/disable V8 profiling. | `true` | no |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to also pass through OTEL_PROFILING_AGENT_VERBOSE=1 as an argument

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the one hand I like this idea, but on the other I want to introduce as little arguments as possible. It is currently possible to enable this flag through env variable. I'd prefer to keep it an undocumented debugging-facility feature. WDYT?

Only the `forward_to` and `targets` fields are required.
Omitted fields take their default values.

Several arguments are marked as "Deprecated (no-op)". These arguments were previously used for configuring various cache sizes and behaviors, but they no longer have any effect. They are kept for backward compatibility but will be removed in a future release. It is recommended to remove these arguments from your configuration.

## Blocks

The `pyroscope.ebpf` component doesn't support any blocks. You can configure this component with arguments.
Expand Down
Loading