Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adam12/rack-server-timing
https://github.com/adam12/rack-server-timing
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/adam12/rack-server-timing
- Owner: adam12
- Created: 2018-11-11T01:00:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T00:45:14.000Z (8 months ago)
- Last Synced: 2024-11-30T13:36:04.789Z (about 1 month ago)
- Language: Ruby
- Size: 26.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this 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:
```ruby
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:
```ruby
# config.ru
require "rack-server-timing/middleware"use RackServerTiming::Middleware
run ->(env) {
[200, {}, ["It Works!"]]
}
```And then record your metrics:
```ruby
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).
```ruby
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.```ruby
DB = Sequel.connectDB.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](http://www.igvita.com/2011/12/19/dont-push-your-pull-requests/)
before attempting a pull request.## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).