new_backup 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/new_backup/datadog.rb +21 -10
- data/lib/new_backup/main.rb +3 -0
- data/lib/new_backup/version.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/new_backup/datadog.rb
CHANGED
@@ -47,17 +47,19 @@ module NewBackup
|
|
47
47
|
|
48
48
|
include Methadone::CLILogging
|
49
49
|
|
50
|
-
|
51
|
-
@environment = (ENV['RAILS_ENV'].nil? || ENV['RAILS_ENV'].empty?) ? 'development' : ENV['RAILS_ENV']
|
50
|
+
DataDogger = Struct.new :api_key, :environment, :client
|
52
51
|
|
53
52
|
module_function
|
54
53
|
|
55
54
|
def api_key
|
56
|
-
|
55
|
+
$dogger ||= DataDogger.new
|
56
|
+
$dogger.api_key
|
57
57
|
end
|
58
58
|
|
59
59
|
def api_key=(api_key)
|
60
|
-
|
60
|
+
$dogger ||= DataDogger.new
|
61
|
+
$dogger.api_key=api_key
|
62
|
+
debug "#{self.class}##{__method__}@#{__LINE__}: $dogger.api_key: #{$dogger.api_key}"
|
61
63
|
end
|
62
64
|
|
63
65
|
def dogger(msg, options={})
|
@@ -69,21 +71,30 @@ module NewBackup
|
|
69
71
|
else
|
70
72
|
info msg
|
71
73
|
end
|
74
|
+
debug "#{self.class}##{__method__}@#{__LINE__}: $dogger exists? #{$dogger.inspect}"
|
75
|
+
debug "#{self.class}##{__method__}@#{__LINE__}: $dogger.api_key: #{$dogger.api_key}"
|
76
|
+
return if $dogger.api_key.nil? || $dogger.api_key.empty?
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
|
78
|
+
$dogger.client ||= Dogapi::Client.new($dogger.api_key)
|
79
|
+
debug "#{self.class}##{__method__}@#{__LINE__}: $dogger.client: #{$dogger.client.inspect}"
|
80
|
+
|
81
|
+
$dogger.environment ||= (ENV['RAILS_ENV'].nil? || ENV['RAILS_ENV'].empty?) ? 'development' : ENV['RAILS_ENV']
|
82
|
+
|
83
|
+
hostname = `hostname`.chomp
|
76
84
|
|
77
85
|
emit_options = {
|
78
86
|
:msg_title => msg,
|
79
|
-
:alert_type => (options[:type] == :error) ? '
|
80
|
-
:tags => [ "host:#{
|
87
|
+
:alert_type => (options[:type] == :error) ? 'error' : 'success',
|
88
|
+
:tags => [ "host:#{hostname}", "env:#{$dogger.environment}", "new_backup" ],
|
81
89
|
:priority => 'normal',
|
90
|
+
:host => hostname,
|
82
91
|
:source => 'MyApps'}
|
83
92
|
|
84
93
|
body = options[:body] ||= msg
|
85
94
|
|
86
|
-
|
95
|
+
this_event = Dogapi::Event.new(body, emit_options)
|
96
|
+
debug "#{self.class}##{__method__}@#{__LINE__}: emit_options: #{emit_options.to_yaml}\nbody: #{body}\nthis_event: #{this_event.inspect}"
|
97
|
+
$dogger.client.emit_event(this_event)
|
87
98
|
|
88
99
|
end
|
89
100
|
|
data/lib/new_backup/main.rb
CHANGED
@@ -105,6 +105,9 @@ module NewBackup
|
|
105
105
|
|
106
106
|
debug @options.to_yaml
|
107
107
|
|
108
|
+
$dogger = DataDogger.new
|
109
|
+
$dogger.api_key=@options[:datadog][:api_key] unless @options[:debug]
|
110
|
+
debug "#{self.class}##{__method__}@#{__LINE__}: $dogger.api_key: #{$dogger.api_key}"
|
108
111
|
|
109
112
|
end
|
110
113
|
|
data/lib/new_backup/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: new_backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -205,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
205
|
version: '0'
|
206
206
|
segments:
|
207
207
|
- 0
|
208
|
-
hash:
|
208
|
+
hash: -1819741959940293617
|
209
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
210
|
none: false
|
211
211
|
requirements:
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
segments:
|
216
216
|
- 0
|
217
|
-
hash:
|
217
|
+
hash: -1819741959940293617
|
218
218
|
requirements: []
|
219
219
|
rubyforge_project:
|
220
220
|
rubygems_version: 1.8.24
|