google-cloud-logging 1.5.1 → 1.5.2

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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/README.md +8 -8
  4. data/lib/google/cloud/logging/credentials.rb +2 -15
  5. data/lib/google/cloud/logging/v2/config_service_v2_client.rb +126 -65
  6. data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +13 -13
  7. data/lib/google/cloud/logging/v2/credentials.rb +38 -0
  8. data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +1 -1
  9. data/lib/google/cloud/logging/v2/doc/google/api/label.rb +1 -1
  10. data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +8 -12
  11. data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +28 -4
  12. data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +1 -1
  13. data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +18 -10
  14. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +11 -19
  15. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +3 -18
  16. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +1 -16
  17. data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +1 -1
  18. data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +1 -1
  19. data/lib/google/cloud/logging/v2/doc/google/protobuf/empty.rb +28 -0
  20. data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +1 -1
  21. data/lib/google/cloud/logging/v2/doc/google/protobuf/struct.rb +73 -0
  22. data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +1 -1
  23. data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +106 -67
  24. data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +12 -12
  25. data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +75 -45
  26. data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +6 -6
  27. data/lib/google/cloud/logging/version.rb +1 -1
  28. data/lib/google/logging/v2/log_entry_pb.rb +1 -0
  29. data/lib/google/logging/v2/logging_config_services_pb.rb +2 -2
  30. data/lib/google/logging/v2/logging_metrics_services_pb.rb +2 -2
  31. data/lib/google/logging/v2/logging_pb.rb +1 -0
  32. data/lib/google/logging/v2/logging_services_pb.rb +5 -4
  33. metadata +35 -5
  34. data/lib/google/cloud/logging/v2/doc/overview.rb +0 -66
@@ -12,21 +12,21 @@
12
12
  "retry_params": {
13
13
  "default": {
14
14
  "initial_retry_delay_millis": 100,
15
- "retry_delay_multiplier": 1.2,
16
- "max_retry_delay_millis": 1000,
15
+ "retry_delay_multiplier": 1.3,
16
+ "max_retry_delay_millis": 60000,
17
17
  "initial_rpc_timeout_millis": 20000,
18
- "rpc_timeout_multiplier": 1.5,
19
- "max_rpc_timeout_millis": 60000,
20
- "total_timeout_millis": 90000
18
+ "rpc_timeout_multiplier": 1.0,
19
+ "max_rpc_timeout_millis": 20000,
20
+ "total_timeout_millis": 600000
21
21
  },
22
22
  "list": {
23
23
  "initial_retry_delay_millis": 100,
24
- "retry_delay_multiplier": 1.2,
25
- "max_retry_delay_millis": 1000,
26
- "initial_rpc_timeout_millis": 2000,
27
- "rpc_timeout_multiplier": 1.5,
28
- "max_rpc_timeout_millis": 10000,
29
- "total_timeout_millis": 20000
24
+ "retry_delay_multiplier": 1.3,
25
+ "max_retry_delay_millis": 60000,
26
+ "initial_rpc_timeout_millis": 20000,
27
+ "rpc_timeout_multiplier": 1.0,
28
+ "max_rpc_timeout_millis": 20000,
29
+ "total_timeout_millis": 600000
30
30
  }
31
31
  },
32
32
  "methods": {
@@ -48,7 +48,7 @@
48
48
  "ListLogEntries": {
49
49
  "timeout_millis": 10000,
50
50
  "retry_codes_name": "idempotent",
51
- "retry_params_name": "list"
51
+ "retry_params_name": "default"
52
52
  },
53
53
  "ListMonitoredResourceDescriptors": {
54
54
  "timeout_millis": 60000,
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,9 +18,6 @@
18
18
  # and updates to that file get reflected here through a refresh process.
19
19
  # For the short term, the refresh process will only be runnable by Google
20
20
  # engineers.
21
- #
22
- # The only allowed edits are to method and file documentation. A 3-way
23
- # merge preserves those additions if the generated source changes.
24
21
 
25
22
  require "json"
26
23
  require "pathname"
@@ -28,7 +25,7 @@ require "pathname"
28
25
  require "google/gax"
29
26
 
30
27
  require "google/logging/v2/logging_metrics_pb"
31
- require "google/cloud/logging/credentials"
28
+ require "google/cloud/logging/v2/credentials"
32
29
 
33
30
  module Google
34
31
  module Cloud
@@ -47,6 +44,9 @@ module Google
47
44
  # The default port of the service.
48
45
  DEFAULT_SERVICE_PORT = 443
49
46
 
47
+ # The default set of gRPC interceptors.
48
+ GRPC_INTERCEPTORS = []
49
+
50
50
  DEFAULT_TIMEOUT = 30
51
51
 
52
52
  PAGE_DESCRIPTORS = {
@@ -68,6 +68,7 @@ module Google
68
68
  "https://www.googleapis.com/auth/logging.write"
69
69
  ].freeze
70
70
 
71
+
71
72
  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
72
73
  "projects/{project}"
73
74
  )
@@ -124,16 +125,18 @@ module Google
124
125
  # or the specified config is missing data points.
125
126
  # @param timeout [Numeric]
126
127
  # The default timeout, in seconds, for calls made through this client.
128
+ # @param metadata [Hash]
129
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
130
+ # @param exception_transformer [Proc]
131
+ # An optional proc that intercepts any exceptions raised during an API call to inject
132
+ # custom error handling.
127
133
  def initialize \
128
- service_path: SERVICE_ADDRESS,
129
- port: DEFAULT_SERVICE_PORT,
130
- channel: nil,
131
- chan_creds: nil,
132
- updater_proc: nil,
133
134
  credentials: nil,
134
135
  scopes: ALL_SCOPES,
135
136
  client_config: {},
136
137
  timeout: DEFAULT_TIMEOUT,
138
+ metadata: nil,
139
+ exception_transformer: nil,
137
140
  lib_name: nil,
138
141
  lib_version: ""
139
142
  # These require statements are intentionally placed here to initialize
@@ -142,21 +145,10 @@ module Google
142
145
  require "google/gax/grpc"
143
146
  require "google/logging/v2/logging_metrics_services_pb"
144
147
 
145
- if channel || chan_creds || updater_proc
146
- warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
147
- "on 2017/09/08"
148
- credentials ||= channel
149
- credentials ||= chan_creds
150
- credentials ||= updater_proc
151
- end
152
- if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
153
- warn "`service_path` and `port` parameters are deprecated and will be removed"
154
- end
155
-
156
- credentials ||= Google::Cloud::Logging::Credentials.default
148
+ credentials ||= Google::Cloud::Logging::V2::Credentials.default
157
149
 
158
150
  if credentials.is_a?(String) || credentials.is_a?(Hash)
159
- updater_proc = Google::Cloud::Logging::Credentials.new(credentials).updater_proc
151
+ updater_proc = Google::Cloud::Logging::V2::Credentials.new(credentials).updater_proc
160
152
  end
161
153
  if credentials.is_a?(GRPC::Core::Channel)
162
154
  channel = credentials
@@ -171,13 +163,16 @@ module Google
171
163
  updater_proc = credentials.updater_proc
172
164
  end
173
165
 
166
+ package_version = Gem.loaded_specs['google-cloud-logging'].version.version
167
+
174
168
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
175
169
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
176
- google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
170
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
177
171
  google_api_client << " grpc/#{GRPC::VERSION}"
178
172
  google_api_client.freeze
179
173
 
180
174
  headers = { :"x-goog-api-client" => google_api_client }
175
+ headers.merge!(metadata) unless metadata.nil?
181
176
  client_config_file = Pathname.new(__dir__).join(
182
177
  "metrics_service_v2_client_config.json"
183
178
  )
@@ -190,9 +185,14 @@ module Google
190
185
  timeout,
191
186
  page_descriptors: PAGE_DESCRIPTORS,
192
187
  errors: Google::Gax::Grpc::API_ERRORS,
193
- kwargs: headers
188
+ metadata: headers
194
189
  )
195
190
  end
191
+
192
+ # Allow overriding the service path/port in subclasses.
193
+ service_path = self.class::SERVICE_ADDRESS
194
+ port = self.class::DEFAULT_SERVICE_PORT
195
+ interceptors = self.class::GRPC_INTERCEPTORS
196
196
  @metrics_service_v2_stub = Google::Gax::Grpc.create_stub(
197
197
  service_path,
198
198
  port,
@@ -200,28 +200,34 @@ module Google
200
200
  channel: channel,
201
201
  updater_proc: updater_proc,
202
202
  scopes: scopes,
203
+ interceptors: interceptors,
203
204
  &Google::Logging::V2::MetricsServiceV2::Stub.method(:new)
204
205
  )
205
206
 
206
207
  @list_log_metrics = Google::Gax.create_api_call(
207
208
  @metrics_service_v2_stub.method(:list_log_metrics),
208
- defaults["list_log_metrics"]
209
+ defaults["list_log_metrics"],
210
+ exception_transformer: exception_transformer
209
211
  )
210
212
  @get_log_metric = Google::Gax.create_api_call(
211
213
  @metrics_service_v2_stub.method(:get_log_metric),
212
- defaults["get_log_metric"]
214
+ defaults["get_log_metric"],
215
+ exception_transformer: exception_transformer
213
216
  )
214
217
  @create_log_metric = Google::Gax.create_api_call(
215
218
  @metrics_service_v2_stub.method(:create_log_metric),
216
- defaults["create_log_metric"]
219
+ defaults["create_log_metric"],
220
+ exception_transformer: exception_transformer
217
221
  )
218
222
  @update_log_metric = Google::Gax.create_api_call(
219
223
  @metrics_service_v2_stub.method(:update_log_metric),
220
- defaults["update_log_metric"]
224
+ defaults["update_log_metric"],
225
+ exception_transformer: exception_transformer
221
226
  )
222
227
  @delete_log_metric = Google::Gax.create_api_call(
223
228
  @metrics_service_v2_stub.method(:delete_log_metric),
224
- defaults["delete_log_metric"]
229
+ defaults["delete_log_metric"],
230
+ exception_transformer: exception_transformer
225
231
  )
226
232
  end
227
233
 
@@ -242,6 +248,9 @@ module Google
242
248
  # @param options [Google::Gax::CallOptions]
243
249
  # Overrides the default settings for this call, e.g, timeout,
244
250
  # retries, etc.
251
+ # @yield [result, operation] Access the result along with the RPC operation
252
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Logging::V2::LogMetric>]
253
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
245
254
  # @return [Google::Gax::PagedEnumerable<Google::Logging::V2::LogMetric>]
246
255
  # An enumerable of Google::Logging::V2::LogMetric instances.
247
256
  # See Google::Gax::PagedEnumerable documentation for other
@@ -251,7 +260,7 @@ module Google
251
260
  # @example
252
261
  # require "google/cloud/logging/v2"
253
262
  #
254
- # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
263
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
255
264
  # formatted_parent = Google::Cloud::Logging::V2::MetricsServiceV2Client.project_path("[PROJECT]")
256
265
  #
257
266
  # # Iterate over all results.
@@ -270,13 +279,14 @@ module Google
270
279
  def list_log_metrics \
271
280
  parent,
272
281
  page_size: nil,
273
- options: nil
282
+ options: nil,
283
+ &block
274
284
  req = {
275
285
  parent: parent,
276
286
  page_size: page_size
277
287
  }.delete_if { |_, v| v.nil? }
278
288
  req = Google::Gax::to_proto(req, Google::Logging::V2::ListLogMetricsRequest)
279
- @list_log_metrics.call(req, options)
289
+ @list_log_metrics.call(req, options, &block)
280
290
  end
