errplane 0.1.9 → 0.2.0

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/README.md CHANGED
@@ -1,6 +1,62 @@
1
1
  Errplane
2
2
  ========
3
3
 
4
- This gem helps you integrate your Ruby on Rails applications with [Errplane](http://errplane.com), a cloud-based tool for handling exceptions, log aggregation, uptime monitoring, and alerting.
4
+ This gem integrates your applications with [Errplane](http://errplane.com), a cloud-based tool for handling exceptions, log aggregation, uptime monitoring, and alerting.
5
5
 
6
- It's a gem. You can figure out the rest.
6
+ This gem currently has support for Ruby on Rails (3.x), Sinatra, Resque, and Capistrano.
7
+
8
+ Support
9
+ -------
10
+
11
+ Running into any issues? Get in touch with us at [support@errplane.com](mailto:support@errplane.com).
12
+
13
+ Ruby on Rails Installation
14
+ --------------------------
15
+
16
+ Start by adding the gem to your Gemfile:
17
+
18
+ gem "errplane"
19
+
20
+ Then, issue the following commands in your application's root directory:
21
+
22
+ bundle
23
+ rails g errplane --api-key your-api-key-goes-here
24
+
25
+ This will create `config/initializers/errplane.rb` for you automatically. If you want to make sure that everything's working correctly, just run:
26
+
27
+ bundle exec rake errplane:test
28
+
29
+ You should be able to view the exception at [http://errplane.com](http://errplane.com) and also receive an email notification of the test exception.
30
+
31
+ Capistrano Integration
32
+ ----------------------
33
+
34
+ In your `config/deploy.rb`, add the following line:
35
+
36
+ require 'errplane/capistrano'
37
+
38
+ This will automatically pull your API key from the Rails initializer and notify Errplane of every deployment.
39
+
40
+ Resque Integration With Multiple Failure Backends
41
+ -------------------------------------------------
42
+
43
+ This gem also supports notifications from failed Resque jobs. Just add the following to the an initializer:
44
+
45
+ require 'resque/failure/multiple'
46
+ require 'resque/failure/redis'
47
+ require 'errplane/resque'
48
+
49
+ Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Errplane]
50
+ Resque::Failure.backend = Resque::Failure::Multiple
51
+
52
+ Don't forget that you can refer to `config/initializers/errplane.rb` for the relevant configuration values.
53
+
54
+ Contributing
55
+ ------------
56
+
57
+ We love contributions. Want to add support for something you don't already see here? Fork this repository and send us a pull request.
58
+
59
+ Copyright
60
+ ---------
61
+
62
+ Copyright (c) 2012 Errplane, Inc.
@@ -6,6 +6,7 @@ module Errplane
6
6
  attr_reader :controller
7
7
  attr_reader :action
8
8
  attr_reader :request_url
9
+ attr_reader :custom_data
9
10
 
10
11
  def initialize(params = {})
11
12
  @exception = params[:exception]
@@ -14,6 +15,7 @@ module Errplane
14
15
  @controller = params[:controller]
15
16
  @action = params[:action]
16
17
  @request_url = params[:request_url]
18
+ @custom_data = params[:custom_data] || {}
17
19
  end
18
20
 
19
21
  def to_json
@@ -30,7 +32,8 @@ module Errplane
30
32
  :language_version => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
31
33
  :environment_variables => ENV.to_hash,
32
34
  :reporter => reporter,
33
- :request_data => request_data
35
+ :request_data => request_data,
36
+ :custom_data => @custom_data
34
37
  }.to_json
35
38
  end
36
39
 
@@ -38,7 +41,7 @@ module Errplane
38
41
  {
39
42
  :name => "Errplane",
40
43
  :version => Errplane::VERSION,
41
- :url => "http://github.com/errplane/gem"
44
+ :url => "https://github.com/errplane/gem"
42
45
  }
43
46
  end
44
47
 
@@ -10,14 +10,16 @@ Capistrano::Configuration.instance(:must_exist).load do
10
10
  puts "Notifying Errplane of the deployment.."
11
11
  framework_env = fetch(:rails_env, fetch(:errplane_env, 'production'))
12
12
  load File.join(Dir.pwd, "config/initializers/errplane.rb")
13
+ Errplane.configuration.rails_environment = framework_env
13
14
 
14
15
  deploy_options = {
15
- :framework_env => framework_env,
16
- :scm_revision => current_revision,
17
- :scm_repository => repository,
18
- :api_key => Errplane.configuration.api_key
16
+ :environment => framework_env,
17
+ :revision => current_revision,
18
+ :repository => repository,
19
+ :scm => scm,
20
+ :host => host
19
21
  }
20
- Errplane::Deployment.new.announce!(deploy_options)
22
+ Errplane::Transmitter.new.relay(deploy_options, true)
21
23
  puts 'Done.'
22
24
  end
23
25
  end
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'errplane'
3
+ rescue LoadError
4
+ raise "Can't find 'errplane' gem. Please add it to your Gemfile or install it."
5
+ end
6
+
7
+ module Resque
8
+ module Failure
9
+ class Errplane < Base
10
+ def save
11
+ ::Errplane.transmit_unless_ignorable(exception, :custom_data => {
12
+ :resque => {
13
+ :payload => payload,
14
+ :worker => worker,
15
+ :queue => queue
16
+ }
17
+ })
18
+ end
19
+ end
20
+ end
21
+ end
@@ -3,15 +3,15 @@ module Errplane
3
3
  def initialize(params = {})
4
4
  end
5
5
 
6
- def relay(black_box)
6
+ def relay(black_box, deployment = false)
7
7
  http = initialize_http_connection
8
8
  data = black_box.to_json
9
9
  response = begin
10
- url = "/api/v1/applications/#{Errplane.configuration.application_id}/exceptions/#{Errplane.configuration.rails_environment}?api_key=#{Errplane.configuration.api_key}"
11
- ::Rails.logger.info("\nURL: #{url}")
12
- ::Rails.logger.info("\nData: #{data.inspect}")
10
+ url = "/api/v1/applications/#{Errplane.configuration.application_id}/exceptions/#{Errplane.configuration.rails_environment}#{"/deploy" if deployment}?api_key=#{Errplane.configuration.api_key}"
11
+ Errplane.configuration.logger.info("\nURL: #{url}") if Errplane.configuration.debug?
12
+ Errplane.configuration.logger.info("\nData: #{data.inspect}") if Errplane.configuration.debug?
13
13
  response = http.post(url, data)
14
- ::Rails.logger.info("\nException Response: #{response.inspect}")
14
+ Errplane.configuration.logger.info("\nException Response: #{response.inspect}") if Errplane.configuration.debug?
15
15
  response
16
16
  rescue Exception => e
17
17
  # e
@@ -1,3 +1,3 @@
1
1
  module Errplane
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errplane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-29 00:00:00.000000000 Z
12
+ date: 2012-07-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This gem provides exception reporting with Errplane for Rails 3.x applications.
15
15
  email:
@@ -29,11 +29,11 @@ files:
29
29
  - lib/errplane/black_box.rb
30
30
  - lib/errplane/capistrano.rb
31
31
  - lib/errplane/configuration.rb
32
- - lib/errplane/deployment.rb
33
32
  - lib/errplane/rack.rb
34
33
  - lib/errplane/rails/air_traffic_controller.rb
35
34
  - lib/errplane/rails/middleware/hijack_render_exception.rb
36
35
  - lib/errplane/railtie.rb
36
+ - lib/errplane/resque.rb
37
37
  - lib/errplane/sinatra.rb
38
38
  - lib/errplane/transmitter.rb
39
39
  - lib/errplane/version.rb
@@ -1,21 +0,0 @@
1
- module Errplane
2
- class Deployment
3
- def announce
4
- http = Net::HTTP.new(Errplane.configuration.api_host, "80")
5
- url = "/api/v1/deployments"
6
- data = {}
7
- response = begin
8
- http.post(url, data)
9
- rescue Exception => e
10
- # e
11
- end
12
-
13
- case response
14
- when Net::HTTPSuccess
15
- # Success
16
- else
17
- # Failure
18
- end
19
- end
20
- end
21
- end