google-cloud-trace 0.39.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +24 -0
  4. data/lib/google-cloud-trace.rb +20 -12
  5. data/lib/google/cloud/trace.rb +18 -14
  6. data/lib/google/cloud/trace/credentials.rb +2 -2
  7. data/lib/google/cloud/trace/result_set.rb +20 -12
  8. data/lib/google/cloud/trace/service.rb +34 -60
  9. data/lib/google/cloud/trace/span.rb +3 -3
  10. data/lib/google/cloud/trace/trace_record.rb +3 -3
  11. data/lib/google/cloud/trace/version.rb +1 -1
  12. metadata +15 -64
  13. data/lib/google/cloud/trace/v1.rb +0 -16
  14. data/lib/google/cloud/trace/v1/credentials.rb +0 -39
  15. data/lib/google/cloud/trace/v1/doc/google/devtools/cloudtrace/v1/trace.rb +0 -253
  16. data/lib/google/cloud/trace/v1/doc/google/protobuf/empty.rb +0 -29
  17. data/lib/google/cloud/trace/v1/doc/google/protobuf/timestamp.rb +0 -113
  18. data/lib/google/cloud/trace/v1/trace_service_client.rb +0 -425
  19. data/lib/google/cloud/trace/v1/trace_service_client_config.json +0 -41
  20. data/lib/google/cloud/trace/v2.rb +0 -123
  21. data/lib/google/cloud/trace/v2/credentials.rb +0 -39
  22. data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/trace.rb +0 -356
  23. data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/tracing.rb +0 -33
  24. data/lib/google/cloud/trace/v2/doc/google/protobuf/any.rb +0 -131
  25. data/lib/google/cloud/trace/v2/doc/google/protobuf/empty.rb +0 -29
  26. data/lib/google/cloud/trace/v2/doc/google/protobuf/timestamp.rb +0 -113
  27. data/lib/google/cloud/trace/v2/doc/google/protobuf/wrappers.rb +0 -34
  28. data/lib/google/cloud/trace/v2/doc/google/rpc/status.rb +0 -39
  29. data/lib/google/cloud/trace/v2/trace_service_client.rb +0 -418
  30. data/lib/google/cloud/trace/v2/trace_service_client_config.json +0 -36
  31. data/lib/google/devtools/cloudtrace/v1/trace_pb.rb +0 -82
  32. data/lib/google/devtools/cloudtrace/v1/trace_services_pb.rb +0 -58
  33. data/lib/google/devtools/cloudtrace/v2/trace_pb.rb +0 -142
  34. data/lib/google/devtools/cloudtrace/v2/tracing_pb.rb +0 -29
  35. data/lib/google/devtools/cloudtrace/v2/tracing_services_pb.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f15f8177b7c46712bfa65de95e962f1d33ee86e7772af0252fa0f992f842095
4
- data.tar.gz: d2eef2c11e859c11a73a573a95a10f9b755d230770b9c91f5ed758ddbefdb3b5
3
+ metadata.gz: b07562091331ce0fc0545ba69eb4dd28c878416fd1db5f3a6f0134b2070b548b
4
+ data.tar.gz: 2274912890a1bb15293e2121c3ce4e1e694a430919c0290624cf929683522895
5
5
  SHA512:
6
- metadata.gz: 921009ab5e7b4c391fc663d5f2e9c81c5122b4101d53f13664a89bdae60ac2cf115f684d6fe6950df36ad5d77d688ab74c45adf2c818e0740d5f145ba61269cf
7
- data.tar.gz: c4536a16227854be8b0dbb8cc42b3741cbe3e52729bdb27b85e7dc032e224fd03ac95d1d9b6fe0594d61443bea50e3a8a8c3b9319bc18597c3a3e33ec361a42b
6
+ metadata.gz: 42f181e09853565ae566548c08dfc69f88c727cfbec9b77663c21889d8c6ded86eff582471c31cceba816d47f0ba6f326773408c7ec87671949bf137c1d2f470
7
+ data.tar.gz: 706749ea6b9625ea23243e16540666d8e4e1855ceb832f45c7dfd7069cde78b9fbab5f76ec9846ed598e7bda3468224172271db7c77fbe95f91501f3f5944fb4
@@ -76,7 +76,7 @@ The environment variables that google-cloud-trace checks for project ID are:
76
76
  1. `TRACE_PROJECT`
77
77
  2. `GOOGLE_CLOUD_PROJECT`
78
78
 
79
- The environment variables that google-cloud-trace checks for credentials are configured on {Google::Cloud::Trace::V2::Credentials}:
79
+ The environment variables that google-cloud-trace checks for credentials are configured on {Google::Cloud::Trace::Credentials}:
80
80
 
81
81
  1. `TRACE_CREDENTIALS` - Path to JSON file, or JSON contents
82
82
  2. `TRACE_KEYFILE` - Path to JSON file, or JSON contents
@@ -1,5 +1,29 @@
1
1
  # Release History
2
2
 
3
+ ### 0.40.0 / 2020-07-23
4
+
5
+ This is a major update that removes the "low-level" client interface code, and
6
+ instead adds the new gems `google-cloud-trace-v1` and `google-cloud-trace-v2`,
7
+ as dependencies.
8
+ The new dependencies are rewritten low-level clients, produced by a next-
9
+ generation client code generator, with improved performance and stability.
10
+
11
+ This change should have no effect on the high-level interface that most users
12
+ will use. The one exception is that the (mostly undocumented) `client_config`
13
+ argument, for adjusting low-level parameters such as RPC retry settings on
14
+ client objects, has been removed. If you need to adjust these parameters, use
15
+ the configuration interface in low-level clients.
16
+
17
+ Substantial changes have been made in the low-level interfaces, however. If you
18
+ are using the low-level classes under the old `Google::Devtools::Cloudtrace`,
19
+ `Google::Cloud::Trace::V1`, or `Google::Cloud::Trace::V2` modules, please
20
+ review the docs for the new low-level gems to see usage changes. In particular:
21
+
22
+ * Some classes have been renamed, notably the client class itself.
23
+ * The client constructor takes a configuration block instead of configuration
24
+ keyword arguments.
25
+ * All RPC method arguments are now keyword arguments.
26
+
3
27
  ### 0.39.0 / 2020-07-07
4
28
 
5
29
  #### Features
@@ -57,10 +57,9 @@ module Google
57
57
  # puts "Retrieved trace ID: #{trace.trace_id}"
58
58
  # end
59
59
  #
60
- def trace scope: nil, timeout: nil, client_config: nil
60
+ def trace scope: nil, timeout: nil
61
61
  Google::Cloud.trace @project, @keyfile, scope: scope,
62
- timeout: (timeout || @timeout),
63
- client_config: client_config
62
+ timeout: (timeout || @timeout)
64
63
  end
65
64
 
66
65
  ##
@@ -99,12 +98,15 @@ module Google
99
98
  # puts "Retrieved trace ID: #{trace.trace_id}"
100
99
  # end
101
100
  #
102
- def self.trace project_id = nil, credentials = nil, scope: nil,
103
- timeout: nil, client_config: nil
101
+ def self.trace project_id = nil,
102
+ credentials = nil,
103
+ scope: nil,
104
+ timeout: nil
104
105
  require "google/cloud/trace"
105
- Google::Cloud::Trace.new project_id: project_id, credentials: credentials,
106
- scope: scope, timeout: timeout,
107
- client_config: client_config
106
+ Google::Cloud::Trace.new project_id: project_id,
107
+ credentials: credentials,
108
+ scope: scope,
109
+ timeout: timeout
108
110
  end
109
111
  end
110
112
  end
@@ -127,17 +129,23 @@ Google::Cloud.configure.add_config! :trace do |config|
127
129
  "TRACE_KEYFILE", "TRACE_KEYFILE_JSON"
128
130
  )
129
131
  end
132
+ endpoint = "cloudtrace.googleapis.com".freeze
133
+ scopes = [
134
+ "https://www.googleapis.com/auth/cloud-platform",
135
+ "https://www.googleapis.com/auth/trace.append",
136
+ "https://www.googleapis.com/auth/trace.readonly"
137
+ ].freeze
130
138
 
131
139
  config.add_field! :project_id, default_project, match: String, allow_nil: true
132
140
  config.add_alias! :project, :project_id
133
- config.add_field! :credentials, default_creds,
141
+ config.add_field! :credentials,
142
+ default_creds,
134
143
  match: [String, Hash, Google::Auth::Credentials],
135
144
  allow_nil: true
136
145
  config.add_alias! :keyfile, :credentials
137
- config.add_field! :scope, nil, match: [String, Array]
146
+ config.add_field! :scope, scopes, match: [String, Array]
138
147
  config.add_field! :timeout, nil, match: Integer
139
- config.add_field! :client_config, nil, match: Hash
140
- config.add_field! :endpoint, nil, match: String
148
+ config.add_field! :endpoint, endpoint, match: String
141
149
  config.add_field! :capture_stack, nil, enum: [true, false]
142
150
  config.add_field! :sampler, nil
143
151
  config.add_field! :span_id_generator, nil, match: Proc
@@ -68,8 +68,6 @@ module Google
68
68
  # * `https://www.googleapis.com/auth/cloud-platform`
69
69
  #
70
70
  # @param [Integer] timeout Default timeout to use in requests. Optional.
71
- # @param [Hash] client_config A hash of values to override the default
72
- # behavior of the API client. Optional.
73
71
  # @param [String] endpoint Override of the endpoint host name. Optional.
74
72
  # If the param is nil, uses the default endpoint.
75
73
  # @param [String] project Alias for the `project_id` argument. Deprecated.
@@ -88,12 +86,16 @@ module Google
88
86
  # puts "Retrieved trace ID: #{trace.trace_id}"
89
87
  # end
90
88
  #
91
- def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
92
- client_config: nil, endpoint: nil, project: nil, keyfile: nil
89
+ def self.new project_id: nil,
90
+ credentials: nil,
91
+ scope: nil,
92
+ timeout: nil,
93
+ endpoint: nil,
94
+ project: nil,
95
+ keyfile: nil
93
96
  project_id ||= (project || default_project_id)
94
97
  scope ||= configure.scope
95
98
  timeout ||= configure.timeout
96
- client_config ||= configure.client_config
97
99
  endpoint ||= configure.endpoint
98
100
  credentials ||= (keyfile || default_credentials(scope: scope))
99
101
 
@@ -104,12 +106,8 @@ module Google
104
106
  project_id = project_id.to_s # Always cast to a string
105
107
  raise ArgumentError, "project_id is missing" if project_id.empty?
106
108
 
107
- Trace::Project.new(
108
- Trace::Service.new(
109
- project_id, credentials,
110
- host: endpoint, timeout: timeout, client_config: client_config
111
- )
112
- )
109
+ service = Trace::Service.new project_id, credentials, host: endpoint, timeout: timeout
110
+ Trace::Project.new service
113
111
  end
114
112
 
115
113
  ##
@@ -128,8 +126,6 @@ module Google
128
126
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
129
127
  # the set of resources and operations that the connection can access.
130
128
  # * `timeout` - (Integer) Default timeout to use in requests.
131
- # * `client_config` - (Hash) A hash of values to override the default
132
- # behavior of the API client.
133
129
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
134
130
  # to use the default endpoint.
135
131
  # * `capture_stack` - (Boolean) Whether to capture stack traces for each
@@ -267,7 +263,8 @@ module Google
267
263
  # end
268
264
  # end
269
265
  #
270
- def self.in_span name, kind: Google::Cloud::Trace::SpanKind::UNSPECIFIED,
266
+ def self.in_span name,
267
+ kind: Google::Cloud::Trace::SpanKind::UNSPECIFIED,
271
268
  labels: {}
272
269
  parent = get
273
270
  if parent
@@ -285,4 +282,11 @@ module Google
285
282
  end
286
283
  end
287
284
  end
285
+
286
+ # Aliases for compatibility with older spellings.
287
+ # @private
288
+ module Devtools
289
+ # @private
290
+ Cloudtrace = ::Google::Cloud::Trace unless const_defined? :Cloudtrace
291
+ end
288
292
  end
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "google/cloud/trace/v1/credentials"
16
+ require "google/cloud/trace/v1/trace_service/credentials"
17
17
 
18
18
  module Google
19
19
  module Cloud
@@ -37,7 +37,7 @@ module Google
37
37
  #
38
38
  # trace.project_id #=> "my-project"
39
39
  #
40
- class Credentials < Google::Cloud::Trace::V1::Credentials
40
+ class Credentials < Google::Cloud::Trace::V1::TraceService::Credentials
41
41
  end
42
42
  end
43
43
  end
@@ -158,7 +158,9 @@ module Google
158
158
  def next_page
159
159
  return nil unless results_pending?
160
160
  service.list_traces \
161
- project, start_time, end_time,
161
+ project,
162
+ start_time,
163
+ end_time,
162
164
  filter: filter,
163
165
  order_by: order_by,
164
166
  view: view,
@@ -167,26 +169,32 @@ module Google
167
169
  end
168
170
 
169
171
  ##
170
- # Create a new ResultSet given a Google::Gax::PagedEnumerable::Page,
172
+ # Create a new ResultSet given a Gapic::PagedEnumerable::Page,
171
173
  # and all the query parameters.
172
174
  #
173
175
  # @private
174
176
  #
175
- def self.from_gax_page service, project_id,
176
- page, start_time, end_time,
177
- filter: nil,
178
- order_by: nil,
179
- view: nil,
180
- page_size: nil,
181
- page_token: nil
177
+ def self.from_gapic_page service,
178
+ project_id,
179
+ page,
180
+ start_time,
181
+ end_time,
182
+ filter: nil,
183
+ order_by: nil,
184
+ view: nil,
185
+ page_size: nil,
186
+ page_token: nil
182
187
  next_page_token = page.next_page_token
183
188
  next_page_token = nil unless page.next_page_token?
184
189
  results = page.map do |proto|
185
190
  Google::Cloud::Trace::TraceRecord.from_grpc proto
186
191
  end
187
- new service, project_id,
188
- results, next_page_token,
189
- start_time, end_time,
192
+ new service,
193
+ project_id,
194
+ results,
195
+ next_page_token,
196
+ start_time,
197
+ end_time,
190
198
  filter: filter,
191
199
  order_by: order_by,
192
200
  view: view,
@@ -16,7 +16,6 @@
16
16
  require "google/cloud/errors"
17
17
  require "google/cloud/trace/version"
18
18
  require "google/cloud/trace/v1"
19
- require "google/gax/errors"
20
19
  require "uri"
21
20
 
22
21
  module Google
@@ -28,17 +27,18 @@ module Google
28
27
  # @private
29
28
  #
30
29
  class Service
31
- attr_accessor :project, :credentials, :timeout, :client_config, :host
30
+ attr_accessor :project, :credentials, :timeout, :host
32
31
 
33
32
  ##
34
33
  # Creates a new Service instance.
35
- def initialize project, credentials, timeout: nil, client_config: nil,
34
+ def initialize project,
35
+ credentials,
36
+ timeout: nil,
36
37
  host: nil
37
38
  @project = project
38
39
  @credentials = credentials
39
40
  @timeout = timeout
40
- @client_config = client_config || {}
41
- @host = host || V1::TraceServiceClient::SERVICE_ADDRESS
41
+ @host = host
42
42
  end
43
43
 
44
44
  def lowlevel_client
@@ -50,15 +50,13 @@ module Google
50
50
  require "google/cloud/trace/patches/active_call_with_trace"
51
51
  require "google/cloud/trace/patches/call_with_trace"
52
52
 
53
- V1::TraceServiceClient.new(
54
- credentials: credentials,
55
- timeout: timeout,
56
- client_config: client_config,
57
- service_address: service_address,
58
- service_port: service_port,
59
- lib_name: "gccl",
60
- lib_version: Google::Cloud::Trace::VERSION
61
- )
53
+ V1::TraceService::Client.new do |config|
54
+ config.credentials = credentials if credentials
55
+ config.timeout = timeout if timeout
56
+ config.endpoint = host if host
57
+ config.lib_name = "gccl"
58
+ config.lib_version = Google::Cloud::Trace::VERSION
59
+ end
62
60
  end
63
61
  end
64
62
  attr_accessor :mocked_lowlevel_client
@@ -67,55 +65,50 @@ module Google
67
65
  # Sends new traces to Stackdriver Trace or updates existing traces.
68
66
  def patch_traces traces
69
67
  traces = Array(traces)
70
- traces_proto = Google::Devtools::Cloudtrace::V1::Traces.new
68
+ traces_proto = Google::Cloud::Trace::V1::Traces.new
71
69
  traces.each do |trace|
72
70
  traces_proto.traces.push trace.to_grpc
73
71
  end
74
- execute do
75
- lowlevel_client.patch_traces @project, traces_proto
76
- end
72
+
73
+ lowlevel_client.patch_traces project_id: @project, traces: traces_proto
77
74
  traces
78
75
  end
79
76
 
80
77
  ##
81
78
  # Returns a trace given its ID
82
79
  def get_trace trace_id
83
- trace_proto = execute do
84
- lowlevel_client.get_trace @project, trace_id
85
- end
80
+ trace_proto = lowlevel_client.get_trace project_id: @project, trace_id: trace_id
86
81
  Google::Cloud::Trace::TraceRecord.from_grpc trace_proto
87
82
  end
88
83
 
89
84
  ##
90
85
  # Searches for traces matching the given criteria.
91
86
  #
92
- def list_traces project_id, start_time, end_time,
87
+ def list_traces project_id,
88
+ start_time,
89
+ end_time,
93
90
  filter: nil,
94
91
  order_by: nil,
95
92
  view: nil,
96
93
  page_size: nil,
97
94
  page_token: nil
98
- call_opts = if page_token
99
- Google::Gax::CallOptions.new page_token: page_token
100
- else
101
- Google::Gax::CallOptions.new
102
- end
103
95
  start_proto = Google::Cloud::Trace::Utils.time_to_grpc start_time
104
96
  end_proto = Google::Cloud::Trace::Utils.time_to_grpc end_time
105
- paged_enum = execute do
106
- lowlevel_client.list_traces project_id,
107
- view: view,
108
- page_size: page_size,
109
- start_time: start_proto,
110
- end_time: end_proto,
111
- filter: filter,
112
- order_by: order_by,
113
- options: call_opts
114
- end
115
-
116
- Google::Cloud::Trace::ResultSet.from_gax_page \
117
- self, project_id,
118
- paged_enum.page, start_time, end_time,
97
+ paged_enum = lowlevel_client.list_traces project_id: project_id,
98
+ view: view,
99
+ page_size: page_size,
100
+ start_time: start_proto,
101
+ end_time: end_proto,
102
+ filter: filter,
103
+ order_by: order_by,
104
+ page_token: page_token
105
+
106
+ Google::Cloud::Trace::ResultSet.from_gapic_page \
107
+ self,
108
+ project_id,
109
+ paged_enum.page,
110
+ start_time,
111
+ end_time,
119
112
  filter: filter,
120
113
  order_by: order_by,
121
114
  view: view,
@@ -127,25 +120,6 @@ module Google
127
120
  def inspect
128
121
  "#{self.class}(#{@project})"
129
122
  end
130
-
131
- protected
132
-
133
- def service_address
134
- return nil if host.nil?
135
- URI.parse("//#{host}").host
136
- end
137
-
138
- def service_port
139
- return nil if host.nil?
140
- URI.parse("//#{host}").port
141
- end
142
-
143
- def execute
144
- yield
145
- rescue Google::Gax::GaxError => e
146
- # GaxError wraps BadStatus, but exposes it as #cause
147
- raise Google::Cloud::Error.from_error(e.cause)
148
- end
149
123
  end
150
124
  end
151
125
  end
@@ -140,7 +140,7 @@ module Google
140
140
  # Create a new Span object from a TraceSpan protobuf and insert it
141
141
  # into the given trace.
142
142
  #
143
- # @param [Google::Devtools::Cloudtrace::V1::TraceSpan] span_proto The
143
+ # @param [Google::Cloud::Trace::V1::Tracespan] span_proto The
144
144
  # span protobuf from the V1 gRPC Trace API.
145
145
  # @param [Google::Cloud::Trace::TraceRecord] trace The trace object
146
146
  # to contain the span.
@@ -169,13 +169,13 @@ module Google
169
169
  #
170
170
  # @param [Integer] default_parent_id The parent span ID to use if the
171
171
  # span has no parent in the trace tree. Optional; defaults to 0.
172
- # @return [Google::Devtools::Cloudtrace::V1::TraceSpan] The generated
172
+ # @return [Google::Cloud::Trace::V1::TraceSpan] The generated
173
173
  # protobuf.
174
174
  #
175
175
  def to_grpc default_parent_id = 0
176
176
  start_proto = Google::Cloud::Trace::Utils.time_to_grpc start_time
177
177
  end_proto = Google::Cloud::Trace::Utils.time_to_grpc end_time
178
- Google::Devtools::Cloudtrace::V1::TraceSpan.new \
178
+ Google::Cloud::Trace::V1::TraceSpan.new \
179
179
  span_id: span_id.to_i,
180
180
  kind: kind.to_sym,
181
181
  name: name,
@@ -76,7 +76,7 @@ module Google
76
76
  ##
77
77
  # Create a new Trace object from a trace protobuf.
78
78
  #
79
- # @param [Google::Devtools::Cloudtrace::V1::Trace] trace_proto The
79
+ # @param [Google::Cloud::Trace::V1::Trace] trace_proto The
80
80
  # trace protobuf from the V1 gRPC Trace API.
81
81
  # @return [Trace, nil] A corresponding Trace object, or `nil` if the
82
82
  # proto does not represent an existing trace object.
@@ -104,14 +104,14 @@ module Google
104
104
  # Convert this Trace object to an equivalent Trace protobuf suitable
105
105
  # for the V1 gRPC Trace API.
106
106
  #
107
- # @return [Google::Devtools::Cloudtrace::V1::Trace] The generated
107
+ # @return [Google::Cloud::Trace::V1::Trace] The generated
108
108
  # protobuf.
109
109
  #
110
110
  def to_grpc
111
111
  span_protos = @spans_by_id.values.map do |span|
112
112
  span.to_grpc trace_context.span_id.to_i
113
113
  end
114
- Google::Devtools::Cloudtrace::V1::Trace.new \
114
+ Google::Cloud::Trace::V1::Trace.new \
115
115
  project_id: project_id,
116
116
  trace_id: trace_id,
117
117
  spans: span_protos