2 releases

0.1.1 Feb 20, 2023
0.1.0 Feb 13, 2023

#697 in HTTP server

Download history 116/week @ 2024-07-23 81/week @ 2024-07-30 134/week @ 2024-08-06 147/week @ 2024-08-13 1831/week @ 2024-08-20 4512/week @ 2024-08-27 6733/week @ 2024-09-03 7685/week @ 2024-09-10 6351/week @ 2024-09-17 7465/week @ 2024-09-24 8018/week @ 2024-10-01 9357/week @ 2024-10-08 10064/week @ 2024-10-15 9243/week @ 2024-10-22 8579/week @ 2024-10-29 4061/week @ 2024-11-05

32,981 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