crashbreak 1.0.16 → 1.0.17

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: 090bcc725aec72a06594ff7adc7c3020c8e012bb
4
- data.tar.gz: a08df3d75839a074aa6010089b8f10fc5136a385
3
+ metadata.gz: 6f81541b60fa10233bdb23fb8ca9cecfb9153663
4
+ data.tar.gz: 1381e17f9d594f74445b60c382900a9ba9adfb6b
5
5
  SHA512:
6
- metadata.gz: 1a83cafd9c89d262e5d2ddfad9df7df6d0a49012cb985d07bffdadcfc0ede6d2837027a32ebef0ffc548e3e1a94444792aafeb9f37e3048bd833d72769a67e8a
7
- data.tar.gz: f28fdeebfd0d8f5bed1a5c79a3d8c824c34b2f4b7804dc9dd13a394744cc1bb1258597f31cc254da8b34081be5fc81f8b6d223d8756009004f3701fe0c0f4c2f
6
+ metadata.gz: 71eda490487fe43bbd242a0212bf8b3e9aea8f00ae33927b0b1419b857aa4abb57f1702d6a3233ef947e3ace25f0a2ec1370d72311fc06feb3362fe6ca934f2d
7
+ data.tar.gz: 9b24c12fbf2fe0403e82dbbc07fe7d2d3ea9257f11746767ed46588c65944fd78d9728a6f3f11e309dd68fbec6d7eee208781cd551e53429274a90d62a1ab89f
data/README.md CHANGED
@@ -1,28 +1,135 @@
1
1
  # Crashbreak [![Version](http://img.shields.io/gem/v/crashbreak.svg) ](https://rubygems.org/gems/crashbreak) [![Build Status](https://travis-ci.org/crashbreak/crashbreak.svg?branch=master)](https://travis-ci.org/crashbreak/crashbreak) [![Code Climate](https://codeclimate.com/github/crashbreak/crashbreak/badges/gpa.svg)](https://codeclimate.com/github/crashbreak/crashbreak)
2
2
 
