yabeda-datadog 0.3.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: 9d32a548b326cf89723f3edb5c9fec66a67dc81b095a6dca76820debe7028bfb
4
- data.tar.gz: eb01206ff99ab8eb4c47832cb19efd1e1552354a3628706c2e56df375a4d01e5
3
+ metadata.gz: 651b614460ad3fbb136abd049623f7d7fc66a853c0a0ea28ceb0b0e0d996c453
4
+ data.tar.gz: c36b5413fb880de21b89b9ff7f22c63a1500e8a834f47fa24a4b8f2ce1158964
5
5
  SHA512:
6
- metadata.gz: 78c79e937c0d597e02bbff887bca4a461368ff02f279b21bac8045478586965552778939c93fa21f569ad6a379efa34b058d95f45af05aee46b728c834b87c5c
7
- data.tar.gz: 8fab8b91c53cdb21d49a1e78e7a82f5b06508de6dfe3a418259451e9bcd80d8503aa75983b9ead17dea54230893ce9c9f4d285de224091b4e57ceed9849c7ffd
6
+ metadata.gz: 19fe55d75d1ab7f3dabe2b2f410c1dd8b0e36eab05edf9289ed7c51c123b424e22cb6920b53ed721826c6b90fe0a303f9ac95ee97e3839d4ef3d57ec009a79b5
7
+ data.tar.gz: 7b527fe8982935d83f2023b8408bc0564673726e35c074b8749b6392bb6be82c77f25941cfb5f6ba71f6088b1eeba71b23a3a31b45c31e569306703875c08006
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-rspec
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: "2.5.3"
6
+ TargetRubyVersion: 2.3
7
7
 
8
8
  Metrics/BlockLength:
9
9
  Exclude:
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.6.0
4
+ - 2.5.3
5
+ - 2.4.2
6
+ - 2.3.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yabeda-datadog (0.3.0)
4
+ yabeda-datadog (0.3.1)
5
5
  anyway_config (~> 1.0)
6
6
  dogapi
7
7
  dogstatsd-ruby
data/README.md CHANGED
@@ -38,7 +38,7 @@ Rails 5.1 users able to use encrypted rails secrets `Rails.application.secrets.y
38
38
  Example of `yabeda_datadog.yml` file:
39
39
 
40
40
  ```yaml
41
- # required
41
+ # required (if missing adapter is no-op)
42
42
  api_key: <your Datadog API key>
43
43
  app_key: <your Datadog App key>
44
44
 
@@ -60,7 +60,7 @@ log_level: 1
60
60
  Example of environment variables:
61
61
 
62
62
  ```shell
63
- # required
63
+ # required (if missing adapter is no-op)
64
64
  YABEDA_DATADOG_API_KEY=<your Datadog API key>
65
65
  YABEDA_DATADOG_APP_KEY=<your Datadog App key>
66
66
 
@@ -93,6 +93,8 @@ To start collecting and sending your metrics to Datadog agent run:
93
93
  Yabeda::Datadog.start
94
94
  ```
95
95
 
96
+ **NOTE**: if you're using Ruby <2.5.2 you might encounter [a bug related to the process forking](https://bugs.ruby-lang.org/issues/14634) (e.g. when using Puma web server). The workaround is to start `Yabeda::Datadog` after the `fork` (e.g. when using Puma, put `Yabeda::Datadog.start` inside the `on_worker_boot` callback).
97
+
96
98
  To star collecting Yabeda collect blocks (aka collectors) run the command:
97
99
 
