l2meter 0.0.4 → 0.0.5

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: 6464aec35fa1c921dc2bf7d268842bad9c8ebc5e
4
- data.tar.gz: fa8b3bec0bfcca18cd9033fc58e4f66b89ec3ded
3
+ metadata.gz: 9dfbf4e39c16435603394a7404fbac26b60c5142
4
+ data.tar.gz: 48cdfe785015cf19420daae0c1928b46b85d5f88
5
5
  SHA512:
6
- metadata.gz: 7d30a0631c60f8512cf1857bfffafa29e31ac4b357d849295b0c6f83c8b4e5814d4eef3ad25c163f40e95d3a7a022d52f0ee9faba416164d838e424603364ac7
7
- data.tar.gz: 553ae36661226e85f9089579a28283fe4748d81463b89edc6ed638ec23cd661ec1566c4a31dc0583bb9789c0eb46ded9464a35ce7f3be58b8d514570530c9195
6
+ metadata.gz: 2baf257241f5b9975294db76308a3a52bf5a8908656123cbefd39dbba5f7e63ea8f44c9743ea9da9c35c0682d5f04e3fb496ac41120bfac4337e9954a5ca1093
7
+ data.tar.gz: 1321770da5b2f42aef7c068325c0f9323673caf563487ce991d94df7f89167aa7495c6c5200562e4fcb2d0dceb36b41ce8251f8be5727e6e2fe6872c5d60c461
data/README.md CHANGED
@@ -159,6 +159,17 @@ config.source = "production"
159
159
  metrics.log foo: :bar # => source=production foo=bar
160
160
  ```
161
161
 
162
+ #### Prefix
163
+
164
+ Prefix allows namespacing your measure/count/unique/sample calls.
165
+
166
+ ```ruby
167
+ config.prefix = "my-app"
168
+
169
+ # ...
170
+
171
+ metrics.count :users, 100500 # => count#my-app.users=100500
172
+
162
173
  ## Silence
163
174
 
164
175
  There's a way to temporary silence the log emitter. This might be userful for
@@ -1,7 +1,7 @@
1
1
  module L2meter
2
2
  class Configuration
3
3
  attr_writer :output
4
- attr_accessor :source
4
+ attr_accessor :source, :prefix
5
5
  attr_reader :contexts
6
6
 
7
7
  def initialize
@@ -29,13 +29,11 @@ module L2meter
29
29
  end
30
30
 
31
31
  def measure(metric, value, unit: nil)
32
- metric = [metric, unit].compact * ?.
33
- log_with_prefix :measure, metric, value
32
+ log_with_prefix :measure, metric, value, unit: unit
34
33
  end
35
34
 
36
35
  def sample(metric, value, unit: nil)
37
- metric = [metric, unit].compact * ?.
38
- log_with_prefix :sample, metric, value
36
+ log_with_prefix :sample, metric, value, unit: unit
39
37
  end
40
38
 
41
39
  def count(metric, value=1)
@@ -95,8 +93,9 @@ module L2meter
95
93
  configuration.output.print tokens.join(" ") + "\n"
96
94
  end
97
95
 
98
- def log_with_prefix(prefix, key, value)
99
- log Hash["#{prefix}##{key}", value]
96
+ def log_with_prefix(method, key, value, unit: nil)
97
+ key = [configuration.prefix, key, unit].compact * ?.
98
+ log Hash["#{method}##{key}", value]
100
99
  end
101
100
 
102
101
  def wrap(params)
@@ -1,3 +1,3 @@
1
1
  module L2meter
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: l2meter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud