Instrument a Python application with the Pyroscope SDK for continuous profiling

domain: grafana.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install the Pyroscope Python SDK: pip install pyroscope-io
  2. Initialize the profiler at application startup by calling pyroscope.configure() with server_address pointing to your Pyroscope or Grafana Pyroscope endpoint, application_name, and auth_token=YOUR_TOKEN if using Grafana Cloud
  3. Add tags to the profiler configuration using the tags dict for static labels (environment, version) and use pyroscope.tag_wrapper() as a context manager to attach dynamic labels (like endpoint or job type) around specific code blocks
  4. For background tasks and async applications call pyroscope.configure() once and rely on the SDK's thread-based sampling; for multi-process applications initialize the profiler in each worker process after fork
  5. Deploy the application and navigate to the Pyroscope or Grafana Explore Profiles UI; select the application name and profile type (cpu, memory allocations) and inspect the flamegraph
  6. Compare profiles across time windows or between app versions using the diff flamegraph view to identify regressions

Known gotchas

Related routes

Instrument a Go service for continuous profiling with Grafana Pyroscope using the push SDK
grafana.com · 5 steps · unrated
Set up continuous profiling for a Go service using Pyroscope with pprof pull mode and correlate profiles with traces
grafana.com · 5 steps · unrated
Emit and ingest the experimental OpenTelemetry profiling signal using the OTel Collector and Pyroscope exporter
opentelemetry.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans