google-cloud-logging 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +5 -5
  2. data/lib/google-cloud-logging.rb +13 -10
  3. data/lib/google/cloud/logging.rb +41 -17
  4. data/lib/google/cloud/logging/async_writer.rb +5 -2
  5. data/lib/google/cloud/logging/credentials.rb +31 -15
  6. data/lib/google/cloud/logging/entry.rb +13 -0
  7. data/lib/google/cloud/logging/entry/http_request.rb +35 -12
  8. data/lib/google/cloud/logging/logger.rb +14 -0
  9. data/lib/google/cloud/logging/middleware.rb +1 -1
  10. data/lib/google/cloud/logging/project.rb +55 -8
  11. data/lib/google/cloud/logging/rails.rb +1 -1
  12. data/lib/google/cloud/logging/service.rb +8 -27
  13. data/lib/google/cloud/logging/v2/config_service_v2_client.rb +360 -93
  14. data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +43 -8
  15. data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +172 -0
  16. data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +187 -0
  17. data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +4 -4
  18. data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +4 -1
  19. data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +13 -6
  20. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +55 -21
  21. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +185 -23
  22. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +89 -5
  23. data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +12 -2
  24. data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +14 -1
  25. data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +223 -0
  26. data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +26 -1
  27. data/lib/google/cloud/logging/v2/doc/overview.rb +67 -0
  28. data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +116 -91
  29. data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +12 -11
  30. data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +87 -76
  31. data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +9 -8
  32. data/lib/google/cloud/logging/version.rb +1 -1
  33. metadata +11 -7
@@ -28,6 +28,7 @@ require "pathname"
28
28
  require "google/gax"
29
29
 
30
30
  require "google/logging/v2/logging_metrics_pb"
31
+ require "google/cloud/logging/credentials"
31
32
 
32
33
  module Google
33
34
  module Cloud
@@ -99,36 +100,24 @@ module Google
99
100
  )
100
101
  end
101
102
 
102
- # Parses the project from a project resource.
103
- # @param project_name [String]
104
- # @return [String]
105
- def self.match_project_from_project_name project_name
106
- PROJECT_PATH_TEMPLATE.match(project_name)["project"]
107
- end
108
-
109
- # Parses the project from a metric resource.
110
- # @param metric_name [String]
111
- # @return [String]
112
- def self.match_project_from_metric_name metric_name
113
- METRIC_PATH_TEMPLATE.match(metric_name)["project"]
114
- end
115
-
116
- # Parses the metric from a metric resource.
117
- # @param metric_name [String]
118
- # @return [String]
119
- def self.match_metric_from_metric_name metric_name
120
- METRIC_PATH_TEMPLATE.match(metric_name)["metric"]
121
- end
122
-
123
- # @param service_path [String]
124
- # The domain name of the API remote host.
125
- # @param port [Integer]
126
- # The port on which to connect to the remote host.
127
- # @param channel [Channel]
128
- # A Channel object through which to make calls.
129
- # @param chan_creds [Grpc::ChannelCredentials]
130
- # A ChannelCredentials for the setting up the RPC client.
131
- # @param client_config[Hash]
103
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
104
+ # Provides the means for authenticating requests made by the client. This parameter can
105
+ # be many types.
106
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
107
+ # authenticating requests made by this client.
108
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
109
+ # credentials for this client.
110
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
111
+ # credentials for this client.
112
+ # A `GRPC::Core::Channel` will be used to make calls through.
113
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
114
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
115
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
116
+ # metadata for requests, generally, to give OAuth credentials.
117
+ # @param scopes [Array<String>]
118
+ # The OAuth scopes for this service. This parameter is ignored if
119
+ # an updater_proc is supplied.
120
+ # @param client_config [Hash]
132
121
  # A Hash for call options for each method. See
133
122
  # Google::Gax#construct_settings for the structure of
134
123
  # this data. Falls back to the default config if not specified
@@ -140,11 +129,11 @@ module Google
140
129
  port: DEFAULT_SERVICE_PORT,
141
130
  channel: nil,
142
131
  chan_creds: nil,
132
+ updater_proc: nil,
133
+ credentials: nil,
143
134
  scopes: ALL_SCOPES,
144
135
  client_config: {},
145
136
  timeout: DEFAULT_TIMEOUT,
146
- app_name: nil,
147
- app_version: nil,
148
137
  lib_name: nil,
149
138
  lib_version: ""
150
139
  # These require statements are intentionally placed here to initialize
@@ -153,14 +142,38 @@ module Google
153
142
  require "google/gax/grpc"
154
143
  require "google/logging/v2/logging_metrics_services_pb"
155
144
 
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
156
157
 
157
- if app_name || app_version
158
- warn "`app_name` and `app_version` are no longer being used in the request headers."
158
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
159
+ updater_proc = Google::Cloud::Logging::Credentials.new(credentials).updater_proc
160
+ end
161
+ if credentials.is_a?(GRPC::Core::Channel)
162
+ channel = credentials
163
+ end
164
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
165
+ chan_creds = credentials
166
+ end
167
+ if credentials.is_a?(Proc)
168
+ updater_proc = credentials
169
+ end
170
+ if credentials.is_a?(Google::Auth::Credentials)
171
+ updater_proc = credentials.updater_proc
159
172
  end
160
173
 
161
174
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
162
175
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
163
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
176
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
164
177
  google_api_client << " grpc/#{GRPC::VERSION}"
165
178
  google_api_client.freeze
166
179
 
@@ -185,6 +198,7 @@ module Google
185
198
  port,
186
199
  chan_creds: chan_creds,
187
200
  channel: channel,
201
+ updater_proc: updater_proc,
188
202
  scopes: scopes,
189
203
  &Google::Logging::V2::MetricsServiceV2::Stub.method(:new)
190
204
  )
@@ -235,12 +249,10 @@ module Google
235
249
  # object.
236
250
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
237
251
  # @example
238
- # require "google/cloud/logging/v2/metrics_service_v2_client"
252
+ # require "google/cloud/logging/v2"
239
253
  #
240
- # MetricsServiceV2Client = Google::Cloud::Logging::V2::MetricsServiceV2Client
241
- #
242
- # metrics_service_v2_client = MetricsServiceV2Client.new
243
- # formatted_parent = MetricsServiceV2Client.project_path("[PROJECT]")
254
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
255
+ # formatted_parent = Google::Cloud::Logging::V2::MetricsServiceV2Client.project_path("[PROJECT]")
244
256
  #
245
257
  # # Iterate over all results.
246
258
  # metrics_service_v2_client.list_log_metrics(formatted_parent).each do |element|
@@ -259,10 +271,11 @@ module Google
259
271
  parent,
260
272
  page_size: nil,
261
273
  options: nil
262
- req = Google::Logging::V2::ListLogMetricsRequest.new({
274
+ req = {
263
275
  parent: parent,
264
276
  page_size: page_size
265
- }.delete_if { |_, v| v.nil? })
277
+ }.delete_if { |_, v| v.nil? }
278
+ req = Google::Gax::to_proto(req, Google::Logging::V2::ListLogMetricsRequest)
266
279
  @list_log_metrics.call(req, options)
267
280
  end
268
281
 
@@ -278,20 +291,19 @@ module Google
278
291
  # @return [Google::Logging::V2::LogMetric]
279
292
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
280
293
  # @example
281
- # require "google/cloud/logging/v2/metrics_service_v2_client"
282
- #
283
- # MetricsServiceV2Client = Google::Cloud::Logging::V2::MetricsServiceV2Client
294
+ # require "google/cloud/logging/v2"
284
295
  #
285
- # metrics_service_v2_client = MetricsServiceV2Client.new
286
- # formatted_metric_name = MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
296
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
297
+ # formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
287
298
  # response = metrics_service_v2_client.get_log_metric(formatted_metric_name)
288
299
 
289
300
  def get_log_metric \
290
301
  metric_name,
291
302
  options: nil
292
- req = Google::Logging::V2::GetLogMetricRequest.new({
303
+ req = {
293
304
  metric_name: metric_name
294
- }.delete_if { |_, v| v.nil? })
305
+ }.delete_if { |_, v| v.nil? }
306
+ req = Google::Gax::to_proto(req, Google::Logging::V2::GetLogMetricRequest)
295
307
  @get_log_metric.call(req, options)
296
308
  end
297
309
 
@@ -303,33 +315,33 @@ module Google
303
315
  # "projects/[PROJECT_ID]"
304
316
  #
305
317
  # The new metric must be provided in the request.
306
- # @param metric [Google::Logging::V2::LogMetric]
318
+ # @param metric [Google::Logging::V2::LogMetric | Hash]
307
319
  # The new logs-based metric, which must not have an identifier that
308
320
  # already exists.
321
+ # A hash of the same form as `Google::Logging::V2::LogMetric`
322
+ # can also be provided.
309
323
  # @param options [Google::Gax::CallOptions]
310
324
  # Overrides the default settings for this call, e.g, timeout,
311
325
  # retries, etc.
312
326
  # @return [Google::Logging::V2::LogMetric]
313
327
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
314
328
  # @example
315
- # require "google/cloud/logging/v2/metrics_service_v2_client"
316
- #
317
- # LogMetric = Google::Logging::V2::LogMetric
318
- # MetricsServiceV2Client = Google::Cloud::Logging::V2::MetricsServiceV2Client
329
+ # require "google/cloud/logging/v2"
319
330
  #
320
- # metrics_service_v2_client = MetricsServiceV2Client.new
321
- # formatted_parent = MetricsServiceV2Client.project_path("[PROJECT]")
322
- # metric = LogMetric.new
331
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
332
+ # formatted_parent = Google::Cloud::Logging::V2::MetricsServiceV2Client.project_path("[PROJECT]")
333
+ # metric = {}
323
334
  # response = metrics_service_v2_client.create_log_metric(formatted_parent, metric)
324
335
 
325
336
  def create_log_metric \
326
337
  parent,
327
338
  metric,
328
339
  options: nil
329
- req = Google::Logging::V2::CreateLogMetricRequest.new({
340
+ req = {
330
341
  parent: parent,
331
342
  metric: metric
332
- }.delete_if { |_, v| v.nil? })
343
+ }.delete_if { |_, v| v.nil? }
344
+ req = Google::Gax::to_proto(req, Google::Logging::V2::CreateLogMetricRequest)
333
345
  @create_log_metric.call(req, options)
334
346
  end
335
347
 
@@ -343,32 +355,32 @@ module Google
343
355
  # The updated metric must be provided in the request and it's
344
356
  # +name+ field must be the same as +[METRIC_ID]+ If the metric
345
357
  # does not exist in +[PROJECT_ID]+, then a new metric is created.
346
- # @param metric [Google::Logging::V2::LogMetric]
358
+ # @param metric [Google::Logging::V2::LogMetric | Hash]
347
359
  # The updated metric.
360
+ # A hash of the same form as `Google::Logging::V2::LogMetric`
361
+ # can also be provided.
348
362
  # @param options [Google::Gax::CallOptions]
349
363
  # Overrides the default settings for this call, e.g, timeout,
350
364
  # retries, etc.
351
365
  # @return [Google::Logging::V2::LogMetric]
352
366
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
353
367
  # @example
354
- # require "google/cloud/logging/v2/metrics_service_v2_client"
368
+ # require "google/cloud/logging/v2"
355
369
  #
356
- # LogMetric = Google::Logging::V2::LogMetric
357
- # MetricsServiceV2Client = Google::Cloud::Logging::V2::MetricsServiceV2Client
358
- #
359
- # metrics_service_v2_client = MetricsServiceV2Client.new
360
- # formatted_metric_name = MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
361
- # metric = LogMetric.new
370
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
371
+ # formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
372
+ # metric = {}
362
373
  # response = metrics_service_v2_client.update_log_metric(formatted_metric_name, metric)
363
374
 
364
375
  def update_log_metric \
365
376
  metric_name,
366
377
  metric,
367
378
  options: nil
368
- req = Google::Logging::V2::UpdateLogMetricRequest.new({
379
+ req = {
369
380
  metric_name: metric_name,
370
381
  metric: metric
371
- }.delete_if { |_, v| v.nil? })
382
+ }.delete_if { |_, v| v.nil? }
383
+ req = Google::Gax::to_proto(req, Google::Logging::V2::UpdateLogMetricRequest)
372
384
  @update_log_metric.call(req, options)
373
385
  end
374
386
 
@@ -383,20 +395,19 @@ module Google
383
395
  # retries, etc.
384
396
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
385
397
  # @example
386
- # require "google/cloud/logging/v2/metrics_service_v2_client"
387
- #
388
- # MetricsServiceV2Client = Google::Cloud::Logging::V2::MetricsServiceV2Client
398
+ # require "google/cloud/logging/v2"
389
399
  #
390
- # metrics_service_v2_client = MetricsServiceV2Client.new
391
- # formatted_metric_name = MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
400
+ # metrics_service_v2_client = Google::Cloud::Logging::V2::Metrics.new
401
+ # formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.metric_path("[PROJECT]", "[METRIC]")
392
402
  # metrics_service_v2_client.delete_log_metric(formatted_metric_name)
393
403
 
394
404
  def delete_log_metric \
395
405
  metric_name,
