bmc-daemon-lib 0.3.4 → 0.3.6

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: 07d8df6da72c6e6fdaafac2a1a67b78ecf760859
4
- data.tar.gz: 8f64f4c0c20bf983b5e1bb4ba4e0272737a5ec20
3
+ metadata.gz: 29df8c92767e8d6c0a33210b7c02a3095790cf37
4
+ data.tar.gz: 7c4744d9b4981d68bac75faa50b121c8cf8c7cca
5
5
  SHA512:
6
- metadata.gz: 350eec5594f1353e43f7929f03eac494de915c9d29c91e3c4f507f7d736399cc23e7b409651c3be26db0dff826ca3c8c20a37f8f02fcb73685fdc3dbed05fd0f
7
- data.tar.gz: a938502ae7175af87becfe05990994a18fa7f1e6f659911d162a550be18628d10deb012b772ccd314a840fd4c8c33c9d65651490175665e3bd3b5766c38aade0
6
+ metadata.gz: f40cd3776b912f2059f8cbc58874deda6a381a66a0113510df38cdb5e6cd295eab798f97a78679dfa61ef4ed82a55883b9d8933d62d8dd919ef5798f57423425
7
+ data.tar.gz: fa834d967a25fdabbd2c30c74c4f71601d83b5143d279ef53aa3072c5b513c237be6a3b528a06c2ac9b9579f491e90639b843d360f17eea760c2017e0acf0e77
data/Gemfile.lock CHANGED
@@ -1,8 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bmc-daemon-lib (0.3.4)
4
+ bmc-daemon-lib (0.3.6)
5
5
  chamber (~> 2.9)
6
+ newrelic_rpm
7
+ rollbar
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
@@ -13,16 +15,20 @@ GEM
13
15
  thor (~> 0.19.1)
14
16
  diff-lcs (1.2.5)
15
17
  hashie (3.4.4)
18
+ multi_json (1.12.1)
19
+ newrelic_rpm (3.16.2.321)
16
20
  parser (2.3.1.2)
17
21
  ast (~> 2.2)
18
22
  powerpack (0.1.1)
19
23
  rainbow (2.1.0)
20
24
  rake (11.2.2)
25
+ rollbar (2.12.0)
26
+ multi_json
21
27
  rspec (3.5.0)
22
28
  rspec-core (~> 3.5.0)
23
29
  rspec-expectations (~> 3.5.0)
24
30
  rspec-mocks (~> 3.5.0)
25
- rspec-core (3.5.2)
31
+ rspec-core (3.5.3)
26
32
  rspec-support (~> 3.5.0)
27
33
  rspec-expectations (3.5.0)
28
34
  diff-lcs (>= 1.2.0, < 2.0)
@@ -39,7 +45,7 @@ GEM
39
45
  unicode-display_width (~> 1.0, >= 1.0.1)
40
46
  ruby-progressbar (1.8.1)
41
47
  thor (0.19.1)
42
- unicode-display_width (1.1.0)
48
+ unicode-display_width (1.1.1)
43
49
 
44
50
  PLATFORMS
45
51
  ruby
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  # Project version
4
- spec.version = "0.3.4"
4
+ spec.version = "0.3.6"
5
5
 
6
6
  # Project description
7
7
  spec.name = "bmc-daemon-lib"
@@ -25,6 +25,9 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "rspec"
26
26
  spec.add_development_dependency "rubocop"
27
27
 
28
+
28
29
  # Runtime dependencies
29
30
  spec.add_runtime_dependency "chamber", "~> 2.9"
31
+ spec.add_runtime_dependency "newrelic_rpm"
32
+ spec.add_runtime_dependency "rollbar"
30
33
  end
@@ -2,7 +2,9 @@
2
2
  require "rubygems"
3
3
  require "syslog"
4
4
  require "thread"
5
-
5
+ require "chamber"
6
+ require 'newrelic_rpm'
7
+ require 'rollbar'
6
8
 
7
9
  # Project's libs
8
10
  require_relative "bmc-daemon-lib/conf"
