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 +4 -4
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +2 -2
- data/LOGGING.md +1 -1
- data/lib/google/cloud/trace/async_reporter.rb +6 -5
- data/lib/google/cloud/trace/errors.rb +2 -2
- data/lib/google/cloud/trace/faraday_middleware.rb +5 -7
- data/lib/google/cloud/trace/label_key.rb +1 -1
- data/lib/google/cloud/trace/middleware.rb +7 -8
- data/lib/google/cloud/trace/notifications.rb +13 -14
- data/lib/google/cloud/trace/patches/active_call_with_trace.rb +1 -1
- data/lib/google/cloud/trace/patches/call_with_trace.rb +1 -1
- data/lib/google/cloud/trace/rails.rb +2 -2
- data/lib/google/cloud/trace/service.rb +4 -1
- data/lib/google/cloud/trace/span.rb +4 -4
- data/lib/google/cloud/trace/trace_record.rb +1 -2
- data/lib/google/cloud/trace/utils.rb +1 -1
- data/lib/google/cloud/trace/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d80aa4d6a48ec1f93a09807e5fb1625deb0697515eb9835026f31e62df940bb
|
4
|
+
data.tar.gz: bfe0c8868cbc08c22db777e89f6d0adb76b27e85556a25e4b953d5b91224986d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e29839ff82637001a33196a308c28c7d8b0446691a81ef19287d6cf81c81c18434ee861e87374d12ebb42e72396284e743cb79c26fba34be275e66121330549f
|
7
|
+
data.tar.gz: 5e9520928f53bf8c734e253579f1f27e36427442efbbaf449fb2c01a2d41a5a15bb4f24e631b9308816671ca68c8eca6e52f5fccf7862442ca5311e0b91aafdd
|
data/CHANGELOG.md
CHANGED
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.
|
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
|
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
|
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:
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
-
|
44
|
-
super
|
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
|
-
|
118
|
-
|
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
|
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
|
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
|
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
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
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
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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]
|
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
|
@@ -191,13 +191,13 @@ module Google
|
|
191
191
|
Trace::Credentials.new credentials
|
192
192
|
end
|
193
193
|
rescue Exception => e
|
194
|
-
|
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
|
-
|
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
|
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
|
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
|
354
|
-
trace.remove_span
|
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?
|
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
|
35
|
+
time = Time.at time if time.is_a? Numeric
|
36
36
|
|
37
37
|
raise ArgumentError unless time.is_a? Time
|
38
38
|
|
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.
|
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:
|
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.
|
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.
|
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: '
|
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: '
|
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.
|
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.
|
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
|