google-cloud-trace-v2 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f7b21588bc980f40eeac0338aec2754fc4c05a89a610d43f2e6133627e430b7
4
- data.tar.gz: 2198a940655d88d2ba7eca3e8b6e47bf1865e30821dcec6cbdf078bf4645b238
3
+ metadata.gz: 301a2c0272350f4499cc6cbdd479f3f0c5e75671ceb29795dddab5606021188e
4
+ data.tar.gz: b920d6892f84d7dbed237a4d5c0d20f73882e75556febace1d4aeef32922b5cf
5
5
  SHA512:
6
- metadata.gz: 34db83437a6795c99993809bcf474b2b6c502175be9cc5b51089404077b62bb4b2196631ad5e265e2892ee38c724423eb9840b1a2747a14b88b0f06b6a5f3990
7
- data.tar.gz: 287ed6bf2b8c00fecc4c58c11c7ab1408c6b2582fc57000b5240ead2781a6175a23c7ba109a29aedea86757cd69bdbf5de6e4a95a9996e0965348a8d9dfdf2ac
6
+ metadata.gz: 87f06c9a3ecce4246547ff74e8026e08f692c713e96f39b016559845b563e448d5d2dbaf389cf8fb7fb44702825c0d152d6a3a956ae0f7d7e98daba6dbdd7d49
7
+ data.tar.gz: 1b7b847a95f498049dbc516ce945c568688e6ad9ee18d89405b12b8a1bae55bc45690fdd8e37f2cc5fcde6b03315b29bf85814df8ee58dcc9ebf9c996d823af0
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Ruby Client for the Cloud Trace V2 API
2
2
 
3
- API Client library for the Cloud Trace V2 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 OpenCensus, a set of open source tracing and stats instrumentation libraries that work with multiple backends.
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
 
@@ -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
@@ -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
@@ -0,0 +1,58 @@
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 "gapic/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/trace/v2/version"
24
+
25
+ require "google/cloud/trace/v2/trace_service/credentials"
26
+ require "google/cloud/trace/v2/trace_service/paths"
27
+ require "google/cloud/trace/v2/trace_service/rest/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Trace
32
+ module V2
33
+ ##
34
+ # Service for collecting and viewing traces and spans within a trace.
35
+ #
36
+ # A trace is a collection of spans corresponding to a single
37
+ # operation or a set of operations in an application.
38
+ #
39
+ # A span is an individual timed event which forms a node of the trace tree.
40
+ # A single trace can contain spans from multiple services.
41
+ #
42
+ # To load this service and instantiate a REST client:
43
+ #
44
+ # require "google/cloud/trace/v2/trace_service/rest"
45
+ # client = ::Google::Cloud::Trace::V2::TraceService::Rest::Client.new
46
+ #
47
+ module TraceService
48
+ # Client for the REST transport
49
+ module Rest
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
58
+ require "google/cloud/trace/v2/trace_service/rest/helpers" if ::File.file? helper_path
@@ -25,6 +25,7 @@ require "google/cloud/trace/v2/version"
25
25
  require "google/cloud/trace/v2/trace_service/credentials"
26
26
  require "google/cloud/trace/v2/trace_service/paths"
27
27
  require "google/cloud/trace/v2/trace_service/client"
28
+ require "google/cloud/trace/v2/trace_service/rest"
28
29
 
29
30
  module Google
30
31
  module Cloud
@@ -44,6 +45,11 @@ module Google
44
45
  # require "google/cloud/trace/v2/trace_service"
45
46
  # client = ::Google::Cloud::Trace::V2::TraceService::Client.new
46
47
  #
48
+ # @example Load this service and instantiate a REST client
49
+ #
50
+ # require "google/cloud/trace/v2/trace_service/rest"
51
+ # client = ::Google::Cloud::Trace::V2::TraceService::Rest::Client.new
52
+ #
47
53
  module TraceService
48
54
  end
49
55
  end
@@ -21,7 +21,7 @@ module Google
21
21
  module Cloud
22
22
  module Trace
23
23
  module V2
24
- VERSION = "0.4.1"
24
+ VERSION = "0.5.0"
25
25
  end
26
26
  end
27
27
  end
@@ -30,6 +30,11 @@ module Google
30
30
  # require "google/cloud/trace/v2"
31
31
  # client = ::Google::Cloud::Trace::V2::TraceService::Client.new
32
32
  #
33
+ # @example Load this package, including all its services, and instantiate a REST client
34
+ #
35
+ # require "google/cloud/trace/v2"
36
+ # client = ::Google::Cloud::Trace::V2::TraceService::Rest::Client.new
37
+ #
33
38
  module V2
34
39
  end
35
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-trace-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-27 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gapic-common
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.16.0
19
+ version: 0.18.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 2.a
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.16.0
29
+ version: 0.18.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.a
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 1.26.1
53
+ version: 1.26.3
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 1.26.1
60
+ version: 1.26.3
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: minitest
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -158,11 +158,11 @@ dependencies:
158
158
  version: '0.9'
159
159
  description: The Cloud Trace API lets you send and retrieve latency data to and from
160
160
  Cloud Trace. This API provides low-level interfaces for interacting directly with
161
- the feature. For some languages, you can use OpenCensus, a set of open source tracing
162
- and stats instrumentation libraries that work with multiple backends. Note that
163
- google-cloud-trace-v2 is a version-specific client library. For most uses, we recommend
164
- installing the main client library google-cloud-trace instead. See the readme for
165
- more details.
161
+ the feature. For some languages, you can use OpenTelemetry, a set of open source
162
+ tracing and stats instrumentation libraries that work with multiple backends. Note
163
+ that google-cloud-trace-v2 is a version-specific client library. For most uses,
164
+ we recommend installing the main client library google-cloud-trace instead. See
165
+ the readme for more details.
166
166
  email: googleapis-packages@google.com
167
167
  executables: []
168
168
  extensions: []
@@ -174,10 +174,14 @@ files:
174
174
  - README.md
175
175
  - lib/google-cloud-trace-v2.rb
176
176
  - lib/google/cloud/trace/v2.rb
177
+ - lib/google/cloud/trace/v2/rest.rb
177
178
  - lib/google/cloud/trace/v2/trace_service.rb
178
179
  - lib/google/cloud/trace/v2/trace_service/client.rb
179
180
  - lib/google/cloud/trace/v2/trace_service/credentials.rb
180
181
  - lib/google/cloud/trace/v2/trace_service/paths.rb
182
+ - lib/google/cloud/trace/v2/trace_service/rest.rb
183
+ - lib/google/cloud/trace/v2/trace_service/rest/client.rb
184
+ - lib/google/cloud/trace/v2/trace_service/rest/service_stub.rb
181
185
  - lib/google/cloud/trace/v2/version.rb
182
186
  - lib/google/devtools/cloudtrace/v2/trace_pb.rb
183
187
  - lib/google/devtools/cloudtrace/v2/tracing_pb.rb
@@ -217,5 +221,9 @@ requirements: []
217
221
  rubygems_version: 3.4.2
218
222
  signing_key:
219
223
  specification_version: 4
220
- summary: API Client library for the Cloud Trace V2 API
224
+ summary: Sends application trace data to Stackdriver Trace for viewing. Trace data
225
+ is collected for all App Engine applications by default. Trace data from other applications
226
+ can be provided using this API. This library is used to interact with the Trace
227
+ API directly. If you are looking to instrument your application for Stackdriver
228
+ Trace, we recommend using OpenTelemetry.
221
229
  test_files: []