fluent-plugin-google-cloud 0.12.10 → 0.12.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bbc10ef9a5f3f10b7a2557bf3876dd63a613423f1294504fdda212bc986ed6d
4
- data.tar.gz: ae2e397ebc1fc18b2e97c1e1553a8eee3d782bc2160850344bb7bf4126c6263c
3
+ metadata.gz: fa2b2de4444cf81be485251db598ee31599684827a2c4ecef5227e1254622aa6
4
+ data.tar.gz: 0d11b11e1f6fcdbb6d712133f911c15eb968f74e020dbfa98a30cfb6e5717602
5
5
  SHA512:
6
- metadata.gz: 1363d1c35d8a1dc951f8c4c373d59a7c893fba8e8fcc0bf3d4d0f5463b3f00ff407351e7fd21f1fbc7a2c89481f273b59a2b3e1ae7035417dc74cdcce5bc9ced
7
- data.tar.gz: edb5f975479e4aa0a814fe51808bfeb3d875842aea757f162da8f807c49d974905f6d27c6eae7d0185bb5b5a63f942326156e7e9b3e0f2d08f5f738f0c4e8f24
6
+ metadata.gz: ca9bf71962b1f2f19270a278f12d4c4e4626bc8f7e0bfc235802ae24f95ae7e65f44243c6600d8f23fedbdcdd840b4fce53b3ccddb4a454806cf32286b3d7ed8
7
+ data.tar.gz: 64cf9cd901800e5ea6711356101c8a39a1310ef99c17e34fd2a3676629abc2a32ad4a60af709d57749953c14e7f6dcad5d01c14880a3e0781e09579924fe8cc7
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-google-cloud (0.12.10)
4
+ fluent-plugin-google-cloud (0.12.11)
5
5
  fluentd (= 1.13.3)
6
- google-api-client (= 0.30.8)
6
+ google-api-client (= 0.44.2)
7
7
  google-cloud-logging (= 1.6.6)
8
8
  google-protobuf (= 3.20.0)
9
9
  googleapis-common-protos (= 1.3.10)
10
10
  googleauth (= 0.9.0)
11
11
  grpc (= 1.45.0)
12
- json (= 2.2.0)
12
+ json (= 2.6.3)
13
13
  opencensus (= 0.5.0)
14
14
  opencensus-stackdriver (= 0.4.1)
15
15
 
@@ -51,14 +51,15 @@ GEM
51
51
  googleapis-common-protos-types (>= 1.0.4, < 2.0)
52
52
  googleauth (~> 0.9)
53
53
  grpc (~> 1.25)
54
- google-api-client (0.30.8)
54
+ google-api-client (0.44.2)
55
55
  addressable (~> 2.5, >= 2.5.1)
56
- googleauth (>= 0.5, < 0.10.0)
56
+ googleauth (~> 0.9)
57
57
  httpclient (>= 2.8.1, < 3.0)
58
58
  mini_mime (~> 1.0)
59
59
  representable (~> 3.0)
60
60
  retriable (>= 2.0, < 4.0)
61
- signet (~> 0.10)
61
+ rexml
62
+ signet (~> 0.12)
62
63
  google-cloud-core (1.6.0)
63
64
  google-cloud-env (~> 1.0)
64
65
  google-cloud-errors (~> 1.0)
@@ -104,7 +105,7 @@ GEM
104
105
  hashdiff (1.0.1)
105
106
  http_parser.rb (0.7.0)
106
107
  httpclient (2.8.3)
107
- json (2.2.0)
108
+ json (2.6.3)
108
109
  jwt (2.7.0)
109
110
  memoist (0.16.2)
110
111
  metaclass (0.0.4)
@@ -122,17 +123,17 @@ GEM
122
123
  google-cloud-trace-v2 (~> 0.1)
123
124
  opencensus (~> 0.5)
124
125
  os (1.1.4)
125
- parser (2.7.2.0)
126
+ parallel (1.22.1)
127
+ parser (3.2.1.1)
126
128
  ast (~> 2.4.1)
127
129
  power_assert (2.0.3)
128
- powerpack (0.1.3)
129
130
  prometheus-client (0.9.0)
130
131
  quantile (~> 0.2.1)
131
132
  public_suffix (5.0.1)
132
133
  quantile (0.2.1)
133
- rainbow (2.2.2)
134
- rake
134
+ rainbow (3.1.1)
135
135
  rake (10.5.0)
136
+ regexp_parser (2.7.0)
136
137
  representable (3.2.0)
137
138
  declarative (< 0.1.0)
138
139
  trailblazer-option (>= 0.1.1, < 0.2.0)
@@ -140,12 +141,18 @@ GEM
140
141
  retriable (3.1.2)
141
142
  rexml (3.2.5)
142
143
  rly (0.2.3)
143
- rubocop (0.39.0)
144
- parser (>= 2.3.0.7, < 3.0)
145
- powerpack (~> 0.1)
146
- rainbow (>= 1.99.1, < 3.0)
144
+ rubocop (1.48.1)
145
+ json (~> 2.3)
146
+ parallel (~> 1.10)
147
+ parser (>= 3.2.0.0)
148
+ rainbow (>= 2.2.2, < 4.0)
149
+ regexp_parser (>= 1.8, < 3.0)
150
+ rexml (>= 3.2.5, < 4.0)
151
+ rubocop-ast (>= 1.26.0, < 2.0)
147
152
  ruby-progressbar (~> 1.7)
148
- unicode-display_width (~> 1.0, >= 1.0.1)
153
+ unicode-display_width (>= 2.4.0, < 3.0)
154
+ rubocop-ast (1.28.0)
155
+ parser (>= 3.2.1.0)
149
156
  ruby-progressbar (1.13.0)
150
157
  serverengine (2.3.2)
151
158
  sigdump (~> 0.2.2)
@@ -174,10 +181,10 @@ GEM
174
181
  trailblazer-option (0.1.2)
175
182
  tzinfo (2.0.6)
176
183
  concurrent-ruby (~> 1.0)
177
- tzinfo-data (1.2022.7)
184
+ tzinfo-data (1.2023.2)
178
185
  tzinfo (>= 1.0.0)
179
186
  uber (0.1.0)
180
- unicode-display_width (1.8.0)
187
+ unicode-display_width (2.4.2)
181
188
  webmock (3.6.2)
182
189
  addressable (>= 2.3.6)
183
190
  crack (>= 0.3.2)
@@ -194,7 +201,7 @@ DEPENDENCIES
194
201
  mocha (= 1.9.0)
195
202
  prometheus-client (< 0.10)
196
203
  rake (= 10.5.0)
197
- rubocop (= 0.39.0)
204
+ rubocop (= 1.48.1)
198
205
  test-unit (= 3.3.3)
199
206
  webmock (= 3.6.2)
200
207
 
data/Rakefile CHANGED
@@ -28,15 +28,16 @@ task :fix_perms do
28
28
  end
29
29
 
30
30
  files.each do |file|
31
- mode = File.stat(file).mode & 0777
32
- next unless mode & 0444 != 0444
31
+ mode = File.stat(file).mode & 0o777
32
+ next unless mode & 0o444 != 0o444
33
+
33
34
  puts "Changing mode of #{file} from #{mode.to_s(8)} to "\
34
- "#{(mode | 0444).to_s(8)}"
35
- chmod mode | 0444, file
35
+ "#{(mode | 0o444).to_s(8)}"
36
+ chmod mode | 0o444, file
36
37
  end
37
38
  end
38
39
 
39
40
  desc 'Run unit tests and RuboCop to check for style violations'
40
- task all: [:rubocop, :test, :fix_perms]
41
+ task all: %i[rubocop test fix_perms]
41
42
 
42
43
  task default: :all
@@ -1,35 +1,35 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'fluent-plugin-google-cloud'
3
- gem.description = <<-eos
3
+ gem.description = <<-DESCRIPTION
4
4
  Fluentd plugins for the Stackdriver Logging API, which will make logs
5
5
  viewable in the Stackdriver Logs Viewer and can optionally store them
6
6
  in Google Cloud Storage and/or BigQuery.
7
7
  This is an official Google Ruby gem.
8
- eos
8
+ DESCRIPTION
9
9
  gem.summary = 'fluentd plugins for the Stackdriver Logging API'
10
10
  gem.homepage =
11
11
  'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
12
12
  gem.license = 'Apache-2.0'
13
- gem.version = '0.12.10'
13
+ gem.version = '0.12.11'
14
14
  gem.authors = ['Stackdriver Agents Team']
15
15
  gem.email = ['stackdriver-agents@google.com']
16
- gem.required_ruby_version = Gem::Requirement.new('>= 2.2')
16
+ gem.required_ruby_version = Gem::Requirement.new('>= 2.6')
17
17
 
18
18
  gem.files = Dir['**/*'].keep_if { |file| File.file?(file) }
19
19
  gem.test_files = gem.files.grep(/^(test)/)
20
20
  gem.require_paths = ['lib']
21
21
 
22
- # Note: In order to update the Fluentd version, please update both here and
22
+ # NOTE: In order to update the Fluentd version, please update both here and
23
23
  # also the fluentd version in
24
24
  # https://github.com/GoogleCloudPlatform/google-fluentd/blob/master/config/software/fluentd.rb.
25
25
  gem.add_runtime_dependency 'fluentd', '1.13.3'
26
+ gem.add_runtime_dependency 'google-api-client', '0.44.2'
26
27
  gem.add_runtime_dependency 'googleapis-common-protos', '1.3.10'
27
28
  gem.add_runtime_dependency 'googleauth', '0.9.0'
28
- gem.add_runtime_dependency 'google-api-client', '0.30.8'
29
29
  gem.add_runtime_dependency 'google-cloud-logging', '1.6.6'
30
30
  gem.add_runtime_dependency 'google-protobuf', '3.20.0'
31
31
  gem.add_runtime_dependency 'grpc', '1.45.0'
32
- gem.add_runtime_dependency 'json', '2.2.0'
32
+ gem.add_runtime_dependency 'json', '2.6.3'
33
33
  gem.add_runtime_dependency 'opencensus', '0.5.0'
34
34
  gem.add_runtime_dependency 'opencensus-stackdriver', '0.4.1'
35
35
 
@@ -42,9 +42,9 @@ eos
42
42
  # initialized.
43
43
  # https://github.com/googleapis/google-auth-library-ruby/issues/227
44
44
  # https://github.com/farcaller/rly/issues/2
45
+ gem.add_development_dependency 'coveralls', '0.8.23'
45
46
  gem.add_development_dependency 'rake', '10.5.0'
46
- gem.add_development_dependency 'rubocop', '0.39.0'
47
+ gem.add_development_dependency 'rubocop', '1.48.1'
47
48
  gem.add_development_dependency 'test-unit', '3.3.3'
48
49
  gem.add_development_dependency 'webmock', '3.6.2'
49
- gem.add_development_dependency 'coveralls', '0.8.23'
50
50
  end
@@ -12,13 +12,15 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require 'uri'
16
+
15
17
  module Common
16
18
  # Constants for service names, resource types and etc.
17
19
  module ServiceConstants
18
20
  APPENGINE_CONSTANTS = {
19
21
  service: 'appengine.googleapis.com',
20
22
  resource_type: 'gae_app',
21
- metadata_attributes: %w(gae_backend_name gae_backend_version)
23
+ metadata_attributes: %w[gae_backend_name gae_backend_version]
22
24
  }.freeze
23
25
  COMPUTE_CONSTANTS = {
24
26
  service: 'compute.googleapis.com',
@@ -27,9 +29,9 @@ module Common
27
29
  GKE_CONSTANTS = {
28
30
  service: 'container.googleapis.com',
29
31
  resource_type: 'gke_container',
30
- extra_resource_labels: %w(namespace_id pod_id container_name),
31
- extra_common_labels: %w(namespace_name pod_name),
32
- metadata_attributes: %w(cluster-name cluster-location),
32
+ extra_resource_labels: %w[namespace_id pod_id container_name],
33
+ extra_common_labels: %w[namespace_name pod_name],
34
+ metadata_attributes: %w[cluster-name cluster-location],
33
35
  stream_severity_map: {
34
36
  'stdout' => 'INFO',
35
37
  'stderr' => 'ERROR'
@@ -47,12 +49,12 @@ module Common
47
49
  DATAFLOW_CONSTANTS = {
48
50
  service: 'dataflow.googleapis.com',
49
51
  resource_type: 'dataflow_step',
50
- extra_resource_labels: %w(region job_name job_id step_id)
52
+ extra_resource_labels: %w[region job_name job_id step_id]
51
53
  }.freeze
52
54
  DATAPROC_CONSTANTS = {
53
55
  service: 'cluster.dataproc.googleapis.com',
54
56
  resource_type: 'cloud_dataproc_cluster',
55
- metadata_attributes: %w(dataproc-cluster-uuid dataproc-cluster-name)
57
+ metadata_attributes: %w[dataproc-cluster-uuid dataproc-cluster-name]
56
58
  }.freeze
57
59
  EC2_CONSTANTS = {
58
60
  service: 'ec2.amazonaws.com',
@@ -61,7 +63,7 @@ module Common
61
63
  ML_CONSTANTS = {
62
64
  service: 'ml.googleapis.com',
63
65
  resource_type: 'ml_job',
64
- extra_resource_labels: %w(job_id task_name)
66
+ extra_resource_labels: %w[job_id task_name]
65
67
  }.freeze
66
68
 
67
69
  # The map between a subservice name and a resource type.
@@ -111,7 +113,7 @@ module Common
111
113
  end
112
114
 
113
115
  begin
114
- open('http://' + METADATA_SERVICE_ADDR, proxy: false) do |f|
116
+ URI.open("http://#{METADATA_SERVICE_ADDR}", proxy: false) do |f|
115
117
  if f.meta['metadata-flavor'] == 'Google'
116
118
  @log.info 'Detected GCE platform'
117
119
  return Platform::GCE
@@ -132,10 +134,10 @@ module Common
132
134
  def fetch_gce_metadata(platform, metadata_path)
133
135
  raise "Called fetch_gce_metadata with platform=#{platform}" unless
134
136
  platform == Platform::GCE
137
+
135
138
  # See https://cloud.google.com/compute/docs/metadata
136
- open('http://' + METADATA_SERVICE_ADDR + '/computeMetadata/v1/' +
137
- metadata_path, 'Metadata-Flavor' => 'Google', :proxy => false,
138
- &:read)
139
+ URI.open("http://#{METADATA_SERVICE_ADDR}/computeMetadata/v1/#{metadata_path}",
140
+ 'Metadata-Flavor' => 'Google', :proxy => false, &:read)
139
141
  end
140
142
 
141
143
  # EC2 Metadata server returns everything in one call. Store it after the
@@ -143,10 +145,10 @@ module Common
143
145
  def ec2_metadata(platform)
144
146
  raise "Called ec2_metadata with platform=#{platform}" unless
145
147
  platform == Platform::EC2
148
+
146
149
  unless @ec2_metadata
147
150
  # See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
148
- open('http://' + METADATA_SERVICE_ADDR +
149
- '/latest/dynamic/instance-identity/document', proxy: false) do |f|
151
+ URI.open("http://#{METADATA_SERVICE_ADDR}/latest/dynamic/instance-identity/document", proxy: false) do |f|
150
152
  contents = f.read
151
153
  @ec2_metadata = JSON.parse(contents)
152
154
  end
@@ -164,6 +166,7 @@ module Common
164
166
  missing << 'vm_id' unless vm_id
165
167
  end
166
168
  return if missing.empty?
169
+
167
170
  raise Fluent::ConfigError,
168
171
  "Unable to obtain metadata parameters: #{missing.join(' ')}"
169
172
  end
@@ -203,15 +206,16 @@ module Common
203
206
  # 2. If not, try to retrieve it locally.
204
207
  def get_location(platform, zone, use_aws_availability_zone)
205
208
  # Response format: "projects/<number>/zones/<zone>"
206
- zone ||= fetch_gce_metadata(platform,
207
- 'instance/zone').rpartition('/')[2] if
208
- platform == Platform::GCE
209
+ if platform == Platform::GCE
210
+ zone ||= fetch_gce_metadata(platform,
211
+ 'instance/zone').rpartition('/')[2]
212
+ end
209
213
  aws_location_key = if use_aws_availability_zone
210
214
  'availabilityZone'
211
215
  else
212
216
  'region'
213
217
  end
214
- zone ||= 'aws:' + ec2_metadata(platform)[aws_location_key] if
218
+ zone ||= "aws:#{ec2_metadata(platform)[aws_location_key]}" if
215
219
  platform == Platform::EC2 &&
216
220
  ec2_metadata(platform).key?(aws_location_key)
217
221
  zone
@@ -222,7 +226,8 @@ module Common
222
226
  # Create a monitored resource from type and labels.
223
227
  def create_monitored_resource(type, labels)
224
228
  Google::Apis::LoggingV2::MonitoredResource.new(
225
- type: type, labels: labels.to_h)
229
+ type: type, labels: labels.to_h
230
+ )
226
231
  end
227
232
 
228
233
  # Retrieve monitored resource via the legacy way.
@@ -231,25 +236,30 @@ module Common
231
236
  # Metadata Agent. Thus it should be equivalent to what Metadata Agent
232
237
  # returns.
233
238
  def determine_agent_level_monitored_resource_via_legacy(
234
- platform, subservice_name, detect_subservice, vm_id, zone)
239
+ platform, subservice_name, detect_subservice, vm_id, zone
240
+ )
235
241
  resource_type = determine_agent_level_monitored_resource_type(
236
- platform, subservice_name, detect_subservice)
242
+ platform, subservice_name, detect_subservice
243
+ )
237
244
  create_monitored_resource(
238
245
  resource_type,
239
246
  determine_agent_level_monitored_resource_labels(
240
- platform, resource_type, vm_id, zone))
247
+ platform, resource_type, vm_id, zone
248
+ )
249
+ )
241
250
  end
