RousselTMLEARNING

Article · Grafana Pyroscope: from discovery to expertise

Continuous profiling

1. The fourth signal #

What metrics, logs and traces do not tell you.

From « what » to « which line of code » #

Available in: ✓ OSS ✓ Enterprise ✓ Cloud Pyroscope open source and Grafana Cloud Profiles

Metrics say a service uses 4 CPUs, traces say which call is slow, logs tell what happened. None of them says which function consumes that CPU or allocates that memory. That is the role of profiling.

Continuous profiling constantly samples the call stack of processes in production (for example 100 times per second) with low overhead (often 1 to 3% CPU). You can then go back to yesterday's spike, compare two versions or find the most expensive function across a fleet.

SignalQuestionGrafana tool
MetricsHow much? Is it normal?Prometheus, Mimir
LogsWhat happened?Loki
TracesWhere was time spent between services?Tempo
ProfilesWhich function consumes CPU or memory?Pyroscope
Good to know: Pyroscope was born in 2020 as an independent project, acquired by Grafana Labs in 2023 and merged with Grafana Phlare. It is open source (AGPLv3). OpenTelemetry is also standardizing profiles as a signal in their own right (OTLP profiles protocol, still in development).

2. Profile types #

CPU, memory, locks, goroutines.

The main types #

TypeMeasuresLanguages
CPU (process_cpu)CPU time spent in each functionAll
Wall clock (wall)Real time, including waitsJava, Python, .NET, Ruby
Allocations (alloc_objects, alloc_space)What is allocated (GC pressure)Go, Java, .NET
Memory in use (inuse_objects, inuse_space)What stays in memory (leaks)Go
Locks (mutex, block, lock)Time waiting on locks and channelsGo, Java, .NET
GoroutinesNumber of goroutines per stackGo

In Pyroscope, a profile type is identified by a string such as process_cpu:cpu:nanoseconds:cpu:nanoseconds (name:sample type:unit:period type:unit).

3. Reading a flame graph #

The reference visualization.

Principle #

Example flame graph
Here, 38% of the CPU is consumed by a regular expression called from computePrice.
  • Each rectangle is a function; its children (below it in Grafana) are the functions it calls.
  • The width is the share of samples in which this function was on the stack: the wider, the more it costs.
  • Horizontal order has no temporal meaning (sorted alphabetically or by size).
  • Self time is the part of a function not covered by any child: it is the function's own code.
Good practice: Look for « plateaus »: a wide rectangle at the very bottom of a stack is a function that actually does work. Grafana's « Top table » sorts functions by self time: it is often the fastest starting point.

4. Pyroscope in the stack #

Collection, storage, exploration.

Three ways to send profiles #

ModePrincipleWhen to use it
SDK (push)The Pyroscope library in the application sends its profilesBusiness labels, span profiles, languages without pprof
Alloy (pull)Alloy collects exposed pprof endpoints (Go, Rust...)Go applications already instrumented with net/http/pprof
Alloy eBPFAlloy profiles all processes on the host via the kernelProfiling a whole fleet without changing code

📄 Continuous profiling with Grafana Pyroscope: why and how →

My progress

  • ⏱ Estimated time : ≈ 4 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Profiles, OpenTelemetry's fourth signal: continuous profiling and correlation with traces

Understand OpenTelemetry's new profile signal: continuous profiling, flame graphs, data model and...

Grafana Alloy: Continuous Profiling with Pyroscope

Discover how to configure continuous profiling in your environments using Grafana Alloy and Pyros...

Continuous profiling with eBPF: Parca, Pyroscope and the OpenTelemetry profiler

Continuously profile every process on a host with eBPF: principle, Parca and parca-agent, Pyrosco...

Analyzing profiles in Grafana: flame graphs, comparisons and diagnostics

A method for analyzing profiles in Grafana: Profiles Drilldown, flame graph and top table, compar...

Grafana Pyroscope best practices: collection, labels, analysis and costs

Production checklist for continuous profiling with Pyroscope: choosing the collection mode, label...

Linking traces and profiles: span profiles with Tempo and Pyroscope

Go from a slow trace to the exact CPU profile of that span: span profiles in Go and Java, configu...

Profiling & Optimization in Dynatrace

Find the code lines consuming CPU and memory with continuous profiling.

Instrumenting applications for Pyroscope: SDKs, Alloy and eBPF

Send profiles to Pyroscope from Go, Java, Python and Node.js with the SDKs, collect pprof endpoin...

Grafana Pyroscope architecture and deployment

Pyroscope components (distributor, ingester, querier, store-gateway, compactor), object storage, ...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!