google-cloud-trace 0.39.0 → 0.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +3 -2
  3. data/CHANGELOG.md +49 -0
  4. data/CONTRIBUTING.md +4 -5
  5. data/LOGGING.md +1 -1
  6. data/OVERVIEW.md +1 -2
  7. data/lib/google-cloud-trace.rb +20 -12
  8. data/lib/google/cloud/trace.rb +18 -14
  9. data/lib/google/cloud/trace/async_reporter.rb +7 -6
  10. data/lib/google/cloud/trace/credentials.rb +2 -2
  11. data/lib/google/cloud/trace/errors.rb +2 -2
  12. data/lib/google/cloud/trace/faraday_middleware.rb +5 -7
  13. data/lib/google/cloud/trace/label_key.rb +1 -1
  14. data/lib/google/cloud/trace/middleware.rb +7 -8
  15. data/lib/google/cloud/trace/notifications.rb +13 -14
  16. data/lib/google/cloud/trace/patches/active_call_with_trace.rb +2 -2
  17. data/lib/google/cloud/trace/patches/call_with_trace.rb +2 -2
  18. data/lib/google/cloud/trace/rails.rb +2 -2
  19. data/lib/google/cloud/trace/result_set.rb +20 -12
  20. data/lib/google/cloud/trace/service.rb +37 -60
  21. data/lib/google/cloud/trace/span.rb +7 -7
  22. data/lib/google/cloud/trace/trace_record.rb +4 -5
  23. data/lib/google/cloud/trace/utils.rb +1 -1
  24. data/lib/google/cloud/trace/version.rb +1 -1
  25. metadata +23 -72
  26. data/lib/google/cloud/trace/v1.rb +0 -16
  27. data/lib/google/cloud/trace/v1/credentials.rb +0 -39
  28. data/lib/google/cloud/trace/v1/doc/google/devtools/cloudtrace/v1/trace.rb +0 -253
  29. data/lib/google/cloud/trace/v1/doc/google/protobuf/empty.rb +0 -29
  30. data/lib/google/cloud/trace/v1/doc/google/protobuf/timestamp.rb +0 -113
  31. data/lib/google/cloud/trace/v1/trace_service_client.rb +0 -425
  32. data/lib/google/cloud/trace/v1/trace_service_client_config.json +0 -41
  33. data/lib/google/cloud/trace/v2.rb +0 -123
  34. data/lib/google/cloud/trace/v2/credentials.rb +0 -39
  35. data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/trace.rb +0 -356
  36. data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/tracing.rb +0 -33
  37. data/lib/google/cloud/trace/v2/doc/google/protobuf/any.rb +0 -131
  38. data/lib/google/cloud/trace/v2/doc/google/protobuf/empty.rb +0 -29
  39. data/lib/google/cloud/trace/v2/doc/google/protobuf/timestamp.rb +0 -113
  40. data/lib/google/cloud/trace/v2/doc/google/protobuf/wrappers.rb +0 -34
  41. data/lib/google/cloud/trace/v2/doc/google/rpc/status.rb +0 -39
  42. data/lib/google/cloud/trace/v2/trace_service_client.rb +0 -418
  43. data/lib/google/cloud/trace/v2/trace_service_client_config.json +0 -36
  44. data/lib/google/devtools/cloudtrace/v1/trace_pb.rb +0 -82
  45. data/lib/google/devtools/cloudtrace/v1/trace_services_pb.rb +0 -58
  46. data/lib/google/devtools/cloudtrace/v2/trace_pb.rb +0 -142
  47. data/lib/google/devtools/cloudtrace/v2/tracing_pb.rb +0 -29
  48. data/lib/google/devtools/cloudtrace/v2/tracing_services_pb.rb +0 -53
@@ -1,425 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/devtools/cloudtrace/v1/trace.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/devtools/cloudtrace/v1/trace_pb"
29
- require "google/cloud/trace/v1/credentials"
30
- require "google/cloud/trace/version"
31
-
32
- module Google
33
- module Cloud
34
- module Trace
35
- module V1
36
- # This file describes an API for collecting and viewing traces and spans
37
- # within a trace. A Trace is a collection of spans corresponding to a single
38
- # operation or set of operations for an application. A span is an individual
39
- # timed event which forms a node of the trace tree. Spans for a single trace
40
- # may span multiple services.
41
- #
42
- # @!attribute [r] trace_service_stub
43
- # @return [Google::Devtools::Cloudtrace::V1::TraceService::Stub]
44
- class TraceServiceClient
45
- # @private
46
- attr_reader :trace_service_stub
47
-
48
- # The default address of the service.
49
- SERVICE_ADDRESS = "cloudtrace.googleapis.com".freeze
50
-
51
- # The default port of the service.
52
- DEFAULT_SERVICE_PORT = 443
53
-
54
- # The default set of gRPC interceptors.
55
- GRPC_INTERCEPTORS = []
56
-
57
- DEFAULT_TIMEOUT = 30
58
-
59
- PAGE_DESCRIPTORS = {
60
- "list_traces" => Google::Gax::PageDescriptor.new(
61
- "page_token",
62
- "next_page_token",
63
- "traces")
64
- }.freeze
65
-
66
- private_constant :PAGE_DESCRIPTORS
67
-
68
- # The scopes needed to make gRPC calls to all of the methods defined in
69
- # this service.
70
- ALL_SCOPES = [
71
- "https://www.googleapis.com/auth/cloud-platform",
72
- "https://www.googleapis.com/auth/trace.append",
73
- "https://www.googleapis.com/auth/trace.readonly"
74
- ].freeze
75
-
76
-
77
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
78
- # Provides the means for authenticating requests made by the client. This parameter can
79
- # be many types.
80
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
81
- # authenticating requests made by this client.
82
- # A `String` will be treated as the path to the keyfile to be used for the construction of
83
- # credentials for this client.
84
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
85
- # credentials for this client.
86
- # A `GRPC::Core::Channel` will be used to make calls through.
87
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
88
- # should already be composed with a `GRPC::Core::CallCredentials` object.
89
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
90
- # metadata for requests, generally, to give OAuth credentials.
91
- # @param scopes [Array<String>]
92
- # The OAuth scopes for this service. This parameter is ignored if
93
- # an updater_proc is supplied.
94
- # @param client_config [Hash]
95
- # A Hash for call options for each method. See
96
- # Google::Gax#construct_settings for the structure of
97
- # this data. Falls back to the default config if not specified
98
- # or the specified config is missing data points.
99
- # @param timeout [Numeric]
100
- # The default timeout, in seconds, for calls made through this client.
101
- # @param metadata [Hash]
102
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
103
- # @param service_address [String]
104
- # Override for the service hostname, or `nil` to leave as the default.
105
- # @param service_port [Integer]
106
- # Override for the service port, or `nil` to leave as the default.
107
- # @param exception_transformer [Proc]
108
- # An optional proc that intercepts any exceptions raised during an API call to inject
109
- # custom error handling.
110
- def initialize \
111
- credentials: nil,
112
- scopes: ALL_SCOPES,
113
- client_config: {},
114
- timeout: DEFAULT_TIMEOUT,
115
- metadata: nil,
116
- service_address: nil,
117
- service_port: nil,
118
- exception_transformer: nil,
119
- lib_name: nil,
120
- lib_version: ""
121
- # These require statements are intentionally placed here to initialize
122
- # the gRPC module only when it's required.
123
- # See https://github.com/googleapis/toolkit/issues/446
124
- require "google/gax/grpc"
125
- require "google/devtools/cloudtrace/v1/trace_services_pb"
126
-
127
- credentials ||= Google::Cloud::Trace::V1::Credentials.default
128
-
129
- if credentials.is_a?(String) || credentials.is_a?(Hash)
130
- updater_proc = Google::Cloud::Trace::V1::Credentials.new(credentials).updater_proc
131
- end
132
- if credentials.is_a?(GRPC::Core::Channel)
133
- channel = credentials
134
- end
135
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
136
- chan_creds = credentials
137
- end
138
- if credentials.is_a?(Proc)
139
- updater_proc = credentials
140
- end
141
- if credentials.is_a?(Google::Auth::Credentials)
142
- updater_proc = credentials.updater_proc
143
- end
144
-
145
- package_version = Google::Cloud::Trace::VERSION
146
-
147
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
148
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
149
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
150
- google_api_client << " grpc/#{GRPC::VERSION}"
151
- google_api_client.freeze
152
-
153
- headers = { :"x-goog-api-client" => google_api_client }
154
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
155
- headers[:"x-goog-user-project"] = credentials.quota_project_id
156
- end
157
- headers.merge!(metadata) unless metadata.nil?
158
- client_config_file = Pathname.new(__dir__).join(
159
- "trace_service_client_config.json"
160
- )
161
- defaults = client_config_file.open do |f|
162
- Google::Gax.construct_settings(
163
- "google.devtools.cloudtrace.v1.TraceService",
164
- JSON.parse(f.read),
165
- client_config,
166
- Google::Gax::Grpc::STATUS_CODE_NAMES,
167
- timeout,
168
- page_descriptors: PAGE_DESCRIPTORS,
169
- errors: Google::Gax::Grpc::API_ERRORS,
170
- metadata: headers
171
- )
172
- end
173
-
174
- # Allow overriding the service path/port in subclasses.
175
- service_path = service_address || self.class::SERVICE_ADDRESS
176
- port = service_port || self.class::DEFAULT_SERVICE_PORT
177
- interceptors = self.class::GRPC_INTERCEPTORS
178
- @trace_service_stub = Google::Gax::Grpc.create_stub(
179
- service_path,
180
- port,
181
- chan_creds: chan_creds,
182
- channel: channel,
183
- updater_proc: updater_proc,
184
- scopes: scopes,
185
- interceptors: interceptors,
186
- &Google::Devtools::Cloudtrace::V1::TraceService::Stub.method(:new)
187
- )
188
-
189
- @patch_traces = Google::Gax.create_api_call(
190
- @trace_service_stub.method(:patch_traces),
191
- defaults["patch_traces"],
192
- exception_transformer: exception_transformer,
193
- params_extractor: proc do |request|
194
- {'project_id' => request.project_id}
195
- end
196
- )
197
- @list_traces = Google::Gax.create_api_call(
198
- @trace_service_stub.method(:list_traces),
199
- defaults["list_traces"],
200
- exception_transformer: exception_transformer,
201
- params_extractor: proc do |request|
202
- {'project_id' => request.project_id}
203
- end
204
- )
205
- @get_trace = Google::Gax.create_api_call(
206
- @trace_service_stub.method(:get_trace),
207
- defaults["get_trace"],
208
- exception_transformer: exception_transformer
209
- )
210
- end
211
-
212
- # Service calls
213
-
214
- # Sends new traces to Stackdriver Trace or updates existing traces. If the ID
215
- # of a trace that you send matches that of an existing trace, any fields
216
- # in the existing trace and its spans are overwritten by the provided values,
217
- # and any new fields provided are merged with the existing trace data. If the
218
- # ID does not match, a new trace is created.
219
- #
220
- # @param project_id [String]
221
- # Required. ID of the Cloud project where the trace data is stored.
222
- # @param traces [Google::Devtools::Cloudtrace::V1::Traces | Hash]
223
- # Required. The body of the message.
224
- # A hash of the same form as `Google::Devtools::Cloudtrace::V1::Traces`
225
- # can also be provided.
226
- # @param options [Google::Gax::CallOptions]
227
- # Overrides the default settings for this call, e.g, timeout,
228
- # retries, etc.
229
- # @yield [result, operation] Access the result along with the RPC operation
230
- # @yieldparam result []
231
- # @yieldparam operation [GRPC::ActiveCall::Operation]
232
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
233
- # @example
234
- # require "google/cloud/trace"
235
- #
236
- # trace_client = Google::Cloud::Trace.new(version: :v1)
237
- #
238
- # # TODO: Initialize `project_id`:
239
- # project_id = ''
240
- #
241
- # # TODO: Initialize `traces`:
242
- # traces = {}
243
- # trace_client.patch_traces(project_id, traces)
244
-
245
- def patch_traces \
246
- project_id,
247
- traces,
248
- options: nil,
249
- &block
250
- req = {
251
- project_id: project_id,
252
- traces: traces
253
- }.delete_if { |_, v| v.nil? }
254
- req = Google::Gax::to_proto(req, Google::Devtools::Cloudtrace::V1::PatchTracesRequest)
255
- @patch_traces.call(req, options, &block)
256
- nil
257
- end
258
-
259
- # Returns of a list of traces that match the specified filter conditions.
260
- #
261
- # @param project_id [String]
262
- # Required. ID of the Cloud project where the trace data is stored.
263
- # @param view [Google::Devtools::Cloudtrace::V1::ListTracesRequest::ViewType]
264
- # Optional. Type of data returned for traces in the list. Default is
265
- # `MINIMAL`.
266
- # @param page_size [Integer]
267
- # The maximum number of resources contained in the underlying API
268
- # response. If page streaming is performed per-resource, this
269
- # parameter does not affect the return value. If page streaming is
270
- # performed per-page, this determines the maximum number of
271
- # resources in a page.
272
- # @param start_time [Google::Protobuf::Timestamp | Hash]
273
- # Start of the time interval (inclusive) during which the trace data was
274
- # collected from the application.
275
- # A hash of the same form as `Google::Protobuf::Timestamp`
276
- # can also be provided.
277
- # @param end_time [Google::Protobuf::Timestamp | Hash]
278
- # End of the time interval (inclusive) during which the trace data was
279
- # collected from the application.
280
- # A hash of the same form as `Google::Protobuf::Timestamp`
281
- # can also be provided.
282
- # @param filter [String]
283
- # Optional. A filter against labels for the request.
284
- #
285
- # By default, searches use prefix matching. To specify exact match, prepend
286
- # a plus symbol (`+`) to the search term.
287
- # Multiple terms are ANDed. Syntax:
288
- #
289
- # * `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any root
290
- # span starts with `NAME_PREFIX`.
291
- # * `+root:NAME` or `+NAME`: Return traces where any root span's name is
292
- # exactly `NAME`.
293
- # * `span:NAME_PREFIX`: Return traces where any span starts with
294
- # `NAME_PREFIX`.
295
- # * `+span:NAME`: Return traces where any span's name is exactly
296
- # `NAME`.
297
- # * `latency:DURATION`: Return traces whose overall latency is
298
- # greater or equal to than `DURATION`. Accepted units are nanoseconds
299
- # (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For
300
- # example, `latency:24ms` returns traces whose overall latency
301
- # is greater than or equal to 24 milliseconds.
302
- # * `label:LABEL_KEY`: Return all traces containing the specified
303
- # label key (exact match, case-sensitive) regardless of the key:value
304
- # pair's value (including empty values).
305
- # * `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the specified
306
- # label key (exact match, case-sensitive) whose value starts with
307
- # `VALUE_PREFIX`. Both a key and a value must be specified.
308
- # * `+LABEL_KEY:VALUE`: Return all traces containing a key:value pair
309
- # exactly matching the specified text. Both a key and a value must be
310
- # specified.
311
- # * `method:VALUE`: Equivalent to `/http/method:VALUE`.
312
- # * `url:VALUE`: Equivalent to `/http/url:VALUE`.
313
- # @param order_by [String]
314
- # Optional. Field used to sort the returned traces.
315
- # Can be one of the following:
316
- #
317
- # * `trace_id`
318
- # * `name` (`name` field of root span in the trace)
319
- # * `duration` (difference between `end_time` and `start_time` fields of
320
- # the root span)
321
- # * `start` (`start_time` field of the root span)
322
- #
323
- # Descending order can be specified by appending `desc` to the sort field
324
- # (for example, `name desc`).
325
- #
326
- # Only one sort field is permitted.
327
- # @param options [Google::Gax::CallOptions]
328
- # Overrides the default settings for this call, e.g, timeout,
329
- # retries, etc.
330
- # @yield [result, operation] Access the result along with the RPC operation
331
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Devtools::Cloudtrace::V1::Trace>]
332
- # @yieldparam operation [GRPC::ActiveCall::Operation]
333
- # @return [Google::Gax::PagedEnumerable<Google::Devtools::Cloudtrace::V1::Trace>]
334
- # An enumerable of Google::Devtools::Cloudtrace::V1::Trace instances.
335
- # See Google::Gax::PagedEnumerable documentation for other
336
- # operations such as per-page iteration or access to the response
337
- # object.
338
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
339
- # @example
340
- # require "google/cloud/trace"
341
- #
342
- # trace_client = Google::Cloud::Trace.new(version: :v1)
343
- #
344
- # # TODO: Initialize `project_id`:
345
- # project_id = ''
346
- #
347
- # # Iterate over all results.
348
- # trace_client.list_traces(project_id).each do |element|
349
- # # Process element.
350
- # end
351
- #
352
- # # Or iterate over results one page at a time.
353
- # trace_client.list_traces(project_id).each_page do |page|
354
- # # Process each page at a time.
355
- # page.each do |element|
356
- # # Process element.
357
- # end
358
- # end
359
-
360
- def list_traces \
361
- project_id,
362
- view: nil,
363
- page_size: nil,
364
- start_time: nil,
365
- end_time: nil,
366
- filter: nil,
367
- order_by: nil,
368
- options: nil,
369
- &block
370
- req = {
371
- project_id: project_id,
372
- view: view,
373
- page_size: page_size,
374
- start_time: start_time,
375
- end_time: end_time,
376
- filter: filter,
377
- order_by: order_by
378
- }.delete_if { |_, v| v.nil? }
379
- req = Google::Gax::to_proto(req, Google::Devtools::Cloudtrace::V1::ListTracesRequest)
380
- @list_traces.call(req, options, &block)
381
- end
382
-
383
- # Gets a single trace by its ID.
384
- #
385
- # @param project_id [String]
386
- # Required. ID of the Cloud project where the trace data is stored.
387
- # @param trace_id [String]
388
- # Required. ID of the trace to return.
389
- # @param options [Google::Gax::CallOptions]
390
- # Overrides the default settings for this call, e.g, timeout,
391
- # retries, etc.
392
- # @yield [result, operation] Access the result along with the RPC operation
393
- # @yieldparam result [Google::Devtools::Cloudtrace::V1::Trace]
394
- # @yieldparam operation [GRPC::ActiveCall::Operation]
395
- # @return [Google::Devtools::Cloudtrace::V1::Trace]
396
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
397
- # @example
398
- # require "google/cloud/trace"
399
- #
400
- # trace_client = Google::Cloud::Trace.new(version: :v1)
401
- #
402
- # # TODO: Initialize `project_id`:
403
- # project_id = ''
404
- #
405
- # # TODO: Initialize `trace_id`:
406
- # trace_id = ''
407
- # response = trace_client.get_trace(project_id, trace_id)
408
-
409
- def get_trace \
410
- project_id,
411
- trace_id,
412
- options: nil,
413
- &block
414
- req = {
415
- project_id: project_id,
416
- trace_id: trace_id
417
- }.delete_if { |_, v| v.nil? }
418
- req = Google::Gax::to_proto(req, Google::Devtools::Cloudtrace::V1::GetTraceRequest)
419
- @get_trace.call(req, options, &block)
420
- end
421
- end
422
- end
423
- end
424
- end
425
- end
@@ -1,41 +0,0 @@
1
- {
2
- "interfaces": {
3
- "google.devtools.cloudtrace.v1.TraceService": {
4
- "retry_codes": {
5
- "idempotent": [
6
- "DEADLINE_EXCEEDED",
7
- "UNAVAILABLE"
8
- ],
9
- "non_idempotent": []
10
- },
11
- "retry_params": {
12
- "default": {
13
- "initial_retry_delay_millis": 100,
14
- "retry_delay_multiplier": 1.2,
15
- "max_retry_delay_millis": 1000,
16
- "initial_rpc_timeout_millis": 20000,
17
- "rpc_timeout_multiplier": 1.5,
18
- "max_rpc_timeout_millis": 30000,
19
- "total_timeout_millis": 45000
20
- }
21
- },
22
- "methods": {
23
- "PatchTraces": {
24
- "timeout_millis": 60000,
25
- "retry_codes_name": "idempotent",
26
- "retry_params_name": "default"
27
- },
28
- "ListTraces": {
29
- "timeout_millis": 60000,
30
- "retry_codes_name": "idempotent",
31
- "retry_params_name": "default"
32
- },
33
- "GetTrace": {
34
- "timeout_millis": 60000,
35
- "retry_codes_name": "idempotent",
36
- "retry_params_name": "default"
37
- }
38
- }
39
- }
40
- }
41
- }