How grafana/pyroscope-go works
Pyroscope Go Client profiles an application and sends profile snapshots to a Pyroscope server. Its main push workflow starts a session, periodically collects enabled CPU, memory, goroutine, block, and mutex data, encodes profiles, and submits upload jobs through an upstream. The README also documents pull profiling through pprof HTTP routes and label-based filtering; the tree includes a k6 baggage middleware integration. The session excerpt supports the collection and upload flow; connections for unsampled subsystems are limited to documented behavior.
Main entry points: session.go Profiling session · upstream.go Upload job · api.go Start API · labels.go App labels
Components 18
Client session
- Start API
api.go - Profiling session
session.go - App labels
internal/semconv/labels.go - Label validation
internal/labelset/labelset.go
Profile collection
- CPU collector
collector.go - Go runtime profiles
session.go - Delta profiles
godeltaprof/block.go - Heap profiler
godeltaprof/heap.go - Profile encoding
godeltaprof/internal/pprof/proto.go
Upload transport
- Upload job
upstream/upstream.go - Upstream interface
upstream/upstream.go - Remote uploader
upstream/remote/remote.go
Integrations
- Pprof HTTP routes
http/pprof/pprof.go - Runtime pprof
internal/pprof/pprof.go - k6 baggage middleware
x/k6/baggage.go
Other components
- Go application
- Pyroscope server
- HTTP or gRPC request
Connections 21
- Go application → Start API: starts profiling
- Start API → Profiling session: creates session
- Profiling session → App labels: builds app names
- App labels → Label validation: parses and validates
- Profiling session → CPU collector: starts CPU collection
- Profiling session → Go runtime profiles: reads runtime profiles
- Profiling session → Delta profiles: dumps block and mutex
- Profiling session → Heap profiler: dumps heap deltas
- Delta profiles → Profile encoding: encodes profile
- Heap profiler → Profile encoding: encodes profile
- CPU collector → Upload job: creates upload jobs
- Profiling session → Upload job: submits snapshots
- Go runtime profiles → Upload job: packages profiles
- Upload job → Upstream interface: submitted through
- Upstream interface → Remote uploader: implemented by
- Remote uploader → Pyroscope server: posts profile data
- HTTP or gRPC request → Pprof HTTP routes: requests profile
- Pprof HTTP routes → Runtime pprof: collects CPU profile
- Runtime pprof → HTTP or gRPC request: writes profile response
- HTTP or gRPC request → k6 baggage middleware: carries baggage
- k6 baggage middleware → Go application: sets profiling labels