google-cloud-error_reporting 0.30.0 → 0.30.1

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
  SHA256:
3
- metadata.gz: 84b5253d164ae3db6ddc1be54bfa7b9c9ce343a2324137c0c1ab08b3cdc4c66f
4
- data.tar.gz: 64bd74a706fd71fc3f54ceacda2a6c5742f035f41d42c873121d8b8f9a23a90b
3
+ metadata.gz: 4803dd3ca8f339200e8644cff9d6cd1ff614d6938252f9ef482a1fdbfebcacf1
4
+ data.tar.gz: 38de25dcb58db7bfea2070f908c2a1d051ad37aeb2d4a0d2c5cb7a76354022c6
5
5
  SHA512:
6
- metadata.gz: 62a140a092f7b33d38c46ffe1d303b06aa12b3ad6fe2eb7781568d9a11111aba123fda5c481bdc1ae2c2a82692e086b56d1042518b99a05f9830d32e6da678df
7
- data.tar.gz: a3d8cdfc89c1eeb7758da6fa59201dfec377b9a513570eebed212b3f9c088bcb11b3c81fee2481b522e33544faed4c971eade4e9cec276bbea226d704a7f6aee
6
+ metadata.gz: 9831d8f4ec9210ee09540126be7e9043ec9dd40d3c9740c37b11850fac7ed48743da98f213a58d4de3de9e5f33636b060828d6978309c2d7dcb96b025e45ce10
7
+ data.tar.gz: 5653c450fb8c1ef7697f2a2f613d2bb35c280897a338f14044db9aabc38a252f76bb5eb95802c12573c8376e2420380830df84d244f9b86fa5d477de92954712
data/README.md CHANGED
@@ -178,10 +178,39 @@ This library also supports the other authentication methods provided by the
178
178
  `google-cloud-ruby` suite. Instructions and configuration options are covered
179
179
  in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-debugger/guides/authentication).
180
180
 
181
+ ## Enabling Logging
182
+
183
+ To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
184
+
185
+ Configuring a Ruby stdlib logger:
186
+
187
+ ```ruby
188
+ require "logger"
189
+
190
+ module MyLogger
191
+ LOGGER = Logger.new $stderr, level: Logger::WARN
192
+ def logger
193
+ LOGGER
194
+ end
195
+ end
196
+
197
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
198
+ module GRPC
199
+ extend MyLogger
200
+ end
201
+ ```
202
+
181
203
  ## Supported Ruby Versions
182
204
 
183
205
  This library is supported on Ruby 2.0+.
184
206
 
207
+ However, Ruby 2.3 or later is strongly recommended, as earlier releases have
208
+ reached or are nearing end-of-life. After June 1, 2018, Google will provide
209
+ official support only for Ruby versions that are considered current and
210
+ supported by Ruby Core (that is, Ruby versions that are either in normal
211
+ maintenance or in security maintenance).
212
+ See https://www.ruby-lang.org/en/downloads/branches/ for further details.
213
+
185
214
  ## Versioning
186
215
 
187
216
  This library follows [Semantic Versioning](http://semver.org/).
@@ -45,6 +45,39 @@ module Google
45
45
  # [Authentication
46
46
  # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
47
47
  #
48
+ # ## Enabling Logging
49
+ #
50
+ # To enable logging for this library, set the logger for the underlying
51
+ # [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The
52
+ # logger that you set may be a Ruby stdlib
53
+ # [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html)
54
+ # as shown below, or a
55
+ # [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
56
+ # that will write logs to [Stackdriver
57
+ # Logging](https://cloud.google.com/logging/). See
58
+ # [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
59
+ # and the gRPC
60
+ # [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
61
+ # for additional information.
62
+ #
63
+ # Configuring a Ruby stdlib logger:
64
+ #
65
+ # ```ruby
66
+ # require "logger"
67
+ #
68
+ # module MyLogger
69
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
70
+ # def logger
71
+ # LOGGER
72
+ # end
73
+ # end
74
+ #
75
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
76
+ # module GRPC
77
+ # extend MyLogger
78
+ # end
79
+ # ```
80
+ #
48
81
  # ## How to report errors
49
82
  #
50
83
  # You can easily report exceptions from your applications to Stackdriver
@@ -213,12 +213,12 @@ module Google
213
213
  # from the given exception.
214
214
  def self.from_exception exception
215
215
  backtrace = exception.backtrace
216
- message = exception.message
216
+ message = "#{exception.message} (#{exception.class})"
217
217
 
218
- unless backtrace.nil?
218
+ if !backtrace.nil? && !backtrace.empty?
219
219
  error_location = backtrace.first
220
220
 
221
- message = "#{error_location}: #{message} (#{exception.class})\n\t" +
221
+ message = "#{error_location}: #{message}\n\t" +
222
222
  backtrace.drop(1).join("\n\t")
223
223
  file_path, line_number, function_name = error_location.split(":")
224
224
  function_name = function_name.to_s[/`(.*)'/, 1]
@@ -24,6 +24,8 @@ module Google
24
24
  # to Stackdriver Error Reporting.
25
25
  #
26
26
  class Middleware
27
+ EXCEPTION_KEYS = ["sinatra.error", "rack.exception"].freeze
28
+
27
29
  # A Google::Cloud::ErrorReporting::Project client used to report
28
30
  # error events.
29
31
  attr_reader :error_reporting
@@ -76,8 +78,13 @@ module Google
76
78
 
77
79
  # sinatra doesn't always raise the Exception, but it saves it in
78
80
  # env['sinatra.error']
79
- if env["sinatra.error"].is_a? Exception
80
- report_exception env, env["sinatra.error"]
81
+ #
82
+ # some frameworks (i.e. hanami) will save a rendering exception in
83
+ # env['rack.exception']
84
+ EXCEPTION_KEYS.each do |exception_key|
85
+ next unless env[exception_key].is_a? Exception
86
+
87
+ report_exception env, env[exception_key]
81
88
  end
82
89
 
83
90
  response
@@ -109,7 +109,9 @@ module Google
109
109
  gcp_config = rails_config.google_cloud
110
110
  er_config = gcp_config.error_reporting
111
111
 
112
- Cloud.configure.use_error_reporting ||= gcp_config.use_error_reporting
112
+ if Cloud.configure.use_error_reporting.nil?
113
+ Cloud.configure.use_error_reporting = gcp_config.use_error_reporting
114
+ end
113
115
  ErrorReporting.configure do |config|
114
116
  config.project_id ||= config.project
115
117
  config.project_id ||= er_config.project_id || er_config.project
@@ -17,7 +17,7 @@ module Google
17
17
  # rubocop:disable LineLength
18
18
 
19
19
  ##
20
- # # Ruby Client for Stackdriver Error Reporting API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
20
+ # # Ruby Client for Stackdriver Error Reporting API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
21
  #
22
22
  # [Stackdriver Error Reporting API][Product Documentation]:
23
23
  # Stackdriver Error Reporting groups and counts similar errors from cloud
@@ -79,4 +79,4 @@ module Google
79
79
  end
80
80
  end
81
81
  end
82
- end
82
+ end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module ErrorReporting
19
- VERSION = "0.30.0".freeze
19
+ VERSION = "0.30.1".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-error_reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 0.30.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2018-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  version: '0'
254
254
  requirements: []
255
255
  rubyforge_project:
256
- rubygems_version: 2.7.6
256
+ rubygems_version: 2.7.7
257
257
  signing_key:
258
258
  specification_version: 4
259
259
  summary: API Client library for Stackdriver Error Reporting