No release in over 3 years
Low commit activity in last 3 years
Server-Timing headers for Rack applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0.1
>= 0.1
>= 1.2
>= 2.0, < 4.0
 Project Readme

Server Timing for Rack

Easily record and emit Server-Timing headers in your Rack applications.

Installation

Add this line to your application's Gemfile:

gem "rack-server-timing"

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-server-timing

Usage in a Rack application

Simply require and add middleware:

# config.ru
require "rack-server-timing/middleware"

use RackServerTiming::Middleware

run ->(env) {
  [200, {}, ["It Works!"]]
}

And then record your metrics:

env["rack.server_timing"].record("DB", 200)

Usage in a Roda application

Enable the plugin server_timing after render (if you wish to have the rendering profiled automatically).

class App < Roda
  plugin :render # Optional
  plugin :server_timing
end

A convenient server_timing helper is available to quickly record or benchmark timing values.

Sequel timing

Enable the server_timing extension in your database instance. This extension will automatically create a null logging instance if there is no logging configured so there may be a small performance hit.

DB = Sequel.connect

DB.extension :server_timing

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/adam12/rack-server-timing.

I love pull requests! If you fork this project and modify it, please ping me to see if your changes can be incorporated back into this project.

That said, if your feature idea is nontrivial, you should probably open an issue to discuss it before attempting a pull request.

License

The gem is available as open source under the terms of the MIT License.