google-cloud-trace-v2 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/google/cloud/trace/v2/rest.rb +37 -0
- data/lib/google/cloud/trace/v2/trace_service/client.rb +2 -2
- data/lib/google/cloud/trace/v2/trace_service/rest/client.rb +490 -0
- data/lib/google/cloud/trace/v2/trace_service/rest/service_stub.rb +168 -0
- data/lib/google/cloud/trace/v2/trace_service/rest.rb +58 -0
- data/lib/google/cloud/trace/v2/trace_service.rb +6 -0
- data/lib/google/cloud/trace/v2/version.rb +1 -1
- data/lib/google/cloud/trace/v2.rb +5 -0
- data/lib/google/devtools/cloudtrace/v2/trace_pb.rb +27 -103
- data/lib/google/devtools/cloudtrace/v2/tracing_pb.rb +25 -5
- data/proto_docs/google/api/client.rb +67 -4
- data/proto_docs/google/protobuf/any.rb +7 -4
- data/proto_docs/google/protobuf/timestamp.rb +1 -3
- metadata +20 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65456a04388bb995452a37730e6298629f1a8254d2f557aff2d1866d8e5ad270
|
4
|
+
data.tar.gz: 8b6b5bfbaa1a99e45c85e7c2f50489b15d5e2e9f6106b85dd48e1474b1669acc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d17f62eda956eef397dba508b116a0a67b0d7176a94198e765c0481143de53fb465320be721649066db7d68da48661491fe2eadaa5bc5698ace7664e70ebec55
|
7
|
+
data.tar.gz: b440d55b18ed9266fe6efef4472a073ee7afc4e66e1ac214c18d6810adad3f74b5705290df1c6da2249646113c4d66f0a280bf6ff2a2093b2a08235559f098d8
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Ruby Client for the Cloud Trace V2 API
|
2
2
|
|
3
|
-
API
|
3
|
+
Sends application trace data to Stackdriver Trace for viewing. Trace data is collected for all App Engine applications by default. Trace data from other applications can be provided using this API. This library is used to interact with the Trace API directly. If you are looking to instrument your application for Stackdriver Trace, we recommend using OpenTelemetry.
|
4
4
|
|
5
|
-
The Cloud Trace API lets you send and retrieve latency data to and from Cloud Trace. This API provides low-level interfaces for interacting directly with the feature. For some languages, you can use
|
5
|
+
The Cloud Trace API lets you send and retrieve latency data to and from Cloud Trace. This API provides low-level interfaces for interacting directly with the feature. For some languages, you can use OpenTelemetry, a set of open source tracing and stats instrumentation libraries that work with multiple backends.
|
6
6
|
|
7
7
|
https://github.com/googleapis/google-cloud-ruby
|
8
8
|
|
@@ -47,7 +47,7 @@ for general usage information.
|
|
47
47
|
|
48
48
|
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
49
49
|
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
|
50
|
-
or a [`Google::Cloud::Logging::Logger`](https://
|
50
|
+
or a [`Google::Cloud::Logging::Logger`](https://cloud.google.com/ruby/docs/reference/google-cloud-logging/latest)
|
51
51
|
that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
52
52
|
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
53
53
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/trace/v2/trace_service/rest"
|
20
|
+
require "google/cloud/trace/v2/version"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module Trace
|
25
|
+
##
|
26
|
+
# To load just the REST part of this package, including all its services, and instantiate a REST client:
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
#
|
30
|
+
# require "google/cloud/trace/v2/rest"
|
31
|
+
# client = ::Google::Cloud::Trace::V2::TraceService::Rest::Client.new
|
32
|
+
#
|
33
|
+
module V2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -429,9 +429,9 @@ module Google
|
|
429
429
|
# * (`String`) The path to a service account key file in JSON format
|
430
430
|
# * (`Hash`) A service account key as a Hash
|
431
431
|
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
432
|
-
# (see the [googleauth docs](https://
|
432
|
+
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
|
433
433
|
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
434
|
-
# (see the [signet docs](https://
|
434
|
+
# (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
|
435
435
|
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
436
436
|
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
437
437
|
# * (`nil`) indicating no credentials
|
@@ -0,0 +1,490 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/devtools/cloudtrace/v2/tracing_pb"
|
21
|
+
require "google/cloud/trace/v2/trace_service/rest/service_stub"
|
22
|
+
|
23
|
+
module Google
|
24
|
+
module Cloud
|
25
|
+
module Trace
|
26
|
+
module V2
|
27
|
+
module TraceService
|
28
|
+
module Rest
|
29
|
+
##
|
30
|
+
# REST client for the TraceService service.
|
31
|
+
#
|
32
|
+
# Service for collecting and viewing traces and spans within a trace.
|
33
|
+
#
|
34
|
+
# A trace is a collection of spans corresponding to a single
|
35
|
+
# operation or a set of operations in an application.
|
36
|
+
#
|
37
|
+
# A span is an individual timed event which forms a node of the trace tree.
|
38
|
+
# A single trace can contain spans from multiple services.
|
39
|
+
#
|
40
|
+
class Client
|
41
|
+
include Paths
|
42
|
+
|
43
|
+
# @private
|
44
|
+
attr_reader :trace_service_stub
|
45
|
+
|
46
|
+
##
|
47
|
+
# Configure the TraceService Client class.
|
48
|
+
#
|
49
|
+
# See {::Google::Cloud::Trace::V2::TraceService::Rest::Client::Configuration}
|
50
|
+
# for a description of the configuration fields.
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
#
|
54
|
+
# # Modify the configuration for all TraceService clients
|
55
|
+
# ::Google::Cloud::Trace::V2::TraceService::Rest::Client.configure do |config|
|
56
|
+
# config.timeout = 10.0
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# @yield [config] Configure the Client client.
|
60
|
+
# @yieldparam config [Client::Configuration]
|
61
|
+
#
|
62
|
+
# @return [Client::Configuration]
|
63
|
+
#
|
64
|
+
def self.configure
|
65
|
+
@configure ||= begin
|
66
|
+
namespace = ["Google", "Cloud", "Trace", "V2"]
|
67
|
+
parent_config = while namespace.any?
|
68
|
+
parent_name = namespace.join "::"
|
69
|
+
parent_const = const_get parent_name
|
70
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
71
|
+
namespace.pop
|
72
|
+
end
|
73
|
+
default_config = Client::Configuration.new parent_config
|
74
|
+
|
75
|
+
default_config.rpcs.batch_write_spans.timeout = 120.0
|
76
|
+
default_config.rpcs.batch_write_spans.retry_policy = {
|
77
|
+
initial_delay: 0.1, max_delay: 30.0, multiplier: 2, retry_codes: [14, 4]
|
78
|
+
}
|
79
|
+
|
80
|
+
default_config.rpcs.create_span.timeout = 120.0
|
81
|
+
default_config.rpcs.create_span.retry_policy = {
|
82
|
+
initial_delay: 0.1, max_delay: 1.0, multiplier: 1.2, retry_codes: [14, 4]
|
83
|
+
}
|
84
|
+
|
85
|
+
default_config
|
86
|
+
end
|
87
|
+
yield @configure if block_given?
|
88
|
+
@configure
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Configure the TraceService Client instance.
|
93
|
+
#
|
94
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
95
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
96
|
+
# should be made on {Client.configure}.
|
97
|
+
#
|
98
|
+
# See {::Google::Cloud::Trace::V2::TraceService::Rest::Client::Configuration}
|
99
|
+
# for a description of the configuration fields.
|
100
|
+
#
|
101
|
+
# @yield [config] Configure the Client client.
|
102
|
+
# @yieldparam config [Client::Configuration]
|
103
|
+
#
|
104
|
+
# @return [Client::Configuration]
|
105
|
+
#
|
106
|
+
def configure
|
107
|
+
yield @config if block_given?
|
108
|
+
@config
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# Create a new TraceService REST client object.
|
113
|
+
#
|
114
|
+
# @example
|
115
|
+
#
|
116
|
+
# # Create a client using the default configuration
|
117
|
+
# client = ::Google::Cloud::Trace::V2::TraceService::Rest::Client.new
|
118
|
+
#
|
119
|
+
# # Create a client using a custom configuration
|
120
|
+
# client = ::Google::Cloud::Trace::V2::TraceService::Rest::Client.new do |config|
|
121
|
+
# config.timeout = 10.0
|
122
|
+
# end
|
123
|
+
#
|
124
|
+
# @yield [config] Configure the TraceService client.
|
125
|
+
# @yieldparam config [Client::Configuration]
|
126
|
+
#
|
127
|
+
def initialize
|
128
|
+
# Create the configuration object
|
129
|
+
@config = Configuration.new Client.configure
|
130
|
+
|
131
|
+
# Yield the configuration if needed
|
132
|
+
yield @config if block_given?
|
133
|
+
|
134
|
+
# Create credentials
|
135
|
+
credentials = @config.credentials
|
136
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
137
|
+
# but only if the default endpoint does not have a region prefix.
|
138
|
+
enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
|
139
|
+
!@config.endpoint.split(".").first.include?("-")
|
140
|
+
credentials ||= Credentials.default scope: @config.scope,
|
141
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
142
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
143
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
144
|
+
end
|
145
|
+
|
146
|
+
@quota_project_id = @config.quota_project
|
147
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
148
|
+
|
149
|
+
@trace_service_stub = ::Google::Cloud::Trace::V2::TraceService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
|
150
|
+
end
|
151
|
+
|
152
|
+
# Service calls
|
153
|
+
|
154
|
+
##
|
155
|
+
# Batch writes new spans to new or existing traces. You cannot update
|
156
|
+
# existing spans.
|
157
|
+
#
|
158
|
+
# @overload batch_write_spans(request, options = nil)
|
159
|
+
# Pass arguments to `batch_write_spans` via a request object, either of type
|
160
|
+
# {::Google::Cloud::Trace::V2::BatchWriteSpansRequest} or an equivalent Hash.
|
161
|
+
#
|
162
|
+
# @param request [::Google::Cloud::Trace::V2::BatchWriteSpansRequest, ::Hash]
|
163
|
+
# A request object representing the call parameters. Required. To specify no
|
164
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
165
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
166
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
167
|
+
#
|
168
|
+
# @overload batch_write_spans(name: nil, spans: nil)
|
169
|
+
# Pass arguments to `batch_write_spans` via keyword arguments. Note that at
|
170
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
171
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
172
|
+
#
|
173
|
+
# @param name [::String]
|
174
|
+
# Required. The name of the project where the spans belong. The format is
|
175
|
+
# `projects/[PROJECT_ID]`.
|
176
|
+
# @param spans [::Array<::Google::Cloud::Trace::V2::Span, ::Hash>]
|
177
|
+
# Required. A list of new spans. The span names must not match existing
|
178
|
+
# spans, otherwise the results are undefined.
|
179
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
180
|
+
# @yieldparam result [::Google::Protobuf::Empty]
|
181
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
182
|
+
#
|
183
|
+
# @return [::Google::Protobuf::Empty]
|
184
|
+
#
|
185
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
186
|
+
def batch_write_spans request, options = nil
|
187
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
188
|
+
|
189
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Trace::V2::BatchWriteSpansRequest
|
190
|
+
|
191
|
+
# Converts hash and nil to an options object
|
192
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
193
|
+
|
194
|
+
# Customize the options with defaults
|
195
|
+
call_metadata = @config.rpcs.batch_write_spans.metadata.to_h
|
196
|
+
|
197
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
198
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
199
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
200
|
+
gapic_version: ::Google::Cloud::Trace::V2::VERSION,
|
201
|
+
transports_version_send: [:rest]
|
202
|
+
|
203
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
204
|
+
|
205
|
+
options.apply_defaults timeout: @config.rpcs.batch_write_spans.timeout,
|
206
|
+
metadata: call_metadata,
|
207
|
+
retry_policy: @config.rpcs.batch_write_spans.retry_policy
|
208
|
+
|
209
|
+
options.apply_defaults timeout: @config.timeout,
|
210
|
+
metadata: @config.metadata,
|
211
|
+
retry_policy: @config.retry_policy
|
212
|
+
|
213
|
+
@trace_service_stub.batch_write_spans request, options do |result, operation|
|
214
|
+
yield result, operation if block_given?
|
215
|
+
return result
|
216
|
+
end
|
217
|
+
rescue ::Gapic::Rest::Error => e
|
218
|
+
raise ::Google::Cloud::Error.from_error(e)
|
219
|
+
end
|
220
|
+
|
221
|
+
##
|
222
|
+
# Creates a new span.
|
223
|
+
#
|
224
|
+
# @overload create_span(request, options = nil)
|
225
|
+
# Pass arguments to `create_span` via a request object, either of type
|
226
|
+
# {::Google::Cloud::Trace::V2::Span} or an equivalent Hash.
|
227
|
+
#
|
228
|
+
# @param request [::Google::Cloud::Trace::V2::Span, ::Hash]
|
229
|
+
# A request object representing the call parameters. Required. To specify no
|
230
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
231
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
232
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
233
|
+
#
|
234
|
+
# @overload create_span(name: nil, span_id: nil, parent_span_id: nil, display_name: nil, start_time: nil, end_time: nil, attributes: nil, stack_trace: nil, time_events: nil, links: nil, status: nil, same_process_as_parent_span: nil, child_span_count: nil, span_kind: nil)
|
235
|
+
# Pass arguments to `create_span` via keyword arguments. Note that at
|
236
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
237
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
238
|
+
#
|
239
|
+
# @param name [::String]
|
240
|
+
# Required. The resource name of the span in the following format:
|
241
|
+
#
|
242
|
+
# * `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]`
|
243
|
+
#
|
244
|
+
# `[TRACE_ID]` is a unique identifier for a trace within a project;
|
245
|
+
# it is a 32-character hexadecimal encoding of a 16-byte array. It should
|
246
|
+
# not be zero.
|
247
|
+
#
|
248
|
+
# `[SPAN_ID]` is a unique identifier for a span within a trace; it
|
249
|
+
# is a 16-character hexadecimal encoding of an 8-byte array. It should not
|
250
|
+
# be zero.
|
251
|
+
# .
|
252
|
+
# @param span_id [::String]
|
253
|
+
# Required. The `[SPAN_ID]` portion of the span's resource name.
|
254
|
+
# @param parent_span_id [::String]
|
255
|
+
# The `[SPAN_ID]` of this span's parent span. If this is a root span,
|
256
|
+
# then this field must be empty.
|
257
|
+
# @param display_name [::Google::Cloud::Trace::V2::TruncatableString, ::Hash]
|
258
|
+
# Required. A description of the span's operation (up to 128 bytes).
|
259
|
+
# Cloud Trace displays the description in the
|
260
|
+
# Cloud console.
|
261
|
+
# For example, the display name can be a qualified method name or a file name
|
262
|
+
# and a line number where the operation is called. A best practice is to use
|
263
|
+
# the same display name within an application and at the same call point.
|
264
|
+
# This makes it easier to correlate spans in different traces.
|
265
|
+
# @param start_time [::Google::Protobuf::Timestamp, ::Hash]
|
266
|
+
# Required. The start time of the span. On the client side, this is the time
|
267
|
+
# kept by the local machine where the span execution starts. On the server
|
268
|
+
# side, this is the time when the server's application handler starts
|
269
|
+
# running.
|
270
|
+
# @param end_time [::Google::Protobuf::Timestamp, ::Hash]
|
271
|
+
# Required. The end time of the span. On the client side, this is the time
|
272
|
+
# kept by the local machine where the span execution ends. On the server
|
273
|
+
# side, this is the time when the server application handler stops running.
|
274
|
+
# @param attributes [::Google::Cloud::Trace::V2::Span::Attributes, ::Hash]
|
275
|
+
# A set of attributes on the span. You can have up to 32 attributes per
|
276
|
+
# span.
|
277
|
+
# @param stack_trace [::Google::Cloud::Trace::V2::StackTrace, ::Hash]
|
278
|
+
# Stack trace captured at the start of the span.
|
279
|
+
# @param time_events [::Google::Cloud::Trace::V2::Span::TimeEvents, ::Hash]
|
280
|
+
# A set of time events. You can have up to 32 annotations and 128 message
|
281
|
+
# events per span.
|
282
|
+
# @param links [::Google::Cloud::Trace::V2::Span::Links, ::Hash]
|
283
|
+
# Links associated with the span. You can have up to 128 links per Span.
|
284
|
+
# @param status [::Google::Rpc::Status, ::Hash]
|
285
|
+
# Optional. The final status for this span.
|
286
|
+
# @param same_process_as_parent_span [::Google::Protobuf::BoolValue, ::Hash]
|
287
|
+
# Optional. Set this parameter to indicate whether this span is in
|
288
|
+
# the same process as its parent. If you do not set this parameter,
|
289
|
+
# Trace is unable to take advantage of this helpful information.
|
290
|
+
# @param child_span_count [::Google::Protobuf::Int32Value, ::Hash]
|
291
|
+
# Optional. The number of child spans that were generated while this span
|
292
|
+
# was active. If set, allows implementation to detect missing child spans.
|
293
|
+
# @param span_kind [::Google::Cloud::Trace::V2::Span::SpanKind]
|
294
|
+
# Optional. Distinguishes between spans generated in a particular context.
|
295
|
+
# For example, two spans with the same name may be distinguished using
|
296
|
+
# `CLIENT` (caller) and `SERVER` (callee) to identify an RPC call.
|
297
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
298
|
+
# @yieldparam result [::Google::Cloud::Trace::V2::Span]
|
299
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
300
|
+
#
|
301
|
+
# @return [::Google::Cloud::Trace::V2::Span]
|
302
|
+
#
|
303
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
304
|
+
def create_span request, options = nil
|
305
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
306
|
+
|
307
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Trace::V2::Span
|
308
|
+
|
309
|
+
# Converts hash and nil to an options object
|
310
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
311
|
+
|
312
|
+
# Customize the options with defaults
|
313
|
+
call_metadata = @config.rpcs.create_span.metadata.to_h
|
314
|
+
|
315
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
316
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
317
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
318
|
+
gapic_version: ::Google::Cloud::Trace::V2::VERSION,
|
319
|
+
transports_version_send: [:rest]
|
320
|
+
|
321
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
322
|
+
|
323
|
+
options.apply_defaults timeout: @config.rpcs.create_span.timeout,
|
324
|
+
metadata: call_metadata,
|
325
|
+
retry_policy: @config.rpcs.create_span.retry_policy
|
326
|
+
|
327
|
+
options.apply_defaults timeout: @config.timeout,
|
328
|
+
metadata: @config.metadata,
|
329
|
+
retry_policy: @config.retry_policy
|
330
|
+
|
331
|
+
@trace_service_stub.create_span request, options do |result, operation|
|
332
|
+
yield result, operation if block_given?
|
333
|
+
return result
|
334
|
+
end
|
335
|
+
rescue ::Gapic::Rest::Error => e
|
336
|
+
raise ::Google::Cloud::Error.from_error(e)
|
337
|
+
end
|
338
|
+
|
339
|
+
##
|
340
|
+
# Configuration class for the TraceService REST API.
|
341
|
+
#
|
342
|
+
# This class represents the configuration for TraceService REST,
|
343
|
+
# providing control over timeouts, retry behavior, logging, transport
|
344
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
345
|
+
# applied individually to specific RPCs. See
|
346
|
+
# {::Google::Cloud::Trace::V2::TraceService::Rest::Client::Configuration::Rpcs}
|
347
|
+
# for a list of RPCs that can be configured independently.
|
348
|
+
#
|
349
|
+
# Configuration can be applied globally to all clients, or to a single client
|
350
|
+
# on construction.
|
351
|
+
#
|
352
|
+
# @example
|
353
|
+
#
|
354
|
+
# # Modify the global config, setting the timeout for
|
355
|
+
# # batch_write_spans to 20 seconds,
|
356
|
+
# # and all remaining timeouts to 10 seconds.
|
357
|
+
# ::Google::Cloud::Trace::V2::TraceService::Rest::Client.configure do |config|
|
358
|
+
# config.timeout = 10.0
|
359
|
+
# config.rpcs.batch_write_spans.timeout = 20.0
|
360
|
+
# end
|
361
|
+
#
|
362
|
+
# # Apply the above configuration only to a new client.
|
363
|
+
# client = ::Google::Cloud::Trace::V2::TraceService::Rest::Client.new do |config|
|
364
|
+
# config.timeout = 10.0
|
365
|
+
# config.rpcs.batch_write_spans.timeout = 20.0
|
366
|
+
# end
|
367
|
+
#
|
368
|
+
# @!attribute [rw] endpoint
|
369
|
+
# The hostname or hostname:port of the service endpoint.
|
370
|
+
# Defaults to `"cloudtrace.googleapis.com"`.
|
371
|
+
# @return [::String]
|
372
|
+
# @!attribute [rw] credentials
|
373
|
+
# Credentials to send with calls. You may provide any of the following types:
|
374
|
+
# * (`String`) The path to a service account key file in JSON format
|
375
|
+
# * (`Hash`) A service account key as a Hash
|
376
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
377
|
+
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
|
378
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
379
|
+
# (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
|
380
|
+
# * (`nil`) indicating no credentials
|
381
|
+
# @return [::Object]
|
382
|
+
# @!attribute [rw] scope
|
383
|
+
# The OAuth scopes
|
384
|
+
# @return [::Array<::String>]
|
385
|
+
# @!attribute [rw] lib_name
|
386
|
+
# The library name as recorded in instrumentation and logging
|
387
|
+
# @return [::String]
|
388
|
+
# @!attribute [rw] lib_version
|
389
|
+
# The library version as recorded in instrumentation and logging
|
390
|
+
# @return [::String]
|
391
|
+
# @!attribute [rw] timeout
|
392
|
+
# The call timeout in seconds.
|
393
|
+
# @return [::Numeric]
|
394
|
+
# @!attribute [rw] metadata
|
395
|
+
# Additional headers to be sent with the call.
|
396
|
+
# @return [::Hash{::Symbol=>::String}]
|
397
|
+
# @!attribute [rw] retry_policy
|
398
|
+
# The retry policy. The value is a hash with the following keys:
|
399
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
400
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
401
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
402
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
403
|
+
# trigger a retry.
|
404
|
+
# @return [::Hash]
|
405
|
+
# @!attribute [rw] quota_project
|
406
|
+
# A separate project against which to charge quota.
|
407
|
+
# @return [::String]
|
408
|
+
#
|
409
|
+
class Configuration
|
410
|
+
extend ::Gapic::Config
|
411
|
+
|
412
|
+
config_attr :endpoint, "cloudtrace.googleapis.com", ::String
|
413
|
+
config_attr :credentials, nil do |value|
|
414
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
415
|
+
allowed.any? { |klass| klass === value }
|
416
|
+
end
|
417
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
418
|
+
config_attr :lib_name, nil, ::String, nil
|
419
|
+
config_attr :lib_version, nil, ::String, nil
|
420
|
+
config_attr :timeout, nil, ::Numeric, nil
|
421
|
+
config_attr :metadata, nil, ::Hash, nil
|
422
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
423
|
+
config_attr :quota_project, nil, ::String, nil
|
424
|
+
|
425
|
+
# @private
|
426
|
+
def initialize parent_config = nil
|
427
|
+
@parent_config = parent_config unless parent_config.nil?
|
428
|
+
|
429
|
+
yield self if block_given?
|
430
|
+
end
|
431
|
+
|
432
|
+
##
|
433
|
+
# Configurations for individual RPCs
|
434
|
+
# @return [Rpcs]
|
435
|
+
#
|
436
|
+
def rpcs
|
437
|
+
@rpcs ||= begin
|
438
|
+
parent_rpcs = nil
|
439
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
440
|
+
Rpcs.new parent_rpcs
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
##
|
445
|
+
# Configuration RPC class for the TraceService API.
|
446
|
+
#
|
447
|
+
# Includes fields providing the configuration for each RPC in this service.
|
448
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
449
|
+
# the following configuration fields:
|
450
|
+
#
|
451
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
452
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
453
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
454
|
+
# include the following keys:
|
455
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
456
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
457
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
458
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
459
|
+
# trigger a retry.
|
460
|
+
#
|
461
|
+
class Rpcs
|
462
|
+
##
|
463
|
+
# RPC-specific configuration for `batch_write_spans`
|
464
|
+
# @return [::Gapic::Config::Method]
|
465
|
+
#
|
466
|
+
attr_reader :batch_write_spans
|
467
|
+
##
|
468
|
+
# RPC-specific configuration for `create_span`
|
469
|
+
# @return [::Gapic::Config::Method]
|
470
|
+
#
|
471
|
+
attr_reader :create_span
|
472
|
+
|
473
|
+
# @private
|
474
|
+
def initialize parent_rpcs = nil
|
475
|
+
batch_write_spans_config = parent_rpcs.batch_write_spans if parent_rpcs.respond_to? :batch_write_spans
|
476
|
+
@batch_write_spans = ::Gapic::Config::Method.new batch_write_spans_config
|
477
|
+
create_span_config = parent_rpcs.create_span if parent_rpcs.respond_to? :create_span
|
478
|
+
@create_span = ::Gapic::Config::Method.new create_span_config
|
479
|
+
|
480
|
+
yield self if block_given?
|
481
|
+
end
|
482
|
+
end
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
488
|
+
end
|
489
|
+
end
|
490
|
+
end
|