statful-client 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/client.rb +17 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2082d2f2574057de832307766202d6a492f4817c
4
- data.tar.gz: b9326d3830adb06a4ab25123ca489a1238408a30
3
+ metadata.gz: 5584d17bad505e388a9a32cbcb2adb3acceacdb0
4
+ data.tar.gz: 0ae8df0d1bcdb2bc44ff20b76bd5a67584f69c96
5
5
  SHA512:
6
- metadata.gz: 5a09ee6befcecc28200828770b37a1cec711316121b691c617635ade92af7e75b8c0af4ff20d7a2f8bb4dec05d1bd67802e98f883f54664d5867023c647d3dd6
7
- data.tar.gz: 0f9a337a23504ad89aac1a4b9ac0d9d5b8f9d731a297d42c3b836f4e527d75c23c14abd55029791675e7a959006f5d04e4badec6b2493016888db03c8bd28d04
6
+ metadata.gz: 4b7f4b7ae1fa3e5198465458908ed204e1c74dae903da4e0450c022c81700215edf73a289dad16772dd6710c89165c21aa5cd0310d9d68f9ab2929f2c552faa0
7
+ data.tar.gz: 409d9d331ad2cfe686db336a882905cd5d6dd013c54fb77022407a30d6160599da29b6a3758823d5f5877840f5011c05567e664caaa57c4100d246f8d6925c30
data/lib/client.rb CHANGED
@@ -153,17 +153,23 @@ class StatfulClient
153
153
  # @private
154
154
  # @param metric [String] Name of the metric, ex: `response_time`
155
155
  # @param value [Numeric] Value of the metric
156
- # @param tags [Hash] Tags to associate to the metric
157
- # @param agg [Array<String>] List of aggregations to be applied by Statful
158
- # @param agg_freq [Integer] Aggregation frequency in seconds
159
- # @param sample_rate [Integer] Sampling rate, between: (1-100)
160
- # @param namespace [String] Namespace of the metric
161
- # @param timestamp [Integer] Timestamp of the metric
162
- def put(metric, tags, value, agg = [], agg_freq = 10, sample_rate = nil, namespace = 'application', timestamp = nil)
163
- _tags = @config[:tags]
164
- _tags = _tags.merge(tags) unless tags.nil?
156
+ # @param [Hash] options The options to apply to the metric
157
+ # @param options tags [Hash] Tags to associate to the metric
158
+ # @param options agg [Array<String>] List of aggregations to be applied by Statful
159
+ # @param options agg_freq [Integer] Aggregation frequency in seconds
160
+ # @param options sample_rate [Integer] Sampling rate, between: (1-100)
161
+ # @param options namespace [String] Namespace of the metric
162
+ # @param options timestamp [Integer] Timestamp of the metric
163
+ def put(metric, value, options = {})
164
+ tags = @config[:tags]
165
+ tags = tags.merge(options[:tags]) unless options[:tags].nil?
166
+
167
+ agg = options[:agg].nil? ? [] : options[:agg]
168
+
169
+ sample_rate = options[:sample_rate].nil? ? 100 : options[:sample_rate]
170
+ namespace = options[:namespace].nil? ? 'application' : options[:namespace]
165
171
 
166
- _put(metric, _tags, value, agg, agg_freq, sample_rate, namespace, timestamp)
172
+ _put(metric, tags, value, agg, options[:agg_freq], sample_rate, namespace, options[:timestamp])
167
173
  end
168
174
 
169
175
  private
@@ -182,7 +188,7 @@ class StatfulClient
182
188
  # @param sample_rate [Integer] Sampling rate, between: (1-100)
183
189
  # @param namespace [String] Namespace of the metric
184
190
  # @param timestamp [Integer] Timestamp of the metric
185
- def _put(metric, tags, value, agg = [], agg_freq = 10, sample_rate = nil, namespace = 'application', timestamp = nil)
191
+ def _put(metric, tags, value, agg = [], agg_freq = 10, sample_rate = 100, namespace = 'application', timestamp = nil)
186
192
  metric_name = "#{namespace}.#{metric}"
187
193
  sample_rate_normalized = sample_rate / 100
188
194
  timestamp = Time.now.to_i if timestamp.nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statful-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Fonseca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-12 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler