Module: StatsD::Instrument::Strict
- Included in:
- Client
- Defined in:
- lib/statsd/instrument/strict.rb
Overview
The Strict monkeypatch can be loaded to see if you're using the StatsD library in a deprecated way.
- The metric methods are not retuning a Metric instance.
- Only accept keyword arguments for tags and sample_rate, rather than position arguments.
- Only accept a position argument for value, rather than a keyword argument.
- The provided arguments have the right type.
You can enable this monkeypatch by changing your Gemfile as follows:
gem 'statsd-instrument', require: 'statsd/instrument/strict'
By doing this as part of your QA/CI, you can find where you are still using deprecated patterns, and fix them before the deprecated behavior is removed in the next major version.
This monkeypatch is not meant to be used in production.
Instance Method Summary collapse
- #distribution(key, value = UNSPECIFIED, sample_rate: nil, tags: nil, no_prefix: false, &block) ⇒ Object
- #event(title, text, tags: nil, no_prefix: false, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) ⇒ Object
- #gauge(key, value, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
- #histogram(key, value, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
- #increment(key, value = 1, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
- #measure(key, value = UNSPECIFIED, sample_rate: nil, tags: nil, no_prefix: false, &block) ⇒ Object
- #service_check(name, status, tags: nil, no_prefix: false, hostname: nil, timestamp: nil, message: nil) ⇒ Object
- #set(key, value, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
Instance Method Details
#distribution(key, value = UNSPECIFIED, sample_rate: nil, tags: nil, no_prefix: false, &block) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/statsd/instrument/strict.rb', line 79 def distribution(key, value = UNSPECIFIED, sample_rate: nil, tags: nil, no_prefix: false, &block) check_block_or_numeric_value(value, &block) (sample_rate, ) super end |
#event(title, text, tags: nil, no_prefix: false, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) ⇒ Object
66 67 68 69 70 |
# File 'lib/statsd/instrument/strict.rb', line 66 def event(title, text, tags: nil, no_prefix: false, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) super end |
#gauge(key, value, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/statsd/instrument/strict.rb', line 36 def gauge(key, value, sample_rate: nil, tags: nil, no_prefix: false) raise ArgumentError, "StatsD.increment does not accept a block" if block_given? raise ArgumentError, "The value argument should be an integer, got #{value.inspect}" unless value.is_a?(Numeric) (sample_rate, ) super end |
#histogram(key, value, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/statsd/instrument/strict.rb', line 45 def histogram(key, value, sample_rate: nil, tags: nil, no_prefix: false) raise ArgumentError, "StatsD.increment does not accept a block" if block_given? raise ArgumentError, "The value argument should be an integer, got #{value.inspect}" unless value.is_a?(Numeric) (sample_rate, ) super end |
#increment(key, value = 1, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/statsd/instrument/strict.rb', line 27 def increment(key, value = 1, sample_rate: nil, tags: nil, no_prefix: false) raise ArgumentError, "StatsD.increment does not accept a block" if block_given? raise ArgumentError, "The value argument should be an integer, got #{value.inspect}" unless value.is_a?(Integer) (sample_rate, ) super end |
#measure(key, value = UNSPECIFIED, sample_rate: nil, tags: nil, no_prefix: false, &block) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/statsd/instrument/strict.rb', line 72 def measure(key, value = UNSPECIFIED, sample_rate: nil, tags: nil, no_prefix: false, &block) check_block_or_numeric_value(value, &block) (sample_rate, ) super end |
#service_check(name, status, tags: nil, no_prefix: false, hostname: nil, timestamp: nil, message: nil) ⇒ Object
62 63 64 |
# File 'lib/statsd/instrument/strict.rb', line 62 def service_check(name, status, tags: nil, no_prefix: false, hostname: nil, timestamp: nil, message: nil) super end |
#set(key, value, sample_rate: nil, tags: nil, no_prefix: false) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/statsd/instrument/strict.rb', line 54 def set(key, value, sample_rate: nil, tags: nil, no_prefix: false) raise ArgumentError, "StatsD.set does not accept a block" if block_given? (sample_rate, ) super end |