98
100
  ```ruby
@@ -2,16 +2,17 @@
2
2
 
3
3
  module Yabeda
4
4
  module Datadog
5
+ class ConfigError < StandardError; end
5
6
  # = This error raised when no Datadog API key provided
6
- class ApiKeyError < StandardError
7
- def initialize(msg = "Datadog API key doesn't set")
7
+ class ApiKeyError < ConfigError
8
+ def initialize(msg = "Datadog API key is missing")
8
9
  super
9
10
  end
10
11
  end
11
12
 
12
13
  # = This error raised when no Datadog application key provided
13
- class AppKeyError < StandardError
14
- def initialize(msg = "Datadog application key doesn't set")
14
+ class AppKeyError < ConfigError
15
+ def initialize(msg = "Datadog application key is missing")
15
16
  super
16
17
  end
17
18
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Datadog
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
@@ -14,36 +14,40 @@ module Yabeda
14
14
  SECOND = 1
15
15
  COLLECT_INTERVAL = 60 * SECOND
16
16
 
17
- # Gem configuration object
18
- def self.config
19
- @config ||= Config.new
20
- end
21
-
22
- # Check the gem configuration has valid state
23
- def self.ensure_configured
24
- raise ApiKeyError unless config.api_key
25
- raise AppKeyError unless config.app_key
26
- end
17
+ class << self
18
+ # Gem configuration object
19
+ def config
20
+ @config ||= Config.new
21
+ end
27
22
 
28
- # Prepare the adapter to work
29
- def self.start
30
- ensure_configured
23
+ # Check the gem configuration has valid state
24
+ def ensure_configured
25
+ raise ApiKeyError unless config.api_key
26
+ raise AppKeyError unless config.app_key
27
+ end
31
28
 
32
- worker = Yabeda::Datadog::Worker.start(config)
33
- adapter = Yabeda::Datadog::Adapter.new(worker: worker)
34
- Yabeda.register_adapter(:datadog, adapter)
35
- adapter
36
- end
29
+ # Prepare the adapter to work
30
+ def start
31
+ ensure_configured
32
+ worker = Yabeda::Datadog::Worker.start(config)
33
+ adapter = Yabeda::Datadog::Adapter.new(worker: worker)
34
+ Yabeda.register_adapter(:datadog, adapter)
35
+ adapter
36
+ rescue ConfigError => e
37
+ Logging.instance.warn e.message
38
+ nil
39
+ end
37
40
 
38
- # Start collection metrics from Yabeda collectors
39
- def self.start_exporter(collect_interval: COLLECT_INTERVAL)
40
- Thread.new do
41
- Logging.instance.debug("initilize collectors harvest")
42
- loop do
43
- Logging.instance.debug("start collectors harvest")
44
- Yabeda.collectors.each(&:call)
45
- Logging.instance.debug("end collectors harvest")
46
- sleep(collect_interval)
41
+ # Start collection metrics from Yabeda collectors
42
+ def start_exporter(collect_interval: COLLECT_INTERVAL)
43
+ Thread.new do
44
+ Logging.instance.debug("initilize collectors harvest")
45
+ loop do
46
+ Logging.instance.debug("start collectors harvest")
47
+ Yabeda.collectors.each(&:call)
48
+ Logging.instance.debug("end collectors harvest")
49
+ sleep(collect_interval)
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.required_ruby_version = ">= 2.5.3"
30
+ spec.required_ruby_version = ">= 2.3.0"
31
31
 
32
32
  spec.add_dependency "anyway_config", "~> 1.0"
33
33
  spec.add_dependency "dogapi"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-datadog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Shvetsov <@shvetsovdm>
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-11 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -134,6 +134,7 @@ files:
134
134
  - ".gitignore"
135
135
  - ".rspec"
136
136
  - ".rubocop.yml"
137
+ - ".travis.yml"
137
138
  - CONTRIBUTING.md
138
139
  - Gemfile
139
140
  - Gemfile.lock
@@ -172,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
173
  requirements:
173
174
  - - ">="
174
175
  - !ruby/object:Gem::Version
175
- version: 2.5.3
176
+ version: 2.3.0
176
177
  required_rubygems_version: !ruby/object:Gem::Requirement
177
178
  requirements:
178
179
  - - ">="