Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Ability to configure the percentiles sent to Librato #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ By default you can use `LIBRATO_USER` and `LIBRATO_TOKEN` to pass your account d
* `LIBRATO_PROXY` - HTTP proxy to use when connecting to the Librato API (can also use the `https_proxy` or `http_proxy` environment variable commonly supported by Linux command line utilities)
* `LIBRATO_AUTORUN` - set to `'0'` to prevent the reporter from starting, useful if you don't want `librato-rack` to start under certain circumstances
* `LIBRATO_EVENT_MODE` - use with evented apps, see "Use with EventMachine" below
* `LIBRATO_PERCENTILES` - the timing percentiles to capture. Default is p95. Provide as a comma separated list, e.g. `95,99`

##### Use a configuration object

Expand Down
2 changes: 1 addition & 1 deletion lib/librato/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module Librato
class Rack
RECORD_RACK_BODY = <<-'EOS'
group.increment 'total'
group.timing 'time', duration, percentile: 95
group.timing 'time', duration, percentile: config.percentiles
group.increment 'slow' if duration > 200.0
EOS

Expand Down
3 changes: 2 additions & 1 deletion lib/librato/rack/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Configuration

attr_accessor :api_endpoint, :autorun, :disable_rack_metrics,
:flush_interval, :log_level, :log_prefix,
:log_target, :proxy, :suites,
:log_target, :percentiles, :proxy, :suites,
:tags, :token, :tracker, :user
attr_reader :deprecations, :prefix

Expand Down Expand Up @@ -64,6 +64,7 @@ def load_configuration
self.proxy = ENV['LIBRATO_PROXY'] || ENV['https_proxy'] || ENV['http_proxy']
self.event_mode = ENV['LIBRATO_EVENT_MODE']
self.suites = ENV['LIBRATO_SUITES'] || ''
self.percentiles = ENV['LIBRATO_PERCENTILES']&.split(',')&.map(&:to_i) || [95]
check_deprecations
end

Expand Down
2 changes: 2 additions & 0 deletions test/unit/rack/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ def test_environment_variable_config
ENV["LIBRATO_TAGS"] = "hostname=metrics-web-stg-1"
ENV['LIBRATO_PROXY'] = 'http://localhost:8080'
ENV['LIBRATO_SUITES'] = 'foo,bar'
ENV['LIBRATO_PERCENTILES'] = '95,99'
expected_tags = { hostname: "metrics-web-stg-1" }
config = Configuration.new
assert_equal '[email protected]', config.user
assert_equal 'api_key', config.token
assert_equal expected_tags, config.tags
assert_equal 'http://localhost:8080', config.proxy
assert_equal 'foo,bar', config.suites
assert_equal [95, 99], config.percentiles
#assert Librato::Rails.explicit_source, 'source is explicit'
end

Expand Down