396
406
  options: nil
397
- req = Google::Logging::V2::DeleteLogMetricRequest.new({
407
+ req = {
398
408
  metric_name: metric_name
399
- }.delete_if { |_, v| v.nil? })
409
+ }.delete_if { |_, v| v.nil? }
410
+ req = Google::Gax::to_proto(req, Google::Logging::V2::DeleteLogMetricRequest)
400
411
  @delete_log_metric.call(req, options)
401
412
  nil
402
413
  end
@@ -4,6 +4,7 @@
4
4
  "retry_codes": {
5
5
  "idempotent": [
6
6
  "DEADLINE_EXCEEDED",
7
+ "INTERNAL",
7
8
  "UNAVAILABLE"
8
9
  ],
9
10
  "non_idempotent": []
@@ -13,35 +14,35 @@
13
14
  "initial_retry_delay_millis": 100,
14
15
  "retry_delay_multiplier": 1.2,
15
16
  "max_retry_delay_millis": 1000,
16
- "initial_rpc_timeout_millis": 2000,
17
+ "initial_rpc_timeout_millis": 20000,
17
18
  "rpc_timeout_multiplier": 1.5,
18
- "max_rpc_timeout_millis": 30000,
19
- "total_timeout_millis": 45000
19
+ "max_rpc_timeout_millis": 60000,
20
+ "total_timeout_millis": 90000
20
21
  }
21
22
  },
22
23
  "methods": {
23
24
  "ListLogMetrics": {
24
- "timeout_millis": 30000,
25
+ "timeout_millis": 60000,
25
26
  "retry_codes_name": "idempotent",
26
27
  "retry_params_name": "default"
27
28
  },
28
29
  "GetLogMetric": {
29
- "timeout_millis": 30000,
30
+ "timeout_millis": 60000,
30
31
  "retry_codes_name": "idempotent",
31
32
  "retry_params_name": "default"
32
33
  },
33
34
  "CreateLogMetric": {
34
- "timeout_millis": 30000,
35
+ "timeout_millis": 60000,
35
36
  "retry_codes_name": "non_idempotent",
36
37
  "retry_params_name": "default"
37
38
  },
38
39
  "UpdateLogMetric": {
39
- "timeout_millis": 30000,
40
+ "timeout_millis": 60000,
40
41
  "retry_codes_name": "non_idempotent",
41
42
  "retry_params_name": "default"
42
43
  },
43
44
  "DeleteLogMetric": {
44
- "timeout_millis": 30000,
45
+ "timeout_millis": 60000,
45
46
  "retry_codes_name": "idempotent",
46
47
  "retry_params_name": "default"
47
48
  }
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Logging
19
- VERSION = "1.2.3"
19
+ VERSION = "1.3.0"
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-27 00:00:00.000000000 Z
12
+ date: 2017-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.0'
20
+ version: '1.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.0'
27
+ version: '1.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: stackdriver-core
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.8.0
48
+ version: 0.10.1
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 0.8.0
55
+ version: 0.10.1
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: minitest
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -244,7 +244,9 @@ files:
244
244
  - lib/google/cloud/logging/v2.rb
245
245
  - lib/google/cloud/logging/v2/config_service_v2_client.rb
246
246
  - lib/google/cloud/logging/v2/config_service_v2_client_config.json
247
+ - lib/google/cloud/logging/v2/doc/google/api/distribution.rb
247
248
  - lib/google/cloud/logging/v2/doc/google/api/label.rb
249
+ - lib/google/cloud/logging/v2/doc/google/api/metric.rb
248
250
  - lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb
249
251
  - lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb
250
252
  - lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb
@@ -253,7 +255,9 @@ files:
253
255
  - lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb
254
256
  - lib/google/cloud/logging/v2/doc/google/protobuf/any.rb
255
257
  - lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb
258
+ - lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb
256
259
  - lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb
260
+ - lib/google/cloud/logging/v2/doc/overview.rb
257
261
  - lib/google/cloud/logging/v2/logging_service_v2_client.rb
258
262
  - lib/google/cloud/logging/v2/logging_service_v2_client_config.json
259
263
  - lib/google/cloud/logging/v2/metrics_service_v2_client.rb
@@ -286,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
290
  version: '0'
287
291
  requirements: []
288
292
  rubyforge_project:
289
- rubygems_version: 2.6.13
293
+ rubygems_version: 2.7.2
290
294
  signing_key:
291
295
  specification_version: 4
292
296
  summary: API Client library for Stackdriver Logging