Skip to content

Go library for adding Server-Timing headers to your application.

License

Notifications You must be signed in to change notification settings

rubenv/servertiming

Repository files navigation

servertiming

Go library for adding Server-Timing headers to your application.

Build Status GoDoc

Timings in Chrome Dev Tools

Usage

// Create a new instance:

    t := servertiming.New()

// Optionally enable name prefixing to preserve the order of metrics (will adjust names though!)

    t.EnablePrefix()

// Add a few metrics, either by manually specifying the duration:

    t.Add("cache", "Cache Read", 23200*time.Microsecond)

// Or by using the start-stop API:

    ti.Start("db", "Database query")
    // query db
    ti.Stop("db")

// Then send it with your response:

    w.Header().Set("Server-Timing", ti.String())

Note: timings can be sent as a trailer when using HTTP2, see the example in net/http: Example (Trailers).

License

This library is distributed under the MIT license.

About

Go library for adding Server-Timing headers to your application.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages