GithubHelp home page GithubHelp logo

no9 / tide-trace Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 1.0 34 KB

USDT middleware for Tide to enable dynamic probes that can be used with ebpf on Linux and Dtrace on other *nixes

License: MIT License

Rust 52.42% Makefile 8.28% C 10.28% DTrace 7.31% Shell 21.71%
usdt tide rust

tide-trace's Introduction

tide-trace

Minimum overhead USDT middleware to dynamically trace tide with BPF or DTrace.

$ cargo run --example histogram

$ sudo bpftrace -p $(pgrep histogram) tools/route-histogram.bt
Attaching 2 probes...

$ curl http://localhost:8080/route1 && curl http://localhost:8080/route2


^C
@us[GET, /favicon.ico]: 
[32, 64)               1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|

@us[GET, /route1]: 
[32, 64)               2 |@@@@@@@@@@@@@@@@@                                   |
[64, 128)              6 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[128, 256)             2 |@@@@@@@@@@@@@@@@@                                   |

@us[GET, /route2]: 
[32, 64)               2 |@@@@@@@@@@@@@@@@@@@@                                |
[64, 128)              5 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[128, 256)             4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           |

pre-requisites

linux

ubuntu

$ sudo apt-get install systemtap-sdt-dev bpftrace

fedora

$ sudo dnf install systemtap-sdt-devel bpftrace

mac

This middleware is intended to work on mac but has not been fully tested

$ brew install make 

example usage

For a prebuilt applications see examples folder

Make a project

$ cargo init sample-project

Cargo.toml

tide = "0.15"
async-std = { version = "1.8.0", features = ["attributes"] }
tide-trace = { version = "0.4.0" }

main.rs

#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
    tide::log::start();
    let mut app = tide::new();
    app.middleware(tide_trace::USDTMiddleware::new(0));
    app.at("/").get(|_| async { Ok("Hello, world!") });
    app.listen("127.0.0.1:8080").await?;
    Ok(())
}

trace requests

$ sudo bpftrace -p $(pgrep sample-project) tools/routes.bt 
$ curl http://localhost:8080/

tests

$ cargo build --examples 
$ sudo ./tests/test-all.sh

tide-trace's People

Contributors

bbigras avatar no9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

bbigras

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.