google-cloud-trace-v2 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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://googleapis.dev/ruby/googleauth/latest/index.html))
378
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
379
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
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
@@ -0,0 +1,168 @@
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/devtools/cloudtrace/v2/tracing_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Trace
24
+ module V2
25
+ module TraceService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the TraceService service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ numeric_enums: true,
40
+ raise_faraday_errors: false
41
+ end
42
+
43
+ ##
44
+ # Baseline implementation for the batch_write_spans REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::Trace::V2::BatchWriteSpansRequest]
47
+ # A request object representing the call parameters. Required.
48
+ # @param options [::Gapic::CallOptions]
49
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
50
+ #
51
+ # @yield [result, operation] Access the result along with the TransportOperation object
52
+ # @yieldparam result [::Google::Protobuf::Empty]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Protobuf::Empty]
56
+ # A result object deserialized from the server's reply
57
+ def batch_write_spans request_pb, options = nil
58
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
59
+
60
+ verb, uri, query_string_params, body = ServiceStub.transcode_batch_write_spans_request request_pb
61
+ query_string_params = if query_string_params.any?
62
+ query_string_params.to_h { |p| p.split("=", 2) }
63
+ else
64
+ {}
65
+ end
66
+
67
+ response = @client_stub.make_http_request(
68
+ verb,
69
+ uri: uri,
70
+ body: body || "",
71
+ params: query_string_params,
72
+ options: options
73
+ )
74
+ operation = ::Gapic::Rest::TransportOperation.new response
75
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
76
+
77
+ yield result, operation if block_given?
78
+ result
79
+ end
80
+
81
+ ##
82
+ # Baseline implementation for the create_span REST call
83
+ #
84
+ # @param request_pb [::Google::Cloud::Trace::V2::Span]
85
+ # A request object representing the call parameters. Required.
86
+ # @param options [::Gapic::CallOptions]
87
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
88
+ #
89
+ # @yield [result, operation] Access the result along with the TransportOperation object
90
+ # @yieldparam result [::Google::Cloud::Trace::V2::Span]
91
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
92
+ #
93
+ # @return [::Google::Cloud::Trace::V2::Span]
94
+ # A result object deserialized from the server's reply
95
+ def create_span request_pb, options = nil
96
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
97
+
98
+ verb, uri, query_string_params, body = ServiceStub.transcode_create_span_request request_pb
99
+ query_string_params = if query_string_params.any?
100
+ query_string_params.to_h { |p| p.split("=", 2) }
101
+ else
102
+ {}
103
+ end
104
+
105
+ response = @client_stub.make_http_request(
106
+ verb,
107
+ uri: uri,
108
+ body: body || "",
109
+ params: query_string_params,
110
+ options: options
111
+ )
112
+ operation = ::Gapic::Rest::TransportOperation.new response
113
+ result = ::Google::Cloud::Trace::V2::Span.decode_json response.body, ignore_unknown_fields: true
114
+
115
+ yield result, operation if block_given?
116
+ result
117
+ end
118
+
119
+ ##
120
+ # @private
121
+ #
122
+ # GRPC transcoding helper method for the batch_write_spans REST call
123
+ #
124
+ # @param request_pb [::Google::Cloud::Trace::V2::BatchWriteSpansRequest]
125
+ # A request object representing the call parameters. Required.
126
+ # @return [Array(String, [String, nil], Hash{String => String})]
127
+ # Uri, Body, Query string parameters
128
+ def self.transcode_batch_write_spans_request request_pb
129
+ transcoder = Gapic::Rest::GrpcTranscoder.new
130
+ .with_bindings(
131
+ uri_method: :post,
132
+ uri_template: "/v2/{name}/traces:batchWrite",
133
+ body: "*",
134
+ matches: [
135
+ ["name", %r{^projects/[^/]+/?$}, false]
136
+ ]
137
+ )
138
+ transcoder.transcode request_pb
139
+ end
140
+
141
+ ##
142
+ # @private
143
+ #
144
+ # GRPC transcoding helper method for the create_span REST call
145
+ #
146
+ # @param request_pb [::Google::Cloud::Trace::V2::Span]
147
+ # A request object representing the call parameters. Required.
148
+ # @return [Array(String, [String, nil], Hash{String => String})]
149
+ # Uri, Body, Query string parameters
150
+ def self.transcode_create_span_request request_pb
151
+ transcoder = Gapic::Rest::GrpcTranscoder.new
152
+ .with_bindings(
153
+ uri_method: :post,
154
+ uri_template: "/v2/{name}",
155
+ body: "*",
156
+ matches: [
157
+ ["name", %r{^projects/[^/]+/traces/[^/]+/spans/[^/]+/?$}, false]
158
+ ]
159
+ )
160
+ transcoder.transcode request_pb
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end