google-cloud-trace 0.40.0 → 0.41.0

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: b07562091331ce0fc0545ba69eb4dd28c878416fd1db5f3a6f0134b2070b548b
4
- data.tar.gz: 2274912890a1bb15293e2121c3ce4e1e694a430919c0290624cf929683522895
3
+ metadata.gz: 8d80aa4d6a48ec1f93a09807e5fb1625deb0697515eb9835026f31e62df940bb
4
+ data.tar.gz: bfe0c8868cbc08c22db777e89f6d0adb76b27e85556a25e4b953d5b91224986d
5
5
  SHA512:
6
- metadata.gz: 42f181e09853565ae566548c08dfc69f88c727cfbec9b77663c21889d8c6ded86eff582471c31cceba816d47f0ba6f326773408c7ec87671949bf137c1d2f470
7
- data.tar.gz: 706749ea6b9625ea23243e16540666d8e4e1855ceb832f45c7dfd7069cde78b9fbab5f76ec9846ed598e7bda3468224172271db7c77fbe95f91501f3f5944fb4
6
+ metadata.gz: e29839ff82637001a33196a308c28c7d8b0446691a81ef19287d6cf81c81c18434ee861e87374d12ebb42e72396284e743cb79c26fba34be275e66121330549f
7
+ data.tar.gz: 5e9520928f53bf8c734e253579f1f27e36427442efbbaf449fb2c01a2d41a5a15bb4f24e631b9308816671ca68c8eca6e52f5fccf7862442ca5311e0b91aafdd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 0.41.0 / 2021-03-11
4
+
5
+ #### Features
6
+
7
+ * Drop support for Ruby 2.4 and add support for Ruby 3.0
8
+
3
9
  ### 0.40.0 / 2020-07-23
4
10
 
5
11
  This is a major update that removes the "low-level" client interface code, and
data/CONTRIBUTING.md CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
24
24
  In order to use the google-cloud-trace console and run the project's tests,
25
25
  there is a small amount of setup:
26
26
 
27
- 1. Install Ruby. google-cloud-trace requires Ruby 2.4+. You may choose to
27
+ 1. Install Ruby. google-cloud-trace requires Ruby 2.5+. You may choose to
28
28
  manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
