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 +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -2
- data/lib/yabeda/datadog/exceptions.rb +5 -4
- data/lib/yabeda/datadog/version.rb +1 -1
- data/lib/yabeda/datadog.rb +31 -27
- data/yabeda-datadog.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 651b614460ad3fbb136abd049623f7d7fc66a853c0a0ea28ceb0b0e0d996c453
|
4
|
+
data.tar.gz: c36b5413fb880de21b89b9ff7f22c63a1500e8a834f47fa24a4b8f2ce1158964
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19fe55d75d1ab7f3dabe2b2f410c1dd8b0e36eab05edf9289ed7c51c123b424e22cb6920b53ed721826c6b90fe0a303f9ac95ee97e3839d4ef3d57ec009a79b5
|
7
|
+
data.tar.gz: 7b527fe8982935d83f2023b8408bc0564673726e35c074b8749b6392bb6be82c77f25941cfb5f6ba71f6088b1eeba71b23a3a31b45c31e569306703875c08006
|
data/.rubocop.yml
CHANGED
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
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 <
|
7
|
-
def initialize(msg = "Datadog API key
|
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 <
|
14
|
-
def initialize(msg = "Datadog application key
|
14
|
+
class AppKeyError < ConfigError
|
15
|
+
def initialize(msg = "Datadog application key is missing")
|
15
16
|
super
|
16
17
|
end
|
17
18
|
end
|
data/lib/yabeda/datadog.rb
CHANGED
@@ -14,36 +14,40 @@ module Yabeda
|
|
14
14
|
SECOND = 1
|
15
15
|
COLLECT_INTERVAL = 60 * SECOND
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
data/yabeda-datadog.gemspec
CHANGED
@@ -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.
|
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.
|
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
|
+
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.
|
176
|
+
version: 2.3.0
|
176
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
178
|
requirements:
|
178
179
|
- - ">="
|