google-cloud-error_reporting 0.32.0 → 0.32.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96a8b2ba7e135e4e92d2214792fa1e984be8e651f9b807369e8b4b6ba85288cf
4
- data.tar.gz: c5a07ee5288fe0914460c57b21b25c7c21505d6569a03da05752ac14389c8556
3
+ metadata.gz: c9979f9f2835f10dddb6e0176470af18c3365f327c08b738986327efffab2408
4
+ data.tar.gz: 68c69be359657054041e9c8a81948c16750245a9ecc211679f610eab74931004
5
5
  SHA512:
6
- metadata.gz: ea52d976179d1cf59e0f7b5a601cf0c5a760ec2596ddf966a18ac678913dfca9a5ec16e83fe0a5998c6bb14ef5d1d4a8e6d9b8cec5f5db2a70a7d3ded4b2ab49
7
- data.tar.gz: 91ab3a7c056f6bf1157e4d495bd8e985601571bf131e274627ad94d2fd2a2818a44633bc43b5a5ca1e66ed0eeaa42383353019d0200bed443d8310d6036f3916
6
+ metadata.gz: ae9b9ea77ab3cf2119c798d82cdf3060903fa2bff1797d112c33e1e3dadda94143e580cfa644aca7ee44e707633300df58d38daa72386320799120d90f196967
7
+ data.tar.gz: a89bb5a4d117fc776db3f55d12b0f127bd8742ad4b82414a8f4ff1c6dd269dfcd7dff2494fbea8b9a70f2f2ca127cea2b66d1a3230a7d637c6160d2676b38881
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 0.32.1 / 2019-10-10
4
+
5
+ #### Bug Fixes
6
+
7
+ * The ErrorReporting middleware reuses the existing default reporter instead of creating new ones every time
8
+
3
9
  ### 0.32.0 / 2019-08-23
4
10
 
5
11
  #### Features
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ require "monitor"
16
17
  require "google-cloud-error_reporting"
17
18
  require "google/cloud/error_reporting/async_error_reporter"
18
19
  require "google/cloud/error_reporting/project"
@@ -35,7 +36,8 @@ module Google
35
36
  ##
36
37
  # @private The default Google::Cloud::ErrorReporting::Project client used
37
38
  # for the Google::Cloud::ErrorReporting.report API.
38
- @@default_client = nil
39
+ @default_reporter = nil
40
+ @default_reporter_mutex = Monitor.new
39
41
 
40
42
  ##
41
43
  # Creates a new object for connecting to the Stackdriver Error Reporting
@@ -224,7 +226,7 @@ module Google
224
226
 
225
227
  yield error_event if block_given?
226
228
 
227
- default_client.report error_event
229
+ default_reporter.report error_event
228
230
  end
229
231
 
230
232
  ##
@@ -253,22 +255,32 @@ module Google
253
255
  private_class_method :resolve_project_id
254
256
 
255
257
  ##
256
- # @private Create a private client to
257
- def self.default_client
258
- unless @@default_client
259
- project_id = Project.default_project_id
260
- credentials = default_credentials
261
-
262
- @@default_client = AsyncErrorReporter.new(
263
- new(project_id: project_id, credentials: credentials)
264
- )
258
+ # Returns the global default reporter used by middleware and the
259
+ # {Google::Cloud::ErrorReporting.report} convenience method.
260
+ #
261
+ # If the default reporter is already defined, returns it. Otherwise, if
262
+ # a block is given, it is called and the result is set as the default
263
+ # reporter. Otherwise, if no block is given, a reporter is constructed
264
+ # from the default project and credentials.
265
+ #
266
+ # @return [#report]
267
+ #
268
+ def self.default_reporter &block
269
+ @default_reporter_mutex.synchronize do
270
+ @default_reporter ||=
271
+ if block
272
+ block.call
273
+ else
274
+ project_id = Project.default_project_id
275
+ credentials = default_credentials
276
+ AsyncErrorReporter.new(
277
+ new(project_id: project_id, credentials: credentials)
278
+ )
279
+ end
265
280
  end
266
-
267
- @@default_client
281
+ @default_reporter
268
282
  end
269
283
 
270
- private_class_method :default_client
271
-
272
284
  ##
273
285
  # @private Default credentials.
274
286
  def self.default_credentials scope: nil
@@ -54,14 +54,12 @@ module Google
54
54
 
55
55
  @error_reporting =
56
56
  error_reporting ||
57
- ErrorReporting::AsyncErrorReporter.new(
58
- ErrorReporting.new(project: configuration.project_id,
59
- credentials: configuration.credentials)
60
- )
61
-
62
- # Set module default client to reuse the same client. Update module
63
- # configuration parameters.
64
- ErrorReporting.class_variable_set :@@default_client, @error_reporting
57
+ ErrorReporting.default_reporter do
58
+ ErrorReporting::AsyncErrorReporter.new(
59
+ ErrorReporting.new(project: configuration.project_id,
60
+ credentials: configuration.credentials)
61
+ )
62
+ end
65
63
  end
66
64
 
67
65
  ##
@@ -88,11 +88,13 @@ module Google
88
88
  # 01:30 UTC on January 15, 2017.
89
89
  #
90
90
  # In JavaScript, one can convert a Date object to this format using the
91
- # standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
91
+ # standard
92
+ # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
92
93
  # method. In Python, a standard `datetime.datetime` object can be converted
93
- # to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
94
- # with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
95
- # can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
94
+ # to this format using
95
+ # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
96
+ # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
97
+ # the Joda Time's [`ISODateTimeFormat.dateTime()`](
96
98
  # http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
97
99
  # ) to obtain a formatter capable of generating timestamps in this format.
98
100
  # @!attribute [rw] seconds
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module ErrorReporting
19
- VERSION = "0.32.0".freeze
19
+ VERSION = "0.32.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.32.0
4
+ version: 0.32.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: 2019-08-23 00:00:00.000000000 Z
11
+ date: 2019-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core