google-cloud-logging 1.10.9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +2 -1
- data/CHANGELOG.md +23 -0
- data/lib/google-cloud-logging.rb +14 -15
- data/lib/google/cloud/logging.rb +12 -13
- data/lib/google/cloud/logging/credentials.rb +2 -2
- data/lib/google/cloud/logging/entry.rb +5 -5
- data/lib/google/cloud/logging/entry/http_request.rb +3 -3
- data/lib/google/cloud/logging/entry/list.rb +1 -1
- data/lib/google/cloud/logging/entry/operation.rb +3 -3
- data/lib/google/cloud/logging/entry/source_location.rb +3 -3
- data/lib/google/cloud/logging/log/list.rb +1 -1
- data/lib/google/cloud/logging/metric.rb +2 -2
- data/lib/google/cloud/logging/metric/list.rb +1 -1
- data/lib/google/cloud/logging/resource_descriptor/list.rb +1 -1
- data/lib/google/cloud/logging/service.rb +70 -173
- data/lib/google/cloud/logging/sink.rb +2 -2
- data/lib/google/cloud/logging/sink/list.rb +1 -1
- data/lib/google/cloud/logging/version.rb +1 -1
- metadata +10 -80
- data/lib/google/cloud/logging/v2.rb +0 -18
- data/lib/google/cloud/logging/v2/config_service_v2_client.rb +0 -1368
- data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +0 -106
- data/lib/google/cloud/logging/v2/credentials.rb +0 -39
- data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +0 -164
- data/lib/google/cloud/logging/v2/doc/google/api/label.rb +0 -42
- data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +0 -275
- data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +0 -118
- data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +0 -86
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +0 -179
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +0 -238
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +0 -660
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +0 -220
- data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/logging/v2/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/logging/v2/doc/google/protobuf/struct.rb +0 -74
- data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +0 -680
- data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +0 -61
- data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +0 -475
- data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +0 -56
- data/lib/google/logging/v2/log_entry_pb.rb +0 -59
- data/lib/google/logging/v2/logging_config_pb.rb +0 -173
- data/lib/google/logging/v2/logging_config_services_pb.rb +0 -112
- data/lib/google/logging/v2/logging_metrics_pb.rb +0 -72
- data/lib/google/logging/v2/logging_metrics_services_pb.rb +0 -52
- data/lib/google/logging/v2/logging_pb.rb +0 -80
- data/lib/google/logging/v2/logging_services_pb.rb +0 -64
@@ -1,61 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"interfaces": {
|
3
|
-
"google.logging.v2.LoggingServiceV2": {
|
4
|
-
"retry_codes": {
|
5
|
-
"idempotent": [
|
6
|
-
"DEADLINE_EXCEEDED",
|
7
|
-
"INTERNAL",
|
8
|
-
"UNAVAILABLE"
|
9
|
-
],
|
10
|
-
"non_idempotent": [],
|
11
|
-
"idempotent2": [
|
12
|
-
"DEADLINE_EXCEEDED",
|
13
|
-
"UNAVAILABLE"
|
14
|
-
]
|
15
|
-
},
|
16
|
-
"retry_params": {
|
17
|
-
"default": {
|
18
|
-
"initial_retry_delay_millis": 100,
|
19
|
-
"retry_delay_multiplier": 1.3,
|
20
|
-
"max_retry_delay_millis": 60000,
|
21
|
-
"initial_rpc_timeout_millis": 20000,
|
22
|
-
"rpc_timeout_multiplier": 1.0,
|
23
|
-
"max_rpc_timeout_millis": 20000,
|
24
|
-
"total_timeout_millis": 600000
|
25
|
-
}
|
26
|
-
},
|
27
|
-
"methods": {
|
28
|
-
"DeleteLog": {
|
29
|
-
"timeout_millis": 60000,
|
30
|
-
"retry_codes_name": "idempotent",
|
31
|
-
"retry_params_name": "default"
|
32
|
-
},
|
33
|
-
"ListLogEntries": {
|
34
|
-
"timeout_millis": 10000,
|
35
|
-
"retry_codes_name": "idempotent",
|
36
|
-
"retry_params_name": "default"
|
37
|
-
},
|
38
|
-
"WriteLogEntries": {
|
39
|
-
"timeout_millis": 60000,
|
40
|
-
"retry_codes_name": "idempotent",
|
41
|
-
"retry_params_name": "default",
|
42
|
-
"bundling": {
|
43
|
-
"element_count_threshold": 1000,
|
44
|
-
"request_byte_threshold": 1048576,
|
45
|
-
"delay_threshold_millis": 50
|
46
|
-
}
|
47
|
-
},
|
48
|
-
"ListMonitoredResourceDescriptors": {
|
49
|
-
"timeout_millis": 60000,
|
50
|
-
"retry_codes_name": "idempotent2",
|
51
|
-
"retry_params_name": "default"
|
52
|
-
},
|
53
|
-
"ListLogs": {
|
54
|
-
"timeout_millis": 60000,
|
55
|
-
"retry_codes_name": "idempotent2",
|
56
|
-
"retry_params_name": "default"
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
@@ -1,475 +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/logging/v2/logging_metrics.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/logging/v2/logging_metrics_pb"
|
29
|
-
require "google/cloud/logging/v2/credentials"
|
30
|
-
require "google/cloud/logging/version"
|
31
|
-
|
32
|
-
module Google
|
33
|
-
module Cloud
|
34
|
-
module Logging
|
35
|
-
module V2
|
36
|
-
# Service for configuring logs-based metrics.
|
37
|
-
#
|
38
|
-
# @!attribute [r] metrics_service_v2_stub
|
39
|
-
# @return [Google::Logging::V2::MetricsServiceV2::Stub]
|
40
|
-
class MetricsServiceV2Client
|
41
|
-
# @private
|
42
|
-
attr_reader :metrics_service_v2_stub
|
43
|
-
|
44
|
-
# The default address of the service.
|
45
|
-
SERVICE_ADDRESS = "logging.googleapis.com".freeze
|
46
|
-
|
47
|
-
# The default port of the service.
|
48
|
-
DEFAULT_SERVICE_PORT = 443
|
49
|
-
|
50
|
-
# The default set of gRPC interceptors.
|
51
|
-
GRPC_INTERCEPTORS = []
|
52
|
-
|
53
|
-
DEFAULT_TIMEOUT = 30
|
54
|
-
|
55
|
-
PAGE_DESCRIPTORS = {
|
56
|
-
"list_log_metrics" => Google::Gax::PageDescriptor.new(
|
57
|
-
"page_token",
|
58
|
-
"next_page_token",
|
59
|
-
"metrics")
|
60
|
-
}.freeze
|
61
|
-
|
62
|
-
private_constant :PAGE_DESCRIPTORS
|
63
|
-
|
64
|
-
# The scopes needed to make gRPC calls to all of the methods defined in
|
65
|
-
# this service.
|
66
|
-
ALL_SCOPES = [
|
67
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
68
|
-
"https://www.googleapis.com/auth/cloud-platform.read-only",
|
69
|
-
"https://www.googleapis.com/auth/logging.admin",
|
70
|
-
"https://www.googleapis.com/auth/logging.read",
|
71
|
-
"https://www.googleapis.com/auth/logging.write"
|
72
|
-
].freeze
|
73
|
-
|
74
|
-
|
75
|
-
LOG_METRIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
76
|
-
"projects/{project}/metrics/{metric}"
|
77
|
-
)
|
78
|
-
|
79
|
-
private_constant :LOG_METRIC_PATH_TEMPLATE
|
80
|
-
|
81
|
-
PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
82
|
-
"projects/{project}"
|
83
|
-
)
|
84
|
-
|
85
|
-
private_constant :PROJECT_PATH_TEMPLATE
|
86
|
-
|
87
|
-
# Returns a fully-qualified log_metric resource name string.
|
88
|
-
# @param project [String]
|
89
|
-
# @param metric [String]
|
90
|
-
# @return [String]
|
91
|
-
def self.log_metric_path project, metric
|
92
|
-
LOG_METRIC_PATH_TEMPLATE.render(
|
93
|
-
:"project" => project,
|
94
|
-
:"metric" => metric
|
95
|
-
)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Returns a fully-qualified project resource name string.
|
99
|
-
# @param project [String]
|
100
|
-
# @return [String]
|
101
|
-
def self.project_path project
|
102
|
-
PROJECT_PATH_TEMPLATE.render(
|
103
|
-
:"project" => project
|
104
|
-
)
|
105
|
-
end
|
106
|
-
|
107
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
108
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
109
|
-
# be many types.
|
110
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
111
|
-
# authenticating requests made by this client.
|
112
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
113
|
-
# credentials for this client.
|
114
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
115
|
-
# credentials for this client.
|
116
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
117
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
118
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
119
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
120
|
-
# metadata for requests, generally, to give OAuth credentials.
|
121
|
-
# @param scopes [Array<String>]
|
122
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
123
|
-
# an updater_proc is supplied.
|
124
|
-
# @param client_config [Hash]
|
125
|
-
# A Hash for call options for each method. See
|
126
|
-
# Google::Gax#construct_settings for the structure of
|
127
|
-
# this data. Falls back to the default config if not specified
|
128
|
-
# or the specified config is missing data points.
|
129
|
-
# @param timeout [Numeric]
|
130
|
-
# The default timeout, in seconds, for calls made through this client.
|
131
|
-
# @param metadata [Hash]
|
132
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
133
|
-
# @param service_address [String]
|
134
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
135
|
-
# @param service_port [Integer]
|
136
|
-
# Override for the service port, or `nil` to leave as the default.
|
137
|
-
# @param exception_transformer [Proc]
|
138
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
139
|
-
# custom error handling.
|
140
|
-
def initialize \
|
141
|
-
credentials: nil,
|
142
|
-
scopes: ALL_SCOPES,
|
143
|
-
client_config: {},
|
144
|
-
timeout: DEFAULT_TIMEOUT,
|
145
|
-
metadata: nil,
|
146
|
-
service_address: nil,
|
147
|
-
service_port: nil,
|
148
|
-
exception_transformer: nil,
|
149
|
-
lib_name: nil,
|
150
|
-
lib_version: ""
|
151
|
-
# These require statements are intentionally placed here to initialize
|
152
|
-
# the gRPC module only when it's required.
|
153
|
-
# See https://github.com/googleapis/toolkit/issues/446
|
154
|
-
require "google/gax/grpc"
|
155
|
-
require "google/logging/v2/logging_metrics_services_pb"
|
156
|
-
|
157
|
-
credentials ||= Google::Cloud::Logging::V2::Credentials.default
|
158
|
-
|
159
|
-
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
160
|
-
updater_proc = Google::Cloud::Logging::V2::Credentials.new(credentials).updater_proc
|
161
|
-
end
|
162
|
-
if credentials.is_a?(GRPC::Core::Channel)
|
163
|
-
channel = credentials
|
164
|
-
end
|
165
|
-
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
166
|
-
chan_creds = credentials
|
167
|
-
end
|
168
|
-
if credentials.is_a?(Proc)
|
169
|
-
updater_proc = credentials
|
170
|
-
end
|
171
|
-
if credentials.is_a?(Google::Auth::Credentials)
|
172
|
-
updater_proc = credentials.updater_proc
|
173
|
-
end
|
174
|
-
|
175
|
-
package_version = Google::Cloud::Logging::VERSION
|
176
|
-
|
177
|
-
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
178
|
-
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
179
|
-
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
180
|
-
google_api_client << " grpc/#{GRPC::VERSION}"
|
181
|
-
google_api_client.freeze
|
182
|
-
|
183
|
-
headers = { :"x-goog-api-client" => google_api_client }
|
184
|
-
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
185
|
-
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
186
|
-
end
|
187
|
-
headers.merge!(metadata) unless metadata.nil?
|
188
|
-
client_config_file = Pathname.new(__dir__).join(
|
189
|
-
"metrics_service_v2_client_config.json"
|
190
|
-
)
|
191
|
-
defaults = client_config_file.open do |f|
|
192
|
-
Google::Gax.construct_settings(
|
193
|
-
"google.logging.v2.MetricsServiceV2",
|
194
|
-
JSON.parse(f.read),
|
195
|
-
client_config,
|
196
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
197
|
-
timeout,
|
198
|
-
page_descriptors: PAGE_DESCRIPTORS,
|
199
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
200
|
-
metadata: headers
|
201
|
-
)
|
202
|
-
end
|
203
|
-
|
204
|
-
# Allow overriding the service path/port in subclasses.
|
205
|
-
service_path = service_address || self.class::SERVICE_ADDRESS
|
206
|
-
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
207
|
-
interceptors = self.class::GRPC_INTERCEPTORS
|
208
|
-
@metrics_service_v2_stub = Google::Gax::Grpc.create_stub(
|
209
|
-
service_path,
|
210
|
-
port,
|
211
|
-
chan_creds: chan_creds,
|
212
|
-
channel: channel,
|
213
|
-
updater_proc: updater_proc,
|
214
|
-
scopes: scopes,
|
215
|
-
interceptors: interceptors,
|
216
|
-
&Google::Logging::V2::MetricsServiceV2::Stub.method(:new)
|
217
|
-
)
|
218
|
-
|
219
|
-
@update_log_metric = Google::Gax.create_api_call(
|
220
|
-
@metrics_service_v2_stub.method(:update_log_metric),
|
221
|
-
defaults["update_log_metric"],
|
222
|
-
exception_transformer: exception_transformer,
|
223
|
-
params_extractor: proc do |request|
|
224
|
-
{'metric_name' => request.metric_name}
|
225
|
-
end
|
226
|
-
)
|
227
|
-
@delete_log_metric = Google::Gax.create_api_call(
|
228
|
-
@metrics_service_v2_stub.method(:delete_log_metric),
|
229
|
-
defaults["delete_log_metric"],
|
230
|
-
exception_transformer: exception_transformer,
|
231
|
-
params_extractor: proc do |request|
|
232
|
-
{'metric_name' => request.metric_name}
|
233
|
-
end
|
234
|
-
)
|
235
|
-
@list_log_metrics = Google::Gax.create_api_call(
|
236
|
-
@metrics_service_v2_stub.method(:list_log_metrics),
|
237
|
-
defaults["list_log_metrics"],
|
238
|
-
exception_transformer: exception_transformer,
|
239
|
-
params_extractor: proc do |request|
|
240
|
-
{'parent' => request.parent}
|
241
|
-
end
|
242
|
-
)
|
243
|
-
@get_log_metric = Google::Gax.create_api_call(
|
244
|
-
@metrics_service_v2_stub.method(:get_log_metric),
|
245
|
-
defaults["get_log_metric"],
|
246
|
-
exception_transformer: exception_transformer,
|
247
|
-
params_extractor: proc do |request|
|
248
|
-
{'metric_name' => request.metric_name}
|
249
|
-
end
|
250
|
-
)
|
251
|
-
@create_log_metric = Google::Gax.create_api_call(
|
252
|
-
@metrics_service_v2_stub.method(:create_log_metric),
|
253
|
-
defaults["create_log_metric"],
|
254
|
-
exception_transformer: exception_transformer,
|
255
|
-
params_extractor: proc do |request|
|
256
|
-
{'parent' => request.parent}
|
257
|
-
end
|
258
|
-
)
|
259
|
-
end
|
260
|
-
|
261
|
-
# Service calls
|
262
|
-
|
263
|
-
# Creates or updates a logs-based metric.
|
264
|
-
#
|
265
|
-
# @param metric_name [String]
|
266
|
-
# Required. The resource name of the metric to update:
|
267
|
-
#
|
268
|
-
# "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
|
269
|
-
#
|
270
|
-
# The updated metric must be provided in the request and it's
|
271
|
-
# `name` field must be the same as `[METRIC_ID]` If the metric
|
272
|
-
# does not exist in `[PROJECT_ID]`, then a new metric is created.
|
273
|
-
# @param metric [Google::Logging::V2::LogMetric | Hash]
|
274
|
-
# Required. The updated metric.
|
275
|
-
# A hash of the same form as `Google::Logging::V2::LogMetric`
|
276
|
-
# can also be provided.
|
277
|
-
# @param options [Google::Gax::CallOptions]
|
278
|
-
# Overrides the default settings for this call, e.g, timeout,
|
279
|
-
# retries, etc.
|
280
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
281
|
-
# @yieldparam result [Google::Logging::V2::LogMetric]
|
282
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
283
|
-
# @return [Google::Logging::V2::LogMetric]
|
284
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
285
|
-
# @example
|
286
|
-
# require "google/cloud/logging/v2"
|
287
|
-
#
|
288
|
-
# metrics_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
|
289
|
-
# formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.log_metric_path("[PROJECT]", "[METRIC]")
|
290
|
-
#
|
291
|
-
# # TODO: Initialize `metric`:
|
292
|
-
# metric = {}
|
293
|
-
# response = metrics_client.update_log_metric(formatted_metric_name, metric)
|
294
|
-
|
295
|
-
def update_log_metric \
|
296
|
-
metric_name,
|
297
|
-
metric,
|
298
|
-
options: nil,
|
299
|
-
&block
|
300
|
-
req = {
|
301
|
-
metric_name: metric_name,
|
302
|
-
metric: metric
|
303
|
-
}.delete_if { |_, v| v.nil? }
|
304
|
-
req = Google::Gax::to_proto(req, Google::Logging::V2::UpdateLogMetricRequest)
|
305
|
-
@update_log_metric.call(req, options, &block)
|
306
|
-
end
|
307
|
-
|
308
|
-
# Deletes a logs-based metric.
|
309
|
-
#
|
310
|
-
# @param metric_name [String]
|
311
|
-
# Required. The resource name of the metric to delete:
|
312
|
-
#
|
313
|
-
# "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
|
314
|
-
# @param options [Google::Gax::CallOptions]
|
315
|
-
# Overrides the default settings for this call, e.g, timeout,
|
316
|
-
# retries, etc.
|
317
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
318
|
-
# @yieldparam result []
|
319
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
320
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
321
|
-
# @example
|
322
|
-
# require "google/cloud/logging/v2"
|
323
|
-
#
|
324
|
-
# metrics_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
|
325
|
-
# formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.log_metric_path("[PROJECT]", "[METRIC]")
|
326
|
-
# metrics_client.delete_log_metric(formatted_metric_name)
|
327
|
-
|
328
|
-
def delete_log_metric \
|
329
|
-
metric_name,
|
330
|
-
options: nil,
|
331
|
-
&block
|
332
|
-
req = {
|
333
|
-
metric_name: metric_name
|
334
|
-
}.delete_if { |_, v| v.nil? }
|
335
|
-
req = Google::Gax::to_proto(req, Google::Logging::V2::DeleteLogMetricRequest)
|
336
|
-
@delete_log_metric.call(req, options, &block)
|
337
|
-
nil
|
338
|
-
end
|
339
|
-
|
340
|
-
# Lists logs-based metrics.
|
341
|
-
#
|
342
|
-
# @param parent [String]
|
343
|
-
# Required. The name of the project containing the metrics:
|
344
|
-
#
|
345
|
-
# "projects/[PROJECT_ID]"
|
346
|
-
# @param page_size [Integer]
|
347
|
-
# The maximum number of resources contained in the underlying API
|
348
|
-
# response. If page streaming is performed per-resource, this
|
349
|
-
# parameter does not affect the return value. If page streaming is
|
350
|
-
# performed per-page, this determines the maximum number of
|
351
|
-
# resources in a page.
|
352
|
-
# @param options [Google::Gax::CallOptions]
|
353
|
-
# Overrides the default settings for this call, e.g, timeout,
|
354
|
-
# retries, etc.
|
355
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
356
|
-
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Logging::V2::LogMetric>]
|
357
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
358
|
-
# @return [Google::Gax::PagedEnumerable<Google::Logging::V2::LogMetric>]
|
359
|
-
# An enumerable of Google::Logging::V2::LogMetric instances.
|
360
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
361
|
-
# operations such as per-page iteration or access to the response
|
362
|
-
# object.
|
363
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
364
|
-
# @example
|
365
|
-
# require "google/cloud/logging/v2"
|
366
|
-
#
|
367
|
-
# metrics_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
|
368
|
-
# formatted_parent = Google::Cloud::Logging::V2::MetricsServiceV2Client.project_path("[PROJECT]")
|
369
|
-
#
|
370
|
-
# # Iterate over all results.
|
371
|
-
# metrics_client.list_log_metrics(formatted_parent).each do |element|
|
372
|
-
# # Process element.
|
373
|
-
# end
|
374
|
-
#
|
375
|
-
# # Or iterate over results one page at a time.
|
376
|
-
# metrics_client.list_log_metrics(formatted_parent).each_page do |page|
|
377
|
-
# # Process each page at a time.
|
378
|
-
# page.each do |element|
|
379
|
-
# # Process element.
|
380
|
-
# end
|
381
|
-
# end
|
382
|
-
|
383
|
-
def list_log_metrics \
|
384
|
-
parent,
|
385
|
-
page_size: nil,
|
386
|
-
options: nil,
|
387
|
-
&block
|
388
|
-
req = {
|
389
|
-
parent: parent,
|
390
|
-
page_size: page_size
|
391
|
-
}.delete_if { |_, v| v.nil? }
|
392
|
-
req = Google::Gax::to_proto(req, Google::Logging::V2::ListLogMetricsRequest)
|
393
|
-
@list_log_metrics.call(req, options, &block)
|
394
|
-
end
|
395
|
-
|
396
|
-
# Gets a logs-based metric.
|
397
|
-
#
|
398
|
-
# @param metric_name [String]
|
399
|
-
# Required. The resource name of the desired metric:
|
400
|
-
#
|
401
|
-
# "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
|
402
|
-
# @param options [Google::Gax::CallOptions]
|
403
|
-
# Overrides the default settings for this call, e.g, timeout,
|
404
|
-
# retries, etc.
|
405
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
406
|
-
# @yieldparam result [Google::Logging::V2::LogMetric]
|
407
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
408
|
-
# @return [Google::Logging::V2::LogMetric]
|
409
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
410
|
-
# @example
|
411
|
-
# require "google/cloud/logging/v2"
|
412
|
-
#
|
413
|
-
# metrics_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
|
414
|
-
# formatted_metric_name = Google::Cloud::Logging::V2::MetricsServiceV2Client.log_metric_path("[PROJECT]", "[METRIC]")
|
415
|
-
# response = metrics_client.get_log_metric(formatted_metric_name)
|
416
|
-
|
417
|
-
def get_log_metric \
|
418
|
-
metric_name,
|
419
|
-
options: nil,
|
420
|
-
&block
|
421
|
-
req = {
|
422
|
-
metric_name: metric_name
|
423
|
-
}.delete_if { |_, v| v.nil? }
|
424
|
-
req = Google::Gax::to_proto(req, Google::Logging::V2::GetLogMetricRequest)
|
425
|
-
@get_log_metric.call(req, options, &block)
|
426
|
-
end
|
427
|
-
|
428
|
-
# Creates a logs-based metric.
|
429
|
-
#
|
430
|
-
# @param parent [String]
|
431
|
-
# Required. The resource name of the project in which to create the metric:
|
432
|
-
#
|
433
|
-
# "projects/[PROJECT_ID]"
|
434
|
-
#
|
435
|
-
# The new metric must be provided in the request.
|
436
|
-
# @param metric [Google::Logging::V2::LogMetric | Hash]
|
437
|
-
# Required. The new logs-based metric, which must not have an identifier that
|
438
|
-
# already exists.
|
439
|
-
# A hash of the same form as `Google::Logging::V2::LogMetric`
|
440
|
-
# can also be provided.
|
441
|
-
# @param options [Google::Gax::CallOptions]
|
442
|
-
# Overrides the default settings for this call, e.g, timeout,
|
443
|
-
# retries, etc.
|
444
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
445
|
-
# @yieldparam result [Google::Logging::V2::LogMetric]
|
446
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
447
|
-
# @return [Google::Logging::V2::LogMetric]
|
448
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
449
|
-
# @example
|
450
|
-
# require "google/cloud/logging/v2"
|
451
|
-
#
|
452
|
-
# metrics_client = Google::Cloud::Logging::V2::MetricsServiceV2Client.new
|
453
|
-
# formatted_parent = Google::Cloud::Logging::V2::MetricsServiceV2Client.project_path("[PROJECT]")
|
454
|
-
#
|
455
|
-
# # TODO: Initialize `metric`:
|
456
|
-
# metric = {}
|
457
|
-
# response = metrics_client.create_log_metric(formatted_parent, metric)
|
458
|
-
|
459
|
-
def create_log_metric \
|
460
|
-
parent,
|
461
|
-
metric,
|
462
|
-
options: nil,
|
463
|
-
&block
|
464
|
-
req = {
|
465
|
-
parent: parent,
|
466
|
-
metric: metric
|
467
|
-
}.delete_if { |_, v| v.nil? }
|
468
|
-
req = Google::Gax::to_proto(req, Google::Logging::V2::CreateLogMetricRequest)
|
469
|
-
@create_log_metric.call(req, options, &block)
|
470
|
-
end
|
471
|
-
end
|
472
|
-
end
|
473
|
-
end
|
474
|
-
end
|
475
|
-
end
|