Skip to main content

Module profiling

Module profiling 

Source
Expand description

In-process profiling admin server.

On Unix targets, the server always serves a CPU pprof profile at GET /debug/pprof/profile?seconds=N. With the heap-profiling feature, which needs jemalloc, the server also serves a heap pprof profile at GET /debug/pprof/heap. Grafana Alloy pyroscope.scrape scrapes both. The same admin server can carry more routes, for example /metrics.

The bodies are gzipped Profile protobufs. This is the standard pprof file format, and it is what Go’s net/http/pprof serves. Alloy’s pyroscope.scrape forwards the scraped bytes without a change as the push API’s raw_profile, and the ingester gunzips them. An uncompressed protobuf body makes that gunzip fail with “invalid gzip header”.

CPU profiling uses POSIX signals, so it is available only on Unix. On non-Unix targets the server returns a 503 stub, and the crate thus compiles on all platforms. On wasm32-wasip1 there is no server at all, because the admin server binds its own socket: the module exports only the configuration types there.

Structs§

ProfilingConfig
Process-local CPU and heap profiling policy.
ProfilingSampleFrequency
A positive, finite, whole-Hz sampling frequency accepted by pprof, whose frequency input is a signed int.

Enums§

ProfilingError
Profiling configuration or admin-server failure.

Functions§

await_admin_exit
Wait for a supervised admin task, treating every terminal outcome as an error.
pprof_router
The pprof routes with the compatible default policy.
pprof_router_with_config
The pprof routes with an explicit policy.
serve_admin
Bind an admin HTTP server on addr.
serve_admin_from_env
Like serve_admin, but with the bind address from the environment.
serve_admin_from_env_with
Like serve_admin_from_env, but it also merges extra with the pprof routes.
serve_admin_from_env_with_config
Like serve_admin_from_env_with with explicit profiling policy.
serve_admin_with_config
Bind a profiling admin server with explicit policy.
spawn_admin_from_env_with_config
Environment-address variant of spawn_admin_with_config.
spawn_admin_with_config
Bind a profiling admin server and return its task for lifecycle supervision.