Coder Social home page Coder Social logo

sid-maddy / pyroscope-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grafana/pyroscope-rs

0.0 0.0 0.0 1.09 MB

Pyroscope Profiler for Rust. Profile your Rust applications.

License: Apache License 2.0

Shell 1.03% Ruby 7.41% Python 4.38% C 0.54% Rust 83.51% Makefile 2.19% Dockerfile 0.04% Jsonnet 0.91%

pyroscope-rs's Introduction

Pyroscope Profiler

Pyroscope Profiler for Rust. Profile your Rust applications.

license tests build Crate


You may be looking for:

Table of Contents

Quick Start

Add this to your Cargo.toml:

[dependencies]
pyroscope = "0.5.4"
pyroscope_pprofrs = "0.2"

Include Pyroscope and pprof-rs dependencies:

use pyroscope::PyroscopeAgent;
use pyroscope_pprofrs::{pprof_backend, PprofConfig};

Configure the Pyroscope agent:

 let agent =
     PyroscopeAgent::builder("http://localhost:4040", "myapp-profile")
     .backend(pprof_backend(PprofConfig::new().sample_rate(100)))
     .build()?;

Profile your code:

 let agent_running = agent.start()?;

 // Computation to profile 

 let agent_ready = agent_running.stop()?;
 agent_ready.shutdown();

Pyroscope Server

The Pyroscope Agent send the profiling data to a Pyroscope Server. You need to have a Pyroscope Server running in order to consume and visualize this data. It's not possible, currently, to forward the data to another endpoint.

Multi-Threading

The Pyroscope Agent and the pprof-rs backend can profile and report data from a multi-threaded program. pprof-rs, however, does not track child-processes and thus profiling is limited to a single process.

Profiling Backends

The Pyroscope Agent doesn't do any profiling. The agent role is to orchestrate a profiling backend, and report the profiling data to the Pyroscope Server. The Agent can support external backends (in fact, all current backends are independent crates) and you can make your own. Backends can also be used seperately. The currently available backends are:

Native Integration

Pyroscope can be used directly from your projects with native integration. No agent or external programs are required.

Limitations

  • Backend: The Pyroscope Agent uses pprof-rs as a backend. As a result, the limitations for pprof-rs also applies.
  • Tagging: As of 0.5.0, the Pyroscope Agent support tagging within threads. Check the Tags and Multi-Thread examples for usage.
  • Timer: epoll (for Linux) and kqueue (for macOS) are required for a more precise timer.
  • Shutdown: The Pyroscope Agent might take some time (usually less than 10 seconds) to shutdown properly and drop its threads. For a proper shutdown, it's recommended that you run the shutdown function before dropping the Agent.

Getting help

You can read the Docs or check the examples for detailed usage of the library. You can also join the Slack channel if you have questions.

Major Contributors

We'd like to give a big thank you to the following contributors who have made significant contributions to this project:

License

Pyroscope is distributed under the Apache License (Version 2.0).

See LICENSE for details.

pyroscope-rs's People

Contributors

omarabid avatar korniltsev avatar petethepig avatar drahnr avatar hi-rustin avatar alindima avatar devzbysiu avatar voxelot avatar mati865 avatar mjmdavis avatar olofj avatar zhangsoledad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.