242
251
 
243
252
  # Determine agent level monitored resource type.
244
253
  def determine_agent_level_monitored_resource_type(
245
- platform, subservice_name, detect_subservice)
254
+ platform, subservice_name, detect_subservice
255
+ )
246
256
  case platform
247
257
  when Platform::OTHER
248
258
  # Unknown platform will be defaulted to GCE instance.
249
- return COMPUTE_CONSTANTS[:resource_type]
259
+ COMPUTE_CONSTANTS[:resource_type]
250
260
 
251
261
  when Platform::EC2
252
- return EC2_CONSTANTS[:resource_type]
262
+ EC2_CONSTANTS[:resource_type]
253
263
 
254
264
  when Platform::GCE
255
265
  # Resource types determined by subservice_name config.
@@ -269,14 +279,15 @@ module Common
269
279
  end
270
280
 
271
281
  # GCE instance.
272
- return COMPUTE_CONSTANTS[:resource_type]
282
+ COMPUTE_CONSTANTS[:resource_type]
273
283
  end
274
284
  end
275
285
 
276
286
  # Determine agent level monitored resource labels based on the resource
277
287
  # type. Each resource type has its own labels that need to be filled in.
278
288
  def determine_agent_level_monitored_resource_labels(
279
- platform, type, vm_id, zone)
289
+ platform, type, vm_id, zone
290
+ )
280
291
  case type
281
292
  # GAE app.
282
293
  when APPENGINE_CONSTANTS[:resource_type]
@@ -293,6 +304,7 @@ module Common
293
304
  when COMPUTE_CONSTANTS[:resource_type]
294
305
  raise "Cannot construct a #{type} resource without vm_id and zone" \
295
306
  unless vm_id && zone
307
+
296
308
  return {
297
309
  'instance_id' => vm_id,
298
310
  'zone' => zone
@@ -302,6 +314,7 @@ module Common
302
314
  when GKE_CONSTANTS[:resource_type]
303
315
  raise "Cannot construct a #{type} resource without vm_id and zone" \
304
316
  unless vm_id && zone
317
+
305
318
  return {
306
319
  'instance_id' => vm_id,
307
320
  'zone' => zone,
@@ -327,6 +340,7 @@ module Common
327
340
  when EC2_CONSTANTS[:resource_type]
328
341
  raise "Cannot construct a #{type} resource without vm_id and zone" \
329
342
  unless vm_id && zone
343
+
330
344
  labels = {
331
345
  'instance_id' => vm_id,
332
346
  'region' => zone
@@ -352,9 +366,8 @@ module Common
352
366
  # Returns the project ID (as a string) on success, or nil on failure.
353
367
  def self.project_id
354
368
  creds = Google::Auth.get_application_default(LOGGING_SCOPE)
355
- if creds.respond_to?(:project_id)
356
- return creds.project_id if creds.project_id
357
- end
369
+ return creds.project_id if creds.respond_to?(:project_id) && creds.project_id
370
+
358
371
  if creds.issuer
359
372
  id = extract_project_id(creds.issuer)
360
373
  return id unless id.nil?
@@ -65,21 +65,11 @@ module Fluent
65
65
  @log.info "Initialized the insert ID key to #{@insert_id}."
66
66
  end
67
67
 
68
- def configure(conf)
69
- super
70
- end
71
-
72
- def shutdown
73
- super
74
- end
75
-
76
68
  # rubocop:disable Lint/UnusedMethodArgument
77
69
  def filter(tag, time, record)
78
70
  # Only generate and add an insertId field if the record is a hash and
79
71
  # the insert ID field is not already set (or set to an empty string).
80
- if record.is_a?(Hash) && record[@insert_id_key].to_s.empty?
81
- record[@insert_id_key] = increment_insert_id
82
- end
72
+ record[@insert_id_key] = increment_insert_id if record.is_a?(Hash) && record[@insert_id_key].to_s.empty?
83
73
  record
84
74
  end
85
75
  # rubocop:enable Lint/UnusedMethodArgument