3
- TODO: Write a gem description
3
+ Crashbreak gem is a exception notifier for integration with [crashbreak.com](http://crashbreak.com) for ruby apllications.
4
4
 
5
- ## Installation
5
+ ## Rails Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  gem 'crashbreak'
10
10
 
11
- And then execute:
11
+ And then execute from your rails root:
12
12
 
13
13
  $ bundle
14
14
 
15
- Or install it yourself as:
15
+ Generate crashbreak initializer:
16
16
 
17
- $ gem install crashbreak
17
+ rails generate crashbreak:install your_api_key
18
18
 
19
- ## Usage
19
+ ## Example crashbreak.rb (initializer)
20
+ [Rails example](https://github.com/crashbreak/heroku-rails-example/blob/master/config/initializers/crashbreak.rb)
20
21
 
21
- TODO: Write usage instructions here
22
+ [Grape example](https://github.com/crashbreak/grape_example/blob/master/crashbreak.rb)
23
+
24
+ ## Initializer options
25
+
26
+ ### Error Serializers
27
+ Each serializer converts an exception to JSON request, by customizing this you can create your own exception page in crashbreak.com. There are two types of serializers - summary serializer and hash serializer.
28
+
29
+ #### Summary serializer
30
+ Summary serializer specify the first tab on exception show view and data included in email. This is an example of default summary formatter:
31
+
32
+ ```ruby
33
+ class DefaultSummaryFormatter < SummaryFormatter
34
+ def summary
35
+ {
36
+ action: request.env['PATH_INFO'],
37
+ controller_name: controller.class.to_s,
38
+ file: exception.backtrace[0],
39
+ url: request.env['REQUEST_URI'],
40
+ user_agent: request.env['HTTP_USER_AGENT']
41
+ }
42
+ end
43
+ end
44
+ ```
45
+
46
+ #### Hash serializer
47
+ By using hash serializer you can serialize your custom data into hash and display it in new tab on our web page. For example this is a ```EnvironmentVariablesSerializer```:
48
+
49
+ ```ruby
50
+ class EnvironmentVariablesFormatter < HashFormatter
51
+ hash_name :environment
52
+
53
+ def hash_value
54
+ ENV.to_hash
55
+ end
56
+ end
57
+ ```
58
+ It adds new tab called "Environment" with all ENV variables displayed in "key: value" format.
59
+
60
+ ### Dumpers (and restorers)
61
+ Dumpers are responsible for dump your system and prepare for restore by simulate request test. There are two very important dumpers - request dumper and database dumper. Each dumper is connected to specify restorer (eg ```RequestDumper``` to ```RequestRestorer```) to dump some part of system and restore it in crashbreak test env. This is a part of database dumper:
62
+
63
+ ```ruby
64
+ # Crashbreak::DatabaseDumper
65
+ def dump
66
+ prepare_aws # you need your custom aws bucket
67
+ dump_database
68
+ upload_dump
69
+ remove_locally_dump
70
+
71
+ { file_name: aws_file_name } # only this hash is stored by crashbreak
72
+ end
73
+
74
+ # Crashbreak::DatabaseRestorer
75
+ def restore
76
+ recreate_test_database
77
+ prepare_aws
78
+ download_dump unless dump_already_downloaded
79
+ restore_database
80
+ setup_connection_to_restored_database
81
+ end
82
+ ```
83
+
84
+ ### Exception notifier
85
+ Dumping your system can take some time, in order to improve request response you can use different exception notifier.
86
+
87
+ ```ruby
88
+ config.exception_notifier = Crashbreak::ExceptionNotifier.new # default notifier (one thread)
89
+ config.exception_notifier = Crashbreak::ForkExceptionNotifier.new # creates fork
90
+ ```
91
+
92
+ ## Integrations
93
+
94
+ ### Github
95
+ Crashbreak can automaticaly creates branch with failing request for exception that occurs on your staging / production server. Your part of the job is just pull, run the test and fix the bug!
96
+ ```ruby
97
+ config.github_login = ENV['GITHUB_USER']
98
+ config.github_password = ENV['GITHUB_PASSWORD']
99
+ config.github_repo_name = 'crashbreak/heroku-rails-example'
100
+ ```
101
+
102
+ ### CI sever
103
+ With CI server you can automatically test your fix on external server. If tests succeed just run crashbreak rake task to resolve the error in our system. If you are using the github integration, the rake task can also create a pull request from branch with error to master.
104
+ ```ruby
105
+ after_success:
106
+ - bundle exec rake crashbreak:resolve_error
107
+ ```
108
+
109
+ ### AWS
110
+ Do not send any private / sensitive data to crashbreak, instead of this use your AWS to store it and send us only url or file name. AWS is required for database dumper and restorer.
111
+ ```ruby
112
+ config.dumper_options = {
113
+ aws_bucket_name: 'cb-test-app',
114
+ aws_region: 'us-east-1', # default: ENV['AWS_REGION']
115
+ aws_access_key_id: 'xxx', # default: ENV['AWS_ACCESS_KEY_ID']
116
+ aws_secret_access_key: 'xxx', # default: ENV['AWS_SECRET_ACCESS_KEY']
117
+ }
118
+ ```
119
+
120
+ ## Adapt crashbreak to your system and flow!
121
+ Read more about flow and extensions [here](http://www.crashbreak.com/how_we_use_crashbreak/).
122
+
123
+ Create your own plugin and improve current functionality - [become a collaborator!](http://www.crashbreak.com/extensions#contributing)
124
+
125
+ ### Request store
126
+ Crashbreak uses [request store gem](https://github.com/steveklabnik/request_store) to store data and pass it to serializers and dumpers. By default it stores controller and exception instance and request object but you can add more.
127
+
128
+ #### All crashbreak options can be found [here](https://github.com/crashbreak/crashbreak/blob/master/lib/crashbreak/config/configurator.rb).
22
129
 
23
130
  ## Contributing
24
131
 
25
- 1. Fork it ( https://github.com/[my-github-username]/crashbreak/fork )
132
+ 1. Fork it ( https://github.com/crashbreak/crashbreak/fork )
26
133
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
134
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
135
  4. Push to the branch (`git push origin my-new-feature`)
@@ -29,6 +29,4 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency 'request_store', '>= 0'
30
30
  spec.add_runtime_dependency 'octokit', '>= 0'
31
31
  spec.add_runtime_dependency 'aws-sdk', '~> 2'
32
- spec.add_runtime_dependency 'sidekiq', '>= 0'
33
- spec.add_runtime_dependency 'oj', '>= 0'
34
32
  end
@@ -2,8 +2,6 @@ require 'faraday'
2
2
  require 'request_store'
3
3
  require 'octokit'
4
4
  require 'aws-sdk'
5
- require 'sidekiq'
6
- require 'oj'
7
5
 
8
6
  require 'crashbreak/version'
9
7
  require 'crashbreak/exception_notifier'
@@ -22,7 +20,6 @@ require 'crashbreak/dumpers_data_repository'
22
20
  require 'crashbreak/request_parser'
23
21
  require 'crashbreak/github_integration_service'
24
22
  require 'crashbreak/AWS'
25
- require 'crashbreak/async_exception_notifier'
26
23
  require 'crashbreak/tiny_exception_notifier'
27
24
  require 'crashbreak/fork_exception_notifier'
28
25
  require 'crashbreak/predefined_settings'
@@ -11,7 +11,7 @@ module Crashbreak
11
11
  unless skip_exception?
12
12
  RequestStore.store[:exception] = exception
13
13
  store_variables_from_env env
14
- notify_about_exception
14
+ exception_notifier.notify
15
15
  end
16
16
 
17
17
  raise
@@ -20,33 +20,6 @@ module Crashbreak
20
20
 
21
21
  private
22
22
 
23
- def notify_about_exception
24
- if exception_notifier.respond_to?(:perform_async)
25
- prepare_request_store_for_serialization
26
- exception_notifier.perform_async Oj.dump(RequestStore.store)
27
- else
28
- exception_notifier.notify
29
- end
30
- end
31
-
32
- def prepare_request_store_for_serialization
33
- request_hash = {}
34
-
35
- RequestStore.store[:request].env.each do |key, value|
36
- request_hash[key] = value.to_s
37
- end
38
-
39
- RequestStore.store[:request] = request(request_hash)
40
-
41
- controller = RequestStore.store[:controller].dup
42
-
43
- [:@_env, :@_request, :@_response, :@_lookup_context].each do |variable_symbol|
44
- controller.instance_variable_set(variable_symbol, nil)
45
- end
46
-
47
- RequestStore.store[:controller] = controller
48
- end
49
-
50
23
  def exception_notifier
51
24
  Crashbreak.configure.exception_notifier
52
25
  end
@@ -1,3 +1,3 @@
1
1
  module Crashbreak
2
- VERSION = '1.0.16'
2
+ VERSION = '1.0.17'
3
3
  end
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe 'error id: <%= error_id %>', type: :request do
2
4
 
3
5
  let(:restorers_data) { Crashbreak::StateRestorer.new('<%= error_id %>').restore }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crashbreak
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Janeczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-22 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -178,34 +178,6 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '2'
181
- - !ruby/object:Gem::Dependency
182
- name: sidekiq
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :runtime
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: oj
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :runtime
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
181
  description: Maybe later... :)
210
182
  email:
211
183
  - michal.janeczek@ymail.com
@@ -224,7 +196,6 @@ files:
224
196
  - crashbreak.gemspec
225
197
  - lib/crashbreak.rb
226
198
  - lib/crashbreak/AWS.rb
227
- - lib/crashbreak/async_exception_notifier.rb
228
199
  - lib/crashbreak/config/configurable.rb
229
200
  - lib/crashbreak/config/configurator.rb
230
201
  - lib/crashbreak/deploys_repository.rb
@@ -259,7 +230,6 @@ files:
259
230
  - lib/tasks/crashbreak.rake
260
231
  - spec/dumpers/request_dumper_spec.rb
261
232
  - spec/features/sending_error_report_spec.rb
262
- - spec/lib/async_exception_notifier_spec.rb
263
233
  - spec/lib/config/configurable_spec.rb
264
234
  - spec/lib/config/configurator_spec.rb
265
235
  - spec/lib/deploys_repository_spec.rb
@@ -308,7 +278,6 @@ summary: Take a break from crashes!
308
278
  test_files:
309
279
  - spec/dumpers/request_dumper_spec.rb
310
280
  - spec/features/sending_error_report_spec.rb
311
- - spec/lib/async_exception_notifier_spec.rb
312
281
  - spec/lib/config/configurable_spec.rb
313
282
  - spec/lib/config/configurator_spec.rb
314
283
  - spec/lib/deploys_repository_spec.rb
@@ -1,16 +0,0 @@
1
- module Crashbreak
2
- class AsyncExceptionNotifier
3
- include Sidekiq::Worker
4
-
5
- def perform(request_store_data)
6
- RequestStore.store.merge!(Oj.load(request_store_data))
7
- exception_notifier.notify
8
- end
9
-
10
- private
11
-
12
- def exception_notifier
13
- @exception_notifier ||= ExceptionNotifier.new
14
- end
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- describe Crashbreak::AsyncExceptionNotifier do
2
- subject { described_class.new }
3
- let(:request_data) { Oj.dump(Hash[request: 'request_info', current_user: 'current_user_data']) }
4
-
5
- before(:each) do
6
- expect_any_instance_of(Crashbreak::ExceptionNotifier).to receive(:notify).and_return(true)
7
- end
8
-
9
- it 'calls notify on exception notifier' do
10
- subject.perform(request_data)
11
- end
12
-
13
- it 'sets request_data in RequestStore' do
14
- expect(RequestStore.store[:request]).to eq('request_info')
15
- expect(RequestStore.store[:current_user]).to eq('current_user_data')
16
-
17
- subject.perform(request_data)
18
- end
19
- end