29
  [rbenv](https://github.com/rbenv/rbenv), or
30
30
  [chruby](https://github.com/postmodern/chruby).
@@ -45,7 +45,7 @@ there is a small amount of setup:
45
45
 
46
46
  ```sh
47
47
  $ cd google-cloud-trace/
48
- $ bundle exec rake bundleupdate
48
+ $ bundle install
49
49
  ```
50
50
 
51
51
  ## Console
data/LOGGING.md CHANGED
@@ -3,7 +3,7 @@
3
3
  To enable logging for this library, set the logger for the underlying
4
4
  [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
5
5
  that you set may be a Ruby stdlib
6
- [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
6
+ [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as
7
7
  shown below, or a
8
8
  [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
9
9
  that will write logs to [Stackdriver
@@ -36,7 +36,7 @@ module Google
36
36
 
37
37
  ##
38
38
  # @private Creates a new AsyncReporter instance.
39
- def initialize service, max_count: 1000, max_bytes: 4000000,
39
+ def initialize service, max_count: 1000, max_bytes: 4_000_000,
40
40
  max_queue: 100, interval: 5, threads: 10
41
41
  # init MonitorMixin
42
42
  super()
@@ -111,7 +111,7 @@ module Google
111
111
  @stopped = true
112
112
  patch_batch!
113
113
  @cond.broadcast
114
- @thread_pool.shutdown if @thread_pool
114
+ @thread_pool&.shutdown
115
115
  end
116
116
 
117
117
  self
@@ -219,7 +219,7 @@ module Google
219
219
  @cond.wait
220
220
  else
221
221
  # still waiting for the interval to publish the batch...
222
- @cond.wait(@batch.publish_wait)
222
+ @cond.wait @batch.publish_wait
223
223
  end
224
224
  end
225
225
  end
@@ -295,7 +295,8 @@ module Google
295
295
  ##
296
296
  # @private
297
297
  class Batch
298
- attr_reader :created_at, :traces
298
+ attr_reader :created_at
299
+ attr_reader :traces
299
300
 
300
301
  def initialize reporter
301
302
  @reporter = reporter
@@ -337,7 +338,7 @@ module Google
337
338
 
338
339
  def publish_wait
339
340
  publish_wait = publish_at - Time.now
340
- return 0 if publish_wait < 0
341
+ return 0 if publish_wait.negative?
341
342
  publish_wait
342
343
  end
343
344
 
@@ -32,7 +32,7 @@ module Google
32
32
  attr_reader :traces
33
33
 
34
34
  def initialize message, traces = nil
35
- super(message)
35
+ super message
36
36
  @traces = traces if traces
37
37
  end
38
38
  end
@@ -50,7 +50,7 @@ module Google
50
50
  attr_reader :traces
51
51
 
52
52
  def initialize message, traces = nil
53
- super(message)
53
+ super message
54
54
  @traces = traces if traces
55
55
  end
56
56
  end
@@ -39,10 +39,9 @@ module Google
39
39
  # faraday.adapter Faraday.default_adapter # use Net::HTTP adapter
40
40
  # end
41
41
  # ```
42
-
43
- def initialize app, enable_cross_project_tracing: false
44
- super(app)
45
- @enable_cross_project_tracing = enable_cross_project_tracing || false
42
+ def initialize app, opts = {}
43
+ @enable_cross_project_tracing = opts[:enable_cross_project_tracing] || false
44
+ super app
46
45
  end
47
46
 
48
47
  ##
@@ -114,9 +113,8 @@ module Google
114
113
  ##
115
114
  # @private Add X-Cloud-Trace-Context for request header
116
115
  def add_trace_context_header env
117
- if (trace_ctx = Stackdriver::Core::TraceContext.get)
118
- env[:request_headers]["X-Cloud-Trace-Context"] = trace_ctx.to_string
119
- end
116
+ trace_ctx = Stackdriver::Core::TraceContext.get
117
+ env[:request_headers]["X-Cloud-Trace-Context"] = trace_ctx.to_string if trace_ctx
120
118
  end
121
119
  end
122
120
  end
@@ -118,7 +118,7 @@ module Google
118
118
  json_frames = []
119
119
  collecting_frames = !truncate_stack
120
120
  stack_frames.each do |frame|
121
- collecting_frames ||= truncate_stack.call(frame)
121
+ collecting_frames ||= truncate_stack.call frame
122
122
  next unless collecting_frames
123
123
  next unless !filter_stack || filter_stack.call(frame)
124
124
  json_frames <<
@@ -154,7 +154,7 @@ module Google
154
154
  def initialize app, service: nil, **kwargs
155
155
  @app = app
156
156
 
157
- load_config kwargs
157
+ load_config(**kwargs)
158
158
 
159
159
  if service
160
160
  @service = service
@@ -203,7 +203,7 @@ module Google
203
203
  # @return [Stackdriver::Core::TraceContext] The trace context.
204
204
  #
205
205
  def get_trace_context env
206
- Stackdriver::Core::TraceContext.parse_rack_env(env) do |tc|
206
+ Stackdriver::Core::TraceContext.parse_rack_env env do |tc|
207
207
  if tc.sampled?.nil?
208
208
  sampler = configuration.sampler ||
209
209
  Google::Cloud::Trace::TimeSampler.default
@@ -240,12 +240,11 @@ module Google
240
240
  # @param [Hash] env The Rack environment.
241
241
  #
242
242
  def send_trace trace, env
243
- if @service && trace.trace_context.sampled?
244
- begin
245
- @service.patch_traces trace
246
- rescue StandardError => ex
247
- handle_error ex, logger: env["rack.logger"]
248
- end
243
+ return unless @service && trace.trace_context.sampled?
244
+ begin
245
+ @service.patch_traces trace
246
+ rescue StandardError => e
247
+ handle_error e, logger: env["rack.logger"]
249
248
  end
250
249
  end
251
250
 
@@ -71,7 +71,7 @@ module Google
71
71
  label_namespace: DEFAULT_LABEL_NAMESPACE,
72
72
  capture_stack: false
73
73
  require "active_support/notifications"
74
- ActiveSupport::Notifications.subscribe(type) do |*args|
74
+ ActiveSupport::Notifications.subscribe type do |*args|
75
75
  event = ActiveSupport::Notifications::Event.new(*args)
76
76
  handle_notification_event event, max_length, label_namespace,
77
77
  capture_stack
@@ -83,19 +83,18 @@ module Google
83
83
  def self.handle_notification_event event, maxlen, label_namespace,
84
84
  capture_stack
85
85
  cur_span = Google::Cloud::Trace.get
86
- if cur_span && event.time && event.end
87
- labels = payload_to_labels event, maxlen, label_namespace
88
- if capture_stack
89
- Google::Cloud::Trace::LabelKey.set_stack_trace \
90
- labels,
91
- skip_frames: 2,
92
- truncate_stack: REMOVE_NOTIFICATION_FRAMEWORK
93
- end
94
- cur_span.create_span event.name,
95
- start_time: event.time,
96
- end_time: event.end,
97
- labels: labels
86
+ return unless cur_span && event.time && event.end
87
+ labels = payload_to_labels event, maxlen, label_namespace
88
+ if capture_stack
89
+ Google::Cloud::Trace::LabelKey.set_stack_trace \
90
+ labels,
91
+ skip_frames: 2,
92
+ truncate_stack: REMOVE_NOTIFICATION_FRAMEWORK
98
93
  end
94
+ cur_span.create_span event.name,
95
+ start_time: event.time,
96
+ end_time: event.end,
97
+ labels: labels
99
98
  end
100
99
 
101
100
  ##
@@ -104,7 +103,7 @@ module Google
104
103
  labels = {}
105
104
  event.payload.each do |k, v|
106
105
  if v.is_a? ::String
107
- v = v[0, maxlen - 3] + "..." if maxlen && v.size > maxlen
106
+ v = "#{v[0, maxlen - 3]}..." if maxlen && v.size > maxlen
108
107
  labels["#{label_namespace}#{k}"] = v.to_s
109
108
  end
110
109
  end
@@ -41,5 +41,5 @@ module GRPC
41
41
  end
42
42
 
43
43
  # Patch GRPC::ActiveCall#request_response method
44
- ::GRPC::ActiveCall.send(:prepend, ActiveCallWithTrace)
44
+ ::GRPC::ActiveCall.prepend ActiveCallWithTrace
45
45
  end
@@ -84,6 +84,6 @@ module GRPC
84
84
  end
85
85
 
86
86
  # Patch GRPC::Core::Call#run_batch method
87
- ::GRPC::Core::Call.send(:prepend, CallWithTrace)
87
+ ::GRPC::Core::Call.prepend CallWithTrace
88
88
  end
89
89
  end
@@ -191,13 +191,13 @@ module Google
191
191
  Trace::Credentials.new credentials
192
192
  end
193
193
  rescue Exception => e
194
- STDOUT.puts "Note: Google::Cloud::Trace is disabled because " \
194
+ $stdout.puts "Note: Google::Cloud::Trace is disabled because " \
195
195
  "it failed to authorize with the service. (#{e.message})"
196
196
  return false
197
197
  end
198
198
 
199
199
  if project_id.to_s.empty?
200
- STDOUT.puts "Note: Google::Cloud::Trace is disabled because " \
200
+ $stdout.puts "Note: Google::Cloud::Trace is disabled because " \
201
201
  "the project ID could not be determined."
202
202
  return false
203
203
  end
@@ -27,7 +27,10 @@ module Google
27
27
  # @private
28
28
  #
29
29
  class Service
30
- attr_accessor :project, :credentials, :timeout, :host
30
+ attr_accessor :project
31
+ attr_accessor :credentials
32
+ attr_accessor :timeout
33
+ attr_accessor :host
31
34
 
32
35
  ##
33
36
  # Creates a new Service instance.
@@ -323,7 +323,7 @@ module Google
323
323
  ensure_exists!
324
324
  unless start_time
325
325
  self.start_time = ::Time.now.utc
326
- parent.ensure_started if parent
326
+ parent&.ensure_started
327
327
  end
328
328
  self
329
329
  end
@@ -350,8 +350,8 @@ module Google
350
350
  def delete
351
351
  ensure_exists!
352
352
  @children.each(&:delete)
353
- parent.remove_child(self) if parent
354
- trace.remove_span(self)
353
+ parent&.remove_child self
354
+ trace.remove_span self
355
355
  @trace = nil
356
356
  @parent = nil
357
357
  self
@@ -428,7 +428,7 @@ module Google
428
428
  def ensure_no_cycle! new_parent
429
429
  ptr = new_parent
430
430
  until ptr.nil?
431
- raise "Move would result in a cycle" if ptr.equal?(self)
431
+ raise "Move would result in a cycle" if ptr.equal? self
432
432
  ptr = ptr.parent
433
433
  end
434
434
  end
@@ -56,8 +56,7 @@ module Google
56
56
  @trace_context = trace_context || Stackdriver::Core::TraceContext.new
57
57
  @root_spans = []
58
58
  @spans_by_id = {}
59
- @span_id_generator =
60
- span_id_generator || ::Proc.new { rand(1..0xffffffffffffffff) }
59
+ @span_id_generator = span_id_generator || proc { rand(1..0xffffffffffffffff) }
61
60
  end
62
61
 
63
62
  ##
@@ -32,7 +32,7 @@ module Google
32
32
 
33
33
  # sometimes this gets called with time as a float or
34
34
  # int. Coerce into a time object, and move on.
35
- time = Time.at(time) if time.is_a? Numeric
35
+ time = Time.at time if time.is_a? Numeric
36
36
 
37
37
  raise ArgumentError unless time.is_a? Time
38
38
 
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Trace
19
- VERSION = "0.40.0".freeze
19
+ VERSION = "0.41.0".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-trace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.40.0
4
+ version: 0.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.24.0
89
+ version: 1.25.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.24.0
96
+ version: 1.25.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: minitest
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '0.8'
173
+ version: '1.3'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '0.8'
180
+ version: '1.3'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: railties
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -312,14 +312,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
312
312
  requirements:
313
313
  - - ">="
314
314
  - !ruby/object:Gem::Version
315
- version: '2.4'
315
+ version: '2.5'
316
316
  required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  requirements:
318
318
  - - ">="
319
319
  - !ruby/object:Gem::Version
320
320
  version: '0'
321
321
  requirements: []
322
- rubygems_version: 3.1.3
322
+ rubygems_version: 3.2.13
323
323
  signing_key:
324
324
  specification_version: 4
325
325
  summary: Application Instrumentation and API Client library for Stackdriver Trace