281
291
 
282
292
  # Gets a logs-based metric.
@@ -288,23 +298,27 @@ module Google
288
298
  # @param options [Google::Gax::CallOptions]
289
299
  # Overrides the default settings for this call, e.g, timeout,
290
300
  # retries, etc.
301
+ # @yield [result, operation] Access the result along with the RPC operation
302
+ # @yieldparam result [Google::Logging::V2::LogMetric]
303
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
291
304
  # @return [Google::Logging::V2::LogMetric]
292
305
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
293
306
  # @example
294
307
  # require "google/cloud/logging/v2"
295
308
  #
296
- # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
309
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
297
310
  # formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
298
311
  # response = metrics_service_v2_client.get_log_metric(formatted_metric_name)
299
312
 
300
313
  def get_log_metric \
301
314
  metric_name,
302
- options: nil
315
+ options: nil,
316
+ &block
303
317
  req = {
304
318
  metric_name: metric_name
305
319
  }.delete_if { |_, v| v.nil? }
306
320
  req = Google::Gax::to_proto(req, Google::Logging::V2::GetLogMetricRequest)
307
- @get_log_metric.call(req, options)
321
+ @get_log_metric.call(req, options, &block)
308
322
  end
309
323
 
310
324
  # Creates a logs-based metric.
@@ -323,26 +337,32 @@ module Google
323
337
  # @param options [Google::Gax::CallOptions]
324
338
  # Overrides the default settings for this call, e.g, timeout,
325
339
  # retries, etc.
340
+ # @yield [result, operation] Access the result along with the RPC operation
341
+ # @yieldparam result [Google::Logging::V2::LogMetric]
342
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
326
343
  # @return [Google::Logging::V2::LogMetric]
327
344
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
328
345
  # @example
329
346
  # require "google/cloud/logging/v2"
330
347
  #
331
- # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
348
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
332
349
  # formatted_parent = Google::Cloud::Logging::V2::MetricsServiceV2Client.project_path("[PROJECT]")
350
+ #
351
+ # # TODO: Initialize +metric+:
333
352
  # metric = {}
334
353
  # response = metrics_service_v2_client.create_log_metric(formatted_parent, metric)
335
354
 
336
355
  def create_log_metric \
337
356
  parent,
338
357
  metric,
339
- options: nil
358
+ options: nil,
359
+ &block
340
360
  req = {
341
361
  parent: parent,
342
362
  metric: metric
343
363
  }.delete_if { |_, v| v.nil? }
344
364
  req = Google::Gax::to_proto(req, Google::Logging::V2::CreateLogMetricRequest)
345
- @create_log_metric.call(req, options)
365
+ @create_log_metric.call(req, options, &block)
346
366
  end
347
367
 
348
368
  # Creates or updates a logs-based metric.
@@ -362,26 +382,32 @@ module Google
362
382
  # @param options [Google::Gax::CallOptions]
363
383
  # Overrides the default settings for this call, e.g, timeout,
364
384
  # retries, etc.
385
+ # @yield [result, operation] Access the result along with the RPC operation
386
+ # @yieldparam result [Google::Logging::V2::LogMetric]
387
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
365
388
  # @return [Google::Logging::V2::LogMetric]
366
389
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
367
390
  # @example
368
391
  # require "google/cloud/logging/v2"
369
392
  #
370
- # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
393
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
371
394
  # formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
395
+ #
396
+ # # TODO: Initialize +metric+:
372
397
  # metric = {}
373
398
  # response = metrics_service_v2_client.update_log_metric(formatted_metric_name, metric)
374
399
 
375
400
  def update_log_metric \
376
401
  metric_name,
377
402
  metric,
378
- options: nil
403
+ options: nil,
404
+ &block
379
405
  req = {
380
406
  metric_name: metric_name,
381
407
  metric: metric
382
408
  }.delete_if { |_, v| v.nil? }
383
409
  req = Google::Gax::to_proto(req, Google::Logging::V2::UpdateLogMetricRequest)
