dogstatsd-instrumentation 0.1.1 → 0.1.2

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: 7e2fa7745e8e0793c50a6be0683b60aaee4ac7a4
4
- data.tar.gz: 7143630e2fc8f2b8e686600ce82f4c2b4642b033
3
+ metadata.gz: 05cb2153af9acaf0a45aca5f299aa2ec0fd313ad
4
+ data.tar.gz: 1c9958aeba4035cb8c1d081110d84a44170edda9
5
5
  SHA512:
6
- metadata.gz: 6264454b32d13ed346be65630da6edb420483815166ca314ff5b64bfa446066e7f6f52e39be4296426360d07d1099303465a23f88b5b61e3f8ba80fb33decb55
7
- data.tar.gz: e63199070314dcf70a525523a351abf8b68c3327da058aba68b0d3a781fae9e2cc4956c66bac7d783ffb87d34ef022715f2c88e89d2ba94e1abe773c23992846
6
+ metadata.gz: 5c9b26c6e66d98149ced5c6db9faacd6149834e2dfe0686e80a4adb2d09359079c9ed04673fffa4b415310d80c4202ef4d9452c079703813d920659caf4c09da
7
+ data.tar.gz: a226e71edfa0345bff2e835f956a6440c6654659587a493410f342790827ad52b35d46a99c785432e8cf2099805cb0cc0226f3f5d081893a59bf838f9fa0416c
@@ -13,7 +13,7 @@ module DogStatsd
13
13
  end
14
14
 
15
15
  def self.version
16
- "0.1.1"
16
+ "0.1.2"
17
17
  end
18
18
 
19
19
  def self.version_label
@@ -10,7 +10,9 @@ module DogStatsd
10
10
  include GemConfig::Base
11
11
 
12
12
  with_configuration do
13
- has :environments, classes: Array, default: ['production']
13
+ has :enabled, classes: [TrueClass, FalseClass], default: true
14
+ has :base_tags, classes: Hash, default: {}
15
+
14
16
  has :host, classes: String, default: Datadog::Statsd::DEFAULT_HOST
15
17
  has :port, classes: Integer, default: Datadog::Statsd::DEFAULT_PORT
16
18
  has :opts, classes: Hash, default: {}
@@ -21,13 +23,15 @@ module DogStatsd
21
23
  def self.configure
22
24
  super
23
25
  @@subscriber.unsubscribe if @@subscriber
24
- @@subscriber = Subscriber.new(configuration)
26
+ @@subscriber = Subscriber.new(configuration) if configuration.enabled
25
27
  end
26
28
 
27
29
  @@subscriber = nil
28
30
 
29
31
  class Subscriber
30
32
  def initialize(configuration)
33
+ @base_tags = configuration.base_tags
34
+
31
35
  @statsd = Datadog::Statsd.new(
32
36
  configuration.host,
33
37
  configuration.port,
@@ -53,10 +57,10 @@ module DogStatsd
53
57
  end
54
58
 
55
59
  def instrument(stat:, value:, tags:)
56
- @statsd.histogram stat, value, tags: tagify(tags)
60
+ @statsd.histogram stat, value, tags: Subscriber.tagify(@base_tags.merge(tags))
57
61
  end
58
62
 
59
- def tagify(hash)
63
+ def self.tagify(hash)
60
64
  hash.select{|_,value| value.present? }.map { |key, value| "#{key}:#{value}" }
61
65
  end
62
66
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dogstatsd-instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Costa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-17 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dogstatsd-ruby