govuk_app_config 0.3.0 → 1.0.0

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: 4791548002b6883ab4483008296f2df6a8151865
4
- data.tar.gz: 1dcbcb6a7e6790cb555ca4f776266667a94183aa
3
+ metadata.gz: 7c1aa04a3723ed9121a0a5396efcde54f888c923
4
+ data.tar.gz: 6d8e1e534ed8f3969ac2aa9f59ea575572d45ae7
5
5
  SHA512:
6
- metadata.gz: 8ebacb7a67fa6da41352fce27f2331b5ecf26244bf0a14525d4de17d478282a4b3a73f72b54bc1a308064ef0abbf57967640a6c5748cda254f7de9b899606d63
7
- data.tar.gz: dfe3d0ff930dbe2e2073e3fed0d925635f00d1002410d7385d05b4c02552b5a1e52baae6c5719fab2d3a485fe38efed16d805772c05726a5819aee368d47ad5d
6
+ metadata.gz: 171cf7e15d152cbc6675be11cdd076f3e741588a9d6459455c4fddab83e00d76d754fa04630944fd39dbeb2962f94dbb4ce75fa6ecfd5aa7a561c179ad1eddd7
7
+ data.tar.gz: 95b2fe9fe50983cb1c687d52b1b2d7c98d303e0a6e0708b2753106739eb3619e28520b5d2c7b90cc40b48c78f0d1bd32fa42c113daac47ca0b4c6598bc99071a
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.4.2
@@ -1,4 +1,17 @@
1
- # Changelog
1
+ # 1.0.0
2
+
3
+ * Add Unicorn (our web server) as a dependency
4
+ * Use version [2.7.0 of the Sentry client][sentry-270].
5
+ * Set up logging configuration for Rails applications.
6
+ * Don't send `ActionController::BadRequest`
 to Sentry
7
+
8
+ [sentry-270]: https://github.com/getsentry/raven-ruby/commit/ef623824cb0a8a2f60be5fb7e12f80454da54fd7
9
+
10
+ ### How to upgrade
11
+
12
+ * Remove `gem 'unicorn'` from your Gemfile
13
+ * Remove `gem 'logstasher'` from your Gemfile
14
+ * Remove all `config.logstasher.*` configs from `config/production.rb`
2
15
 
3
16
  ## 0.3.0
4
17
 
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # GOV.UK Config
2
2
 
3
+ Adds the basics of a GOV.UK application:
4
+
5
+ - Unicorn as a web server
6
+ - Error reporting with Sentry
7
+ - Statsd client for reporting stats
8
+
3
9
  ## Installation
4
10
 
5
11
  Add this line to your application's Gemfile:
@@ -14,6 +20,12 @@ And then execute:
14
20
 
15
21
  ## Usage
16
22
 
23
+ ## Unicorn
24
+
25
+ No configuration required.
26
+
27
+ ## Error reporting
28
+
17
29
  ### Automatic error reporting
18
30
 
19
31
  If you include `govuk_app_config` in your `Gemfile`, Rails' autoloading mechanism will make sure that your application is configured to send errors to Sentry.
@@ -22,7 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_dependency "statsd-ruby", "~> 1.4.0"
25
- spec.add_dependency "sentry-raven", "~> 2.6.3"
25
+ spec.add_dependency "logstasher", "~> 1.2.2"
26
+ spec.add_dependency "sentry-raven", "~> 2.7.1"
27
+ spec.add_dependency "unicorn", "~> 5.3.1"
26
28
 
27
29
  spec.add_development_dependency "bundler", "~> 1.15"
28
30
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,4 +1,6 @@
1
1
  require "govuk_app_config/version"
2
2
  require "govuk_app_config/govuk_statsd"
3
3
  require "govuk_app_config/govuk_error"
4
+ require "govuk_app_config/govuk_logging"
4
5
  require "govuk_app_config/configure"
6
+ require "govuk_app_config/railtie" if defined?(Rails)
@@ -3,9 +3,6 @@ if defined?(Airbrake)
3
3
  end
4
4
 
5
5
  GovukError.configure do |config|
6
- # We need this until https://github.com/getsentry/raven-ruby/pull/736 is released
7
- config.current_environment = ENV["SENTRY_CURRENT_ENV"]
8
-
9
6
  # We're misusing the `should_capture` block here to hook into raven until
10
7
  # there's a better way: https://github.com/getsentry/raven-ruby/pull/750
11
8
  config.should_capture = Proc.new {
@@ -18,6 +15,19 @@ GovukError.configure do |config|
18
15
  true
19
16
  }