384
- @update_log_metric.call(req, options)
410
+ @update_log_metric.call(req, options, &block)
385
411
  end
386
412
 
387
413
  # Deletes a logs-based metric.
@@ -393,22 +419,26 @@ module Google
393
419
  # @param options [Google::Gax::CallOptions]
394
420
  # Overrides the default settings for this call, e.g, timeout,
395
421
  # retries, etc.
422
+ # @yield [result, operation] Access the result along with the RPC operation
423
+ # @yieldparam result []
424
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
396
425
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
397
426
  # @example
398
427
  # require "google/cloud/logging/v2"
399
428
  #
400
- # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
429
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
401
430
  # formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
402
431
  # metrics_service_v2_client.delete_log_metric(formatted_metric_name)
403
432
 
404
433
  def delete_log_metric \
405
434
  metric_name,
406
- options: nil
435
+ options: nil,
436
+ &block
407
437
  req = {
408
438
  metric_name: metric_name
409
439
  }.delete_if { |_, v| v.nil? }
410
440
  req = Google::Gax::to_proto(req, Google::Logging::V2::DeleteLogMetricRequest)
411
- @delete_log_metric.call(req, options)
441
+ @delete_log_metric.call(req, options, &block)
412
442
  nil
413
443
  end
414
444
  end
@@ -12,12 +12,12 @@
12
12
  "retry_params": {
13
13
  "default": {
14
14
  "initial_retry_delay_millis": 100,
15
- "retry_delay_multiplier": 1.2,
16
- "max_retry_delay_millis": 1000,
15
+ "retry_delay_multiplier": 1.3,
16
+ "max_retry_delay_millis": 60000,
17
17
  "initial_rpc_timeout_millis": 20000,
18
- "rpc_timeout_multiplier": 1.5,
19
- "max_rpc_timeout_millis": 60000,
20
- "total_timeout_millis": 90000
18
+ "rpc_timeout_multiplier": 1.0,
19
+ "max_rpc_timeout_millis": 20000,
20
+ "total_timeout_millis": 600000
21
21
  }
22
22
  },
23
23
  "methods": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "UpdateLogMetric": {
40
40
  "timeout_millis": 60000,
41
- "retry_codes_name": "non_idempotent",
41
+ "retry_codes_name": "idempotent",
42
42
  "retry_params_name": "default"
43
43
  },
44
44
  "DeleteLogMetric": {
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Logging
19
- VERSION = "1.5.1".freeze
19
+ VERSION = "1.5.2".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -20,6 +20,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
20
20
  optional :insert_id, :string, 4
21
21
  optional :http_request, :message, 7, "google.logging.type.HttpRequest"
22
22
  map :labels, :string, :string, 11
23
+ optional :metadata, :message, 25, "google.api.MonitoredResourceMetadata"
23
24
  optional :operation, :message, 15, "google.logging.v2.LogEntryOperation"
24
25
  optional :trace, :string, 22
25
26
  optional :span_id, :string, 27
@@ -1,13 +1,13 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # Source: google/logging/v2/logging_config.proto for package 'google.logging.v2'
3
3
  # Original file comments:
4
- # Copyright 2017 Google Inc.
4
+ # Copyright 2018 Google Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # https://www.apache.org/licenses/LICENSE-2.0
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -1,13 +1,13 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # Source: google/logging/v2/logging_metrics.proto for package 'google.logging.v2'
3
3
  # Original file comments:
4
- # Copyright 2017 Google Inc.
4
+ # Copyright 2018 Google Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # https://www.apache.org/licenses/LICENSE-2.0
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,6 +20,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
20
20
  map :labels, :string, :string, 3
21
21
  repeated :entries, :message, 4, "google.logging.v2.LogEntry"
22
22
  optional :partial_success, :bool, 5
23
+ optional :dry_run, :bool, 6
23
24
  end
24
25
  add_message "google.logging.v2.WriteLogEntriesResponse" do
25
26
  end