new_backup 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- new_backup (1.0.2)
4
+ new_backup (1.0.3)
5
5
  RunIt
6
6
  dogapi
7
7
  fog
@@ -47,17 +47,19 @@ module NewBackup
47
47
 
48
48
  include Methadone::CLILogging
49
49
 
50
- @api_key = nil
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
- @api_key
55
+ $dogger ||= DataDogger.new
56
+ $dogger.api_key
57
57
  end
58
58
 
59
59
  def api_key=(api_key)
60
- @api_key=api_key
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
- return if @api_key.nil? || @api_key.empty?
74
-
75
- @client ||= Datadog::Client.new(@api_key)
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) ? 'Error' : 'Normal',
80
- :tags => [ "host:#{`hostname`}", "env:#{@environment}" ],
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
- @client.emit_event(Dogapi::Event.new(body, emit_options))
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
 
@@ -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
 
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
  module NewBackup
14
- VERSION = "1.0.2"
14
+ VERSION = "1.0.3"
15
15
  DESCRIPTION = "Backup an RDS database instance to S3, and create and obfuscated version"
16
16
  SUMMARY = DESCRIPTION
17
17
  end
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.2
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: 2444084947987149633
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: 2444084947987149633
217
+ hash: -1819741959940293617
218
218
  requirements: []
219
219
  rubyforge_project:
220
220
  rubygems_version: 1.8.24