Skip to content

Commit

Permalink
Add example for custom label builders in collector middleware
Browse files Browse the repository at this point in the history
Fixes #29.
  • Loading branch information
grobie committed Aug 18, 2016
1 parent 40091e1 commit ddc6d68
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion examples/rack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,31 @@
A simple Rack application which shows how to use prometheus' `Rack::Exporter`
and `Rack::Collector` rack middlwares.

## Usage
## Run the example

Execute the provided `run` script:

```bash
./run
```

This will start the rack app, run a few requests against it and print the
output of `/metrics`.

## Overview

The example show in [`config.ru`](config.ru) is a trivial rack application
using the available collector and exporter middlewares.

In order to use a custom label builder, change the line to something like this:

```ruby
use Prometheus::Client::Rack::Collector do |env|
{
method: env['REQUEST_METHOD'].downcase,
host: env['HTTP_HOST'].to_s,
path: env['PATH_INFO'].to_s,
user_agent: env['HTTP_USER_AGENT'].to_s,
}
end
```

0 comments on commit ddc6d68

Please sign in to comment.