statsd-instrument 2.2.1 → 2.3.0.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c90b5a926408cac6e7ddb08b2828626eabb890f3
4
- data.tar.gz: b006fad637fb15c07f9167e9fbe06bc889ec539f
3
+ metadata.gz: 23dbeea8c2ad9492a763224eebc870d68d3ec115
4
+ data.tar.gz: b5dc664058c39b461fcd96600f3175aca88d7195
5
5
  SHA512:
6
- metadata.gz: 89b66de0c70a829a3d5e884ac93b4885958c50a0e84dd157230bc798afe4b014fa836b47af5fe8cae099cd56b15b6751b20d262c453a507b70e9ee9ca858eca5
7
- data.tar.gz: 2754ba8ae91ced3221bbabc16b97b6272d8cbc269888caed3e9842a5ac69433b4f444cc57cc92cd61aa7bf4becd07bffba68af6df905da1f4c4db67fd1383678
6
+ metadata.gz: e564fd57696fcf3ea78351ad54dc566b0cddd6ead6d18005168c482dc22ba636fed9357a3804bc1a676f6953c48a706f4b4a7f583d97acf74b24c919882e7362
7
+ data.tar.gz: 51928197842090a75ffa25c6d1837d307f90408e645b801cdab05ad0b05ba3775ec471b0e1b1cef05f250891389a84205259f5d4459ab0d43031ad038d91c0c8
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ please at an entry to the "unreleased changes" section below.
5
5
 
6
6
  ### Unreleased changes
7
7
 
8
+ ### Version 2.3.0.beta
9
+
10
+ - Add support for beta, datadog specifc distribution metrics
11
+
8
12
  ### Version 2.2.1
9
13
 
10
14
  - Fix performance regression from v2.2.0
@@ -23,6 +23,10 @@ module StatsD::Instrument::Assertions
23
23
  assert_statsd_call(:h, metric_name, options, &block)
24
24
  end
25
25
 
26
+ def assert_statsd_distribution(metric_name, options = {}, &block)
27
+ assert_statsd_call(:d, metric_name, options, &block)
28
+ end
29
+
26
30
  def assert_statsd_set(metric_name, options = {}, &block)
27
31
  assert_statsd_call(:s, metric_name, options, &block)
28
32
  end
@@ -21,7 +21,7 @@ module StatsD::Instrument::Backends
21
21
  message: 'm',
22
22
  }
23
23
 
24
- SUPPORTED_METRIC_TYPES = BASE_SUPPORTED_METRIC_TYPES.merge(h: true, _e: true, _sc: true)
24
+ SUPPORTED_METRIC_TYPES = BASE_SUPPORTED_METRIC_TYPES.merge(h: true, _e: true, _sc: true, d: true)
25
25
 
26
26
  def generate_packet(metric)
27
27
  packet = ""
@@ -7,6 +7,7 @@ module StatsD::Instrument::Matchers
7
7
  measure: :ms,
8
8
  gauge: :g,
9
9
  histogram: :h,
10
+ distribution: :d,
10
11
  set: :s,
11
12
  key_value: :kv
12
13
  }
@@ -91,6 +91,7 @@ class StatsD::Instrument::Metric
91
91
  ms: 'measure',
92
92
  g: 'gauge',
93
93
  h: 'histogram',
94
+ d: 'distribution',
94
95
  kv: 'key/value',
95
96
  s: 'set',
96
97
  }
@@ -49,6 +49,7 @@ class StatsD::Instrument::MetricExpectation
49
49
  ms: 'measure',
50
50
  g: 'gauge',
51
51
  h: 'histogram',
52
+ d: 'distribution',
52
53
  kv: 'key/value',
53
54
  s: 'set',
54
55
  }
@@ -64,4 +65,4 @@ class StatsD::Instrument::MetricExpectation
64
65
  def inspect
65
66
  "#<StatsD::Instrument::MetricExpectation #{self.to_s}>"
66
67
  end
67
- end
68
+ end
@@ -1,5 +1,5 @@
1
1
  module StatsD
2
2
  module Instrument
3
- VERSION = "2.2.1"
3
+ VERSION = "2.3.0.beta"
4
4
  end
5
5
  end
@@ -339,6 +339,21 @@ module StatsD
339
339
  collect_metric(hash_argument(metric_options).merge(type: :h, name: key, value: value))
340
340
  end
341
341
 
342
+ # Emits a distribution metric.
343
+ # @param key [String] The name of the metric.
344
+ # @param value [Numeric] The value to record.
345
+ # @param metric_options [Hash] (default: {}) Metric options
346
+ # @return (see #collect_metric)
347
+ # @note Supported by the datadog implementation only (in beta)
348
+ def distribution(key, value, *metric_options)
349
+ if value.is_a?(Hash) && metric_options.empty?
350
+ metric_options = [value]
351
+ value = value.fetch(:value, nil)
352
+ end
353
+
354
+ collect_metric(hash_argument(metric_options).merge(type: :d, name: key, value: value))
355
+ end
356
+
342
357
  # Emits a key/value metric.
343
358
  # @param key [String] The name of the metric.
344
359
  # @param value [Numeric] The value to record.
data/test/statsd_test.rb CHANGED
@@ -117,6 +117,15 @@ class StatsDTest < Minitest::Test
117
117
  assert_equal 42, metric.value
118
118
  end
119
119
 
120
+ def test_statsd_distribution
121
+ result = nil
122
+ metric = capture_statsd_call { result = StatsD.distribution('values.foobar', 42) }
123
+ assert_equal metric, result
124
+ assert_equal :d, metric.type
125
+ assert_equal 'values.foobar', metric.name
126
+ assert_equal 42, metric.value
127
+ end
128
+
120
129
  def test_statsd_key_value
121
130
  result = nil
122
131
  metric = capture_statsd_call { result = StatsD.key_value('values.foobar', 42) }
@@ -76,6 +76,12 @@ class UDPBackendTest < Minitest::Test
76
76
  StatsD.histogram('fooh', 42.4)
77
77
  end
78
78
 
79
+ def test_distribution_syntax_on_datadog
80
+ @backend.implementation = :datadog
81
+ @backend.expects(:write_packet).with('fooh:42.4|d')
82
+ StatsD.distribution('fooh', 42.4)
83
+ end
84
+
79
85
  def test_event_on_datadog
80
86
  @backend.implementation = :datadog
81
87
  @backend.expects(:write_packet).with('_e{4,3}:fooh|baz|h:localhost:3000|@0.01|#foo')
@@ -127,6 +133,13 @@ class UDPBackendTest < Minitest::Test
127
133
  StatsD.histogram('fooh', 42.4)
128
134
  end
129
135
 
136
+ def test_distribution_warns_if_not_using_datadog
137
+ @backend.implementation = :other
138
+ @backend.expects(:write_packet).never
139
+ @logger.expects(:warn)
140
+ StatsD.distribution('fooh', 42.4)
141
+ end
142
+
130
143
  def test_supports_key_value_syntax_on_statsite
131
144
  @backend.implementation = :statsite
132
145
  @backend.expects(:write_packet).with("fooy:42|kv\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsd-instrument
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Storimer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-05-23 00:00:00.000000000 Z
13
+ date: 2018-05-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -158,9 +158,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  requirements:
161
- - - ">="
161
+ - - ">"
162
162
  - !ruby/object:Gem::Version
163
- version: '0'
163
+ version: 1.3.1
164
164
  requirements: []
165
165
  rubyforge_project:
166
166
  rubygems_version: 2.6.14