2 releases

0.1.1 Feb 20, 2023
0.1.0 Feb 13, 2023

#962 in HTTP server

Download history 145/week @ 2024-03-13 113/week @ 2024-03-20 137/week @ 2024-03-27 121/week @ 2024-04-03 133/week @ 2024-04-10 46/week @ 2024-04-17 16/week @ 2024-04-24 17/week @ 2024-05-01 50/week @ 2024-05-08 20/week @ 2024-05-15 31/week @ 2024-05-22 27/week @ 2024-05-29 35/week @ 2024-06-05 42/week @ 2024-06-12 21/week @ 2024-06-19 148/week @ 2024-06-26

255 downloads per month
Used in atomic-server

MIT license

72KB
59 lines

simple-server-timing-header

crates.io Documentation

Lightweight zero-dependency Rust crate that adds a Server-Timing header to the response of a request.


use simple_server_timing_header::Timer;

fn handle_request() {
    let mut timer = Timer::new();
    // ... do some stuff
    timer.add("parse_headers");
    // ... do some more stuff
    timer.add("get_db_data");
    // Sets the `Server-Timing: parse_headers;dur=0.1, get_db_data;dur=0.2` header
    add_header(timer.header_key(), timer.header_value());
}

Example of server-timing in Chrome dev tools


lib.rs:

Monitor back-end performance using Server-Timing the HTTP header.

use simple_server_timing_header::Timer;

fn handle_request() {
let mut timer = Timer::new();
// ... do some stuff
timer.add("parse_headers");
// ... do some more stuff
timer.add("get_db_data");
// Generate the header value
assert_eq!(timer.header_value(), "parse_headers;dur=0, get_db_data;dur=0");
}

No runtime deps