google-cloud-logging 1.5.5 → 1.5.6

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: 5cabe641ea9b231603ff1ec5dd90876723acbb111fa200a293fd661ef2cb9c1d
4
- data.tar.gz: 4b828ba6797ba1465a594deca80e4eff19f8d020a1471057b46a521df787a13b
3
+ metadata.gz: 3f0f56c213ee74340b1ad45478f47ccc2dd6679dab718127bfa4e47e5ba63a37
4
+ data.tar.gz: 06d6bf7c11816f05517a7e9b2016d45baebc6dd938c50ab4c4763730481d03c0
5
5
  SHA512:
6
- metadata.gz: dcea1515ca1c9ec282d9db850646bc2279db32c59b6214d84a8656e9605ded07f0213f57f3e4884170fb43b5486110425f890cfff32da30604f6f342f524352a
7
- data.tar.gz: 0f1f1586220415cd0ce7aa654f07dc779a5efebb22fbf79bbac1bea942c49a35dac0d814d7a20a21341fecc411108d467be41a5fd15cfcc99ed5aa08ad3996df
6
+ metadata.gz: 8b14c0195cb3290431e10b9554d31778eecbd2380694adcf2bc6911848c6d6aff7122906960abcd15f6749c3f49c08d61900c80cdf505641275ce837438f2e9f
7
+ data.tar.gz: ecffe6908619f5b2c6d9baa0f5ed785c4ccc129c58f3f5e23c31564b1cb513f28307d3de32c97daa18d74c45c83f89938ec6f6687f2aa30ddd03a26ee01e3e64
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 1.5.6 / 2018-10-03
4
+
5
+ * Use concurrent-ruby and ThreadLocalVar in Logger.
6
+ * Remove Monitor and synchronize blocks.
7
+ * Logger#thread_ids now only returns the current thread.
8
+
3
9
  ### 1.5.5 / 2018-09-20
4
10
 
5
11
  * Make Logger thread-safe.
@@ -14,8 +14,8 @@
14
14
 
15
15
 
16
16
  require "logger"
17
- require "monitor"
18
17
  require "thread"
18
+ require "concurrent"
19
19
 
20
20
  module Google
21
21
  module Cloud
@@ -53,8 +53,6 @@ module Google
53
53
  # logger.info payload
54
54
  #
55
55
  class Logger
56
- include MonitorMixin
57
-
58
56
  ##
59
57
  # A RequestInfo represents data about the request being handled by the
60
58
  # current thread. It is used to configure logs coming from that thread.
@@ -122,12 +120,15 @@ module Google
122
120
  # Stackdriver trace ID is a shared request identifier across all
123
121
  # Stackdriver services.
124
122
  #
123
+ # This method is deprecated and returns a Hash containing only the
124
+ # current Thread ID/trace_id now.
125
+ #
125
126
  # @deprecated Use request_info
126
127
  #
127
128
  def trace_ids
128
- synchronize do
129
- @request_info_map.inject({}) { |r, (k, v)| r[k] = v.trace_id }
130
- end
129
+ current_request_info = request_info
130
+ return {} if current_request_info.nil?
131
+ { current_thread_id => current_request_info.trace_id }
131
132
  end
132
133
 
133
134
  ##
@@ -172,7 +173,7 @@ module Google
172
173
  @resource = resource
173
174
  @labels = labels || {}
174
175
  @level = 0 # DEBUG is the default behavior
175
- @request_info_map = {}
176
+ @request_info_var = Concurrent::ThreadLocalVar.new
176
177
  @closed = false
177
178
  # Unused, but present for API compatibility
178
179
  @formatter = ::Logger::Formatter.new
@@ -182,8 +183,6 @@ module Google
182
183
  # The writer is usually a Project or AsyncWriter.
183
184
  logging = @writer.respond_to?(:logging) ? @writer.logging : @writer
184
185
  @project = logging.project if logging.respond_to? :project
185
-
186
- super() # to init MonitorMixin
187
186
  end
188
187
 
189
188
  ##
@@ -461,14 +460,7 @@ module Google
461
460
  def add_request_info info: nil, env: nil, trace_id: nil, log_name: nil
462
461
  info ||= RequestInfo.new trace_id, log_name, env
463
462
 
464
- synchronize do
465
- @request_info_map[current_thread_id] = info
466
-
467
- # Start removing old entries if hash gets too large.
468
- # This should never happen, because middleware should automatically
469
- # remove entries when a request is finished
470
- @request_info_map.shift while @request_info_map.size > 10_000
471
- end
463
+ @request_info_var.value = info
472
464
 
473
465
  info
474
466
  end
@@ -480,7 +472,7 @@ module Google
480
472
  # or `nil` if there is no data set.
481
473
  #
482
474
  def request_info
483
- synchronize { @request_info_map[current_thread_id] }
475
+ @request_info_var.value
484
476
  end
485
477
 
486
478
  ##
@@ -489,7 +481,7 @@ module Google
489
481
  # @return [RequestInfo] The info that's being deleted
490
482
  #
491
483
  def delete_request_info
492
- synchronize { @request_info_map.delete current_thread_id }
484
+ @request_info_var.value = nil
493
485
  end
494
486
 
495
487
  ##
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Logging
19
- VERSION = "1.5.5".freeze
19
+ VERSION = "1.5.6".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-21 00:00:00.000000000 Z
12
+ date: 2018-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: 1.0.2
70
+ - !ruby/object:Gem::Dependency
71
+ name: concurrent-ruby
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: minitest
72
86
  requirement: !ruby/object:Gem::Requirement