google-cloud-trace 0.38.3 → 0.41.2
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/AUTHENTICATION.md +1 -1
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +4 -5
- data/LOGGING.md +1 -1
- data/OVERVIEW.md +1 -2
- data/lib/google-cloud-trace.rb +20 -12
- data/lib/google/cloud/trace.rb +18 -14
- data/lib/google/cloud/trace/async_reporter.rb +7 -6
- data/lib/google/cloud/trace/credentials.rb +2 -2
- 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 +2 -2
- data/lib/google/cloud/trace/patches/call_with_trace.rb +2 -2
- data/lib/google/cloud/trace/rails.rb +2 -2
- data/lib/google/cloud/trace/result_set.rb +20 -12
- data/lib/google/cloud/trace/service.rb +37 -60
- data/lib/google/cloud/trace/span.rb +7 -7
- data/lib/google/cloud/trace/trace_record.rb +4 -5
- data/lib/google/cloud/trace/utils.rb +1 -1
- data/lib/google/cloud/trace/version.rb +1 -1
- metadata +23 -72
- data/lib/google/cloud/trace/v1.rb +0 -16
- data/lib/google/cloud/trace/v1/credentials.rb +0 -39
- data/lib/google/cloud/trace/v1/doc/google/devtools/cloudtrace/v1/trace.rb +0 -253
- data/lib/google/cloud/trace/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/trace/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/trace/v1/trace_service_client.rb +0 -425
- data/lib/google/cloud/trace/v1/trace_service_client_config.json +0 -41
- data/lib/google/cloud/trace/v2.rb +0 -123
- data/lib/google/cloud/trace/v2/credentials.rb +0 -39
- data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/trace.rb +0 -321
- data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/tracing.rb +0 -33
- data/lib/google/cloud/trace/v2/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/trace/v2/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/trace/v2/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/trace/v2/doc/google/protobuf/wrappers.rb +0 -34
- data/lib/google/cloud/trace/v2/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/trace/v2/trace_service_client.rb +0 -412
- data/lib/google/cloud/trace/v2/trace_service_client_config.json +0 -36
- data/lib/google/devtools/cloudtrace/v1/trace_pb.rb +0 -82
- data/lib/google/devtools/cloudtrace/v1/trace_services_pb.rb +0 -58
- data/lib/google/devtools/cloudtrace/v2/trace_pb.rb +0 -132
- data/lib/google/devtools/cloudtrace/v2/tracing_pb.rb +0 -29
- data/lib/google/devtools/cloudtrace/v2/tracing_services_pb.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cd810b8a33959481b67b8a9d33cec11ab24f87530d54f98ebf6ae57fe504077
|
4
|
+
data.tar.gz: '08ae511b4cc58931c5355792dd1ffbec2c46bba190fe30be0aeed0a33ef49d3f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89e5004427d42e9a77d3984949f291ca6a9e874847876a85c9d944a221e6558e49229d8c9b8f1a9516c041c38521c59b609e0d80abf25c00f15085f82c72cae7
|
7
|
+
data.tar.gz: beca6e775429ad2cc818f36e51199e359bd4efabc7e18391fcbaeb4592a20887ff486ce0fa9bb35e5c0445ee338594855845fb42e3c56fce080ebe0c8eef2bef
|
data/AUTHENTICATION.md
CHANGED
@@ -76,7 +76,7 @@ The environment variables that google-cloud-trace checks for project ID are:
|
|
76
76
|
1. `TRACE_PROJECT`
|
77
77
|
2. `GOOGLE_CLOUD_PROJECT`
|
78
78
|
|
79
|
-
The environment variables that google-cloud-trace checks for credentials are configured on {Google::Cloud::Trace::
|
79
|
+
The environment variables that google-cloud-trace checks for credentials are configured on {Google::Cloud::Trace::Credentials}:
|
80
80
|
|
81
81
|
1. `TRACE_CREDENTIALS` - Path to JSON file, or JSON contents
|
82
82
|
2. `TRACE_KEYFILE` - Path to JSON file, or JSON contents
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,54 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 0.41.2 / 2021-06-22
|
4
|
+
|
5
|
+
#### Bug Fixes
|
6
|
+
|
7
|
+
* Error reporting no longer fails due to loading the wrong constant
|
8
|
+
* Fixed a crash in the gRPC patch when no span is present in the current trace
|
9
|
+
|
10
|
+
### 0.41.1 / 2021-06-17
|
11
|
+
|
12
|
+
#### Bug Fixes
|
13
|
+
|
14
|
+
* Fixed Ruby 3 keyword argument error in GRPC::ActiveCallWithTrace patch
|
15
|
+
|
16
|
+
### 0.41.0 / 2021-03-11
|
17
|
+
|
18
|
+
#### Features
|
19
|
+
|
20
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0
|
21
|
+
|
22
|
+
### 0.40.0 / 2020-07-23
|
23
|
+
|
24
|
+
This is a major update that removes the "low-level" client interface code, and
|
25
|
+
instead adds the new gems `google-cloud-trace-v1` and `google-cloud-trace-v2`,
|
26
|
+
as dependencies.
|
27
|
+
The new dependencies are rewritten low-level clients, produced by a next-
|
28
|
+
generation client code generator, with improved performance and stability.
|
29
|
+
|
30
|
+
This change should have no effect on the high-level interface that most users
|
31
|
+
will use. The one exception is that the (mostly undocumented) `client_config`
|
32
|
+
argument, for adjusting low-level parameters such as RPC retry settings on
|
33
|
+
client objects, has been removed. If you need to adjust these parameters, use
|
34
|
+
the configuration interface in low-level clients.
|
35
|
+
|
36
|
+
Substantial changes have been made in the low-level interfaces, however. If you
|
37
|
+
are using the low-level classes under the old `Google::Devtools::Cloudtrace`,
|
38
|
+
`Google::Cloud::Trace::V1`, or `Google::Cloud::Trace::V2` modules, please
|
39
|
+
review the docs for the new low-level gems to see usage changes. In particular:
|
40
|
+
|
41
|
+
* Some classes have been renamed, notably the client class itself.
|
42
|
+
* The client constructor takes a configuration block instead of configuration
|
43
|
+
keyword arguments.
|
44
|
+
* All RPC method arguments are now keyword arguments.
|
45
|
+
|
46
|
+
### 0.39.0 / 2020-07-07
|
47
|
+
|
48
|
+
#### Features
|
49
|
+
|
50
|
+
* Added support for span kind in the low-level V2 API
|
51
|
+
|
3
52
|
### 0.38.3 / 2020-05-28
|
4
53
|
|
5
54
|
#### Documentation
|
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
|
@@ -119,15 +119,14 @@ If you alter an example's title, you may encounter breaking tests.
|
|
119
119
|
### Trace Acceptance Tests
|
120
120
|
|
121
121
|
The Trace acceptance tests interact with the live service API. Follow the
|
122
|
-
instructions in the {file:AUTHENTICATION.md Authentication
|
122
|
+
instructions in the {file:AUTHENTICATION.md Authentication Guide} for enabling
|
123
123
|
the Trace API. Occasionally, some API features may not yet be generally
|
124
124
|
available, making it difficult for some contributors to successfully run the
|
125
125
|
entire acceptance test suite. However, please ensure that you do successfully
|
126
126
|
run acceptance tests for any code areas covered by your pull request.
|
127
127
|
|
128
128
|
To run the acceptance tests, first create and configure a project in the Google
|
129
|
-
Developers Console, as described in the {file:AUTHENTICATION.md Authentication
|
130
|
-
guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
|
129
|
+
Developers Console, as described in the {file:AUTHENTICATION.md Authentication Guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
|
131
130
|
the KEYFILE location on your system.
|
132
131
|
|
133
132
|
Before you can run the Trace acceptance tests, you must first create indexes
|
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
|
data/OVERVIEW.md
CHANGED
@@ -157,5 +157,4 @@ trace_client.patch_traces trace
|
|
157
157
|
## Additional information
|
158
158
|
|
159
159
|
Stackdriver Trace can be configured to be used in Rack applications or to use
|
160
|
-
gRPC's logging. To learn more, see the {file:INSTRUMENTATION.md Instrumentation
|
161
|
-
Guide} and {file:LOGGING.md Logging guide}.
|
160
|
+
gRPC's logging. To learn more, see the {file:INSTRUMENTATION.md Instrumentation Guide} and {file:LOGGING.md Logging guide}.
|
data/lib/google-cloud-trace.rb
CHANGED
@@ -57,10 +57,9 @@ module Google
|
|
57
57
|
# puts "Retrieved trace ID: #{trace.trace_id}"
|
58
58
|
# end
|
59
59
|
#
|
60
|
-
def trace scope: nil, timeout: nil
|
60
|
+
def trace scope: nil, timeout: nil
|
61
61
|
Google::Cloud.trace @project, @keyfile, scope: scope,
|
62
|
-
timeout: (timeout || @timeout)
|
63
|
-
client_config: client_config
|
62
|
+
timeout: (timeout || @timeout)
|
64
63
|
end
|
65
64
|
|
66
65
|
##
|
@@ -99,12 +98,15 @@ module Google
|
|
99
98
|
# puts "Retrieved trace ID: #{trace.trace_id}"
|
100
99
|
# end
|
101
100
|
#
|
102
|
-
def self.trace project_id = nil,
|
103
|
-
|
101
|
+
def self.trace project_id = nil,
|
102
|
+
credentials = nil,
|
103
|
+
scope: nil,
|
104
|
+
timeout: nil
|
104
105
|
require "google/cloud/trace"
|
105
|
-
Google::Cloud::Trace.new project_id: project_id,
|
106
|
-
|
107
|
-
|
106
|
+
Google::Cloud::Trace.new project_id: project_id,
|
107
|
+
credentials: credentials,
|
108
|
+
scope: scope,
|
109
|
+
timeout: timeout
|
108
110
|
end
|
109
111
|
end
|
110
112
|
end
|
@@ -127,17 +129,23 @@ Google::Cloud.configure.add_config! :trace do |config|
|
|
127
129
|
"TRACE_KEYFILE", "TRACE_KEYFILE_JSON"
|
128
130
|
)
|
129
131
|
end
|
132
|
+
endpoint = "cloudtrace.googleapis.com".freeze
|
133
|
+
scopes = [
|
134
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
135
|
+
"https://www.googleapis.com/auth/trace.append",
|
136
|
+
"https://www.googleapis.com/auth/trace.readonly"
|
137
|
+
].freeze
|
130
138
|
|
131
139
|
config.add_field! :project_id, default_project, match: String, allow_nil: true
|
132
140
|
config.add_alias! :project, :project_id
|
133
|
-
config.add_field! :credentials,
|
141
|
+
config.add_field! :credentials,
|
142
|
+
default_creds,
|
134
143
|
match: [String, Hash, Google::Auth::Credentials],
|
135
144
|
allow_nil: true
|
136
145
|
config.add_alias! :keyfile, :credentials
|
137
|
-
config.add_field! :scope,
|
146
|
+
config.add_field! :scope, scopes, match: [String, Array]
|
138
147
|
config.add_field! :timeout, nil, match: Integer
|
139
|
-
config.add_field! :
|
140
|
-
config.add_field! :endpoint, nil, match: String
|
148
|
+
config.add_field! :endpoint, endpoint, match: String
|
141
149
|
config.add_field! :capture_stack, nil, enum: [true, false]
|
142
150
|
config.add_field! :sampler, nil
|
143
151
|
config.add_field! :span_id_generator, nil, match: Proc
|
data/lib/google/cloud/trace.rb
CHANGED
@@ -68,8 +68,6 @@ module Google
|
|
68
68
|
# * `https://www.googleapis.com/auth/cloud-platform`
|
69
69
|
#
|
70
70
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
71
|
-
# @param [Hash] client_config A hash of values to override the default
|
72
|
-
# behavior of the API client. Optional.
|
73
71
|
# @param [String] endpoint Override of the endpoint host name. Optional.
|
74
72
|
# If the param is nil, uses the default endpoint.
|
75
73
|
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
@@ -88,12 +86,16 @@ module Google
|
|
88
86
|
# puts "Retrieved trace ID: #{trace.trace_id}"
|
89
87
|
# end
|
90
88
|
#
|
91
|
-
def self.new project_id: nil,
|
92
|
-
|
89
|
+
def self.new project_id: nil,
|
90
|
+
credentials: nil,
|
91
|
+
scope: nil,
|
92
|
+
timeout: nil,
|
93
|
+
endpoint: nil,
|
94
|
+
project: nil,
|
95
|
+
keyfile: nil
|
93
96
|
project_id ||= (project || default_project_id)
|
94
97
|
scope ||= configure.scope
|
95
98
|
timeout ||= configure.timeout
|
96
|
-
client_config ||= configure.client_config
|
97
99
|
endpoint ||= configure.endpoint
|
98
100
|
credentials ||= (keyfile || default_credentials(scope: scope))
|
99
101
|
|
@@ -104,12 +106,8 @@ module Google
|
|
104
106
|
project_id = project_id.to_s # Always cast to a string
|
105
107
|
raise ArgumentError, "project_id is missing" if project_id.empty?
|
106
108
|
|
107
|
-
Trace::
|
108
|
-
|
109
|
-
project_id, credentials,
|
110
|
-
host: endpoint, timeout: timeout, client_config: client_config
|
111
|
-
)
|
112
|
-
)
|
109
|
+
service = Trace::Service.new project_id, credentials, host: endpoint, timeout: timeout
|
110
|
+
Trace::Project.new service
|
113
111
|
end
|
114
112
|
|
115
113
|
##
|
@@ -128,8 +126,6 @@ module Google
|
|
128
126
|
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
|
129
127
|
# the set of resources and operations that the connection can access.
|
130
128
|
# * `timeout` - (Integer) Default timeout to use in requests.
|
131
|
-
# * `client_config` - (Hash) A hash of values to override the default
|
132
|
-
# behavior of the API client.
|
133
129
|
# * `endpoint` - (String) Override of the endpoint host name, or `nil`
|
134
130
|
# to use the default endpoint.
|
135
131
|
# * `capture_stack` - (Boolean) Whether to capture stack traces for each
|
@@ -267,7 +263,8 @@ module Google
|
|
267
263
|
# end
|
268
264
|
# end
|
269
265
|
#
|
270
|
-
def self.in_span name,
|
266
|
+
def self.in_span name,
|
267
|
+
kind: Google::Cloud::Trace::SpanKind::UNSPECIFIED,
|
271
268
|
labels: {}
|
272
269
|
parent = get
|
273
270
|
if parent
|
@@ -285,4 +282,11 @@ module Google
|
|
285
282
|
end
|
286
283
|
end
|
287
284
|
end
|
285
|
+
|
286
|
+
# Aliases for compatibility with older spellings.
|
287
|
+
# @private
|
288
|
+
module Devtools
|
289
|
+
# @private
|
290
|
+
Cloudtrace = ::Google::Cloud::Trace unless const_defined? :Cloudtrace
|
291
|
+
end
|
288
292
|
end
|
@@ -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
|
@@ -282,7 +282,7 @@ module Google
|
|
282
282
|
def default_error_callbacks
|
283
283
|
# This is memoized to reduce calls to the configuration.
|
284
284
|
@default_error_callbacks ||= begin
|
285
|
-
error_callback = Google::Cloud::
|
285
|
+
error_callback = Google::Cloud::Trace.configure.on_error
|
286
286
|
error_callback ||= Google::Cloud.configure.on_error
|
287
287
|
if error_callback
|
288
288
|
[error_callback]
|
@@ -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
|
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
-
require "google/cloud/trace/v1/credentials"
|
16
|
+
require "google/cloud/trace/v1/trace_service/credentials"
|
17
17
|
|
18
18
|
module Google
|
19
19
|
module Cloud
|
@@ -37,7 +37,7 @@ module Google
|
|
37
37
|
#
|
38
38
|
# trace.project_id #=> "my-project"
|
39
39
|
#
|
40
|
-
class Credentials < Google::Cloud::Trace::V1::Credentials
|
40
|
+
class Credentials < Google::Cloud::Trace::V1::TraceService::Credentials
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -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
|