20
17
 
18
+ config.excluded_exceptions = [
19
+ 'AbstractController::ActionNotFound',
20
+ 'ActionController::BadRequest',
21
+ 'ActionController::InvalidAuthenticityToken',
22
+ 'ActionController::RoutingError',
23
+ 'ActionController::UnknownAction',
24
+ 'ActiveJob::DeserializationError',
25
+ 'ActiveRecord::RecordNotFound',
26
+ 'CGI::Session::CookieStore::TamperedWithCookie',
27
+ 'Mongoid::Errors::DocumentNotFound',
28
+ 'Sinatra::NotFound',
29
+ ]
30
+
21
31
  config.transport_failure_callback = Proc.new {
22
32
  GovukStatsd.increment("error_reports_failed")
23
33
  }
@@ -0,0 +1,52 @@
1
+ # Rails applications have 2 outputs types:
2
+ #
3
+ # 1) Structured logging statements like the ones we create with
4
+ # `Rails.logger.info` and Rails request logging, which we do with the logstasher
5
+ # gem. These logs are output in JSON and can be read easily by our logging
6
+ # stack.
7
+ #
8
+ # 2) The second are logs that are outputted when an exception occurs or `puts`
9
+ # is used directly. This is unstructured text. Often this logging is sent to
10
+ # STDOUT directly.
11
+ #
12
+ # We want to differentiate between the two types. To do this, we direct all log
13
+ # statements that would _normally_ go to STDOUT to STDERR. This frees up the "real
14
+ # stdout" for use by our loggers.
15
+ $real_stdout = $stdout.clone
16
+ $stdout.reopen($stderr)
17
+
18
+ require 'logstasher'
19
+
20
+ module GovukLogging
21
+ def self.configure
22
+ # Send Rails' logs to STDERR because they're not JSON formatted.
23
+ Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new($stderr))
24
+
25
+ # Custom that will be added to the Rails request logs
26
+ LogStasher.add_custom_fields do |fields|
27
+ # Mirrors Nginx request logging, e.g GET /path/here HTTP/1.1
28
+ fields[:request] = "#{request.request_method} #{request.fullpath} #{request.headers["SERVER_PROTOCOL"]}"
29
+
30
+ # Pass request Id to logging
31
+ fields[:govuk_request_id] = request.headers["GOVUK-Request-Id"]
32
+
33
+ fields[:varnish_id] = request.headers["X-Varnish"]
34
+
35
+ fields[:govuk_app_config] = GovukAppConfig::VERSION
36
+ end
37
+
38
+ Rails.application.config.logstasher.enabled = true
39
+
40
+ # Log controller actions so that we can graph response times
41
+ Rails.application.config.logstasher.controller_enabled = true
42
+
43
+ # The other loggers are not that interesting in production
44
+ Rails.application.config.logstasher.mailer_enabled = false
45
+ Rails.application.config.logstasher.record_enabled = false
46
+ Rails.application.config.logstasher.view_enabled = false
47
+ Rails.application.config.logstasher.job_enabled = false
48
+
49
+ Rails.application.config.logstasher.logger = Logger.new($real_stdout)
50
+ Rails.application.config.logstasher.supress_app_log = true
51
+ end
52
+ end
@@ -0,0 +1,7 @@
1
+ module GovukAppConfig
2
+ class Railtie < Rails::Railtie
3
+ config.before_initialize do
4
+ GovukLogging.configure if Rails.env.production?
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_app_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-21 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: statsd-ruby
@@ -24,20 +24,48 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: logstasher
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.2
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: sentry-raven
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 2.6.3
47
+ version: 2.7.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: unicorn
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.3.1
34
62
  type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: 2.6.3
68
+ version: 5.3.1
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +158,9 @@ files:
130
158
  - lib/govuk_app_config.rb
131
159
  - lib/govuk_app_config/configure.rb
132
160
  - lib/govuk_app_config/govuk_error.rb
161
+ - lib/govuk_app_config/govuk_logging.rb
133
162
  - lib/govuk_app_config/govuk_statsd.rb
163
+ - lib/govuk_app_config/railtie.rb
134
164
  - lib/govuk_app_config/version.rb
135
165
  homepage: https://github.com/alphagov/govuk_app_config
136
166
  licenses:
@@ -152,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
182
  version: '0'
153
183
  requirements: []
154
184
  rubyforge_project:
155
- rubygems_version: 2.6.8
185
+ rubygems_version: 2.6.13
156
186
  signing_key:
157
187
  specification_version: 4
158
188
  summary: Base configuration for GOV.UK applications