@@ -1,6 +1,4 @@
1
1
  # FIXME: files named with hyphens will not be found by Chamber for now
2
- require "chamber"
3
-
4
2
  module BmcDaemonLib
5
3
  # Class exceptions
6
4
  class ConfigInitiRequired < StandardError; end
@@ -80,8 +78,9 @@ module BmcDaemonLib
80
78
  Encoding.default_internal = "utf-8"
81
79
  Encoding.default_external = "utf-8"
82
80
 
83
- # Init New Relic
84
- prepare_newrelic self[:newrelic]
81
+ # Init New Relic, Rollbar
82
+ prepare_newrelic if self.feature?(:newrelic)
83
+ prepare_rollbar if self.feature?(:rollbar)
85
84
 
86
85
  # Try to access any key to force parsing of the files
87
86
  self[:dummy]
@@ -92,6 +91,7 @@ module BmcDaemonLib
92
91
  fail ConfigOtherError, "#{e.message} \n #{e.backtrace.to_yaml}"
93
92
  end
94
93
 
94
+
95
95
  # Reload files
96
96
  def self.reload!
97
97
  ensure_init
@@ -126,9 +126,18 @@ module BmcDaemonLib
126
126
  File.expand_path specific.to_s, path.to_s
127
127
  end
128
128
 
129
- def self.newrelic_enabled?
129
+ def self.feature? name
130
130
  ensure_init
131
- !! (self[:newrelic] && self[:newrelic][:license])
131
+
132
+ # Guess if the specific feature si available
133
+ case name
134
+ when :newrelic
135
+ self.at(:newrelic, :license)
136
+ when :rollbar
137
+ self.at(:rollbar, :token)
138
+ else
139
+ false
140
+ end
132
141
  end
133
142
 
134
143
  # Defaults generators
@@ -173,9 +182,9 @@ module BmcDaemonLib
173
182
  @files << File.expand_path(path) if path && File.readable?(path)
174
183
  end
175
184
 
176
- def self.prepare_newrelic section
177
- # Disable NewRelic if no config present
178
- return unless self.newrelic_enabled?
185
+ def self.prepare_newrelic
186
+ # Require lib
187
+ section = self[:newrelic]
179
188
 
180
189
  # Enable GC profiler
181
190
  GC::Profiler.enable
@@ -200,6 +209,33 @@ module BmcDaemonLib
200
209
  ENV["NEWRELIC_AGENT_ENABLED"] = "true"
201
210
  end
202
211
 
212
+ def self.prepare_rollbar
213
+ # # Disable if no config present
214
+ # return unless self.feature?(:rollbar)
215
+ section = self[:rollbar]
216
+
217
+ # Configure
218
+ Rollbar.configure do |config|
219
+ config.enabled = true
220
+ config.access_token = section[:token].to_s
221
+ config.code_version = @app_version
222
+
223
+ #config.logger
224
+ config.environment = @app_env
225
+
226
+ # Report asynchronously
227
+ config.use_async = true
228
+ # Here we'll disable in 'test':
229
+ # if Rails.env.test? || Rails.env.development?
230
+ # config.enabled = false
231
+ # end
232
+ #logfile_path(:newrelic)
233
+ end
234
+
235
+ # Notify startup
236
+ Rollbar.info("#{@app_name} #{@app_ver} [#{@host}]")
237
+ end
238
+
203
239
  private
204
240
 
205
241
  def self.ensure_init
@@ -7,7 +7,7 @@ module BmcDaemonLib
7
7
  include Singleton
8
8
 
9
9
  def get pipe = nil
10
- pipe = :default if pipe.to_s.blank?
10
+ pipe = :default if pipe.to_s.empty?
11
11
 
12
12
  @loggers ||= {}
13
13
  @loggers[pipe] ||= create(pipe)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmc-daemon-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno MEDICI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: newrelic_rpm
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rollbar
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description: 'Shared utilities to build a daemon: logger, configuration, helpers'
84
112
  email: bmc-daemon-lib@bmconseil.com
85
113
  executables: []