fluent-plugin-google-cloud 0.3.0 → 0.3.1

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.
@@ -0,0 +1,107 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-plugin-google-cloud (0.3.0)
5
+ fluentd (>= 0.10)
6
+ google-api-client (>= 0.8)
7
+ googleauth (~> 0.4)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (4.2.1)
13
+ i18n (~> 0.7)
14
+ json (~> 1.7, >= 1.7.7)
15
+ minitest (~> 5.1)
16
+ thread_safe (~> 0.3, >= 0.3.4)
17
+ tzinfo (~> 1.1)
18
+ addressable (2.3.8)
19
+ autoparse (0.3.3)
20
+ addressable (>= 2.3.1)
21
+ extlib (>= 0.9.15)
22
+ multi_json (>= 1.0.0)
23
+ cool.io (1.3.0)
24
+ crack (0.4.2)
25
+ safe_yaml (~> 1.0.0)
26
+ extlib (0.9.16)
27
+ faraday (0.9.1)
28
+ multipart-post (>= 1.2, < 3)
29
+ fluentd (0.12.8)
30
+ cool.io (>= 1.2.2, < 2.0.0)
31
+ http_parser.rb (>= 0.5.1, < 0.7.0)
32
+ json (>= 1.4.3)
33
+ msgpack (>= 0.5.11, < 0.6.0)
34
+ sigdump (~> 0.2.2)
35
+ string-scrub (>= 0.0.3)
36
+ tzinfo (>= 1.0.0)
37
+ tzinfo-data (>= 1.0.0)
38
+ yajl-ruby (~> 1.0)
39
+ google-api-client (0.8.6)
40
+ activesupport (>= 3.2)
41
+ addressable (~> 2.3)
42
+ autoparse (~> 0.3)
43
+ extlib (~> 0.9)
44
+ faraday (~> 0.9)
45
+ googleauth (~> 0.3)
46
+ launchy (~> 2.4)
47
+ multi_json (~> 1.10)
48
+ retriable (~> 1.4)
49
+ signet (~> 0.6)
50
+ googleauth (0.4.1)
51
+ faraday (~> 0.9)
52
+ jwt (~> 1.4)
53
+ logging (~> 2.0)
54
+ memoist (~> 0.12)
55
+ multi_json (= 1.11)
56
+ signet (~> 0.6)
57
+ http_parser.rb (0.6.0)
58
+ i18n (0.7.0)
59
+ json (1.8.2)
60
+ jwt (1.4.1)
61
+ launchy (2.4.3)
62
+ addressable (~> 2.3)
63
+ little-plugger (1.1.3)
64
+ logging (2.0.0)
65
+ little-plugger (~> 1.1)
66
+ multi_json (~> 1.10)
67
+ memoist (0.12.0)
68
+ metaclass (0.0.4)
69
+ minitest (5.6.1)
70
+ mocha (1.1.0)
71
+ metaclass (~> 0.0.1)
72
+ msgpack (0.5.11)
73
+ multi_json (1.11.0)
74
+ multipart-post (2.0.0)
75
+ power_assert (0.2.3)
76
+ rake (10.4.2)
77
+ retriable (1.4.1)
78
+ safe_yaml (1.0.4)
79
+ sigdump (0.2.2)
80
+ signet (0.6.0)
81
+ addressable (~> 2.3)
82
+ extlib (~> 0.9)
83
+ faraday (~> 0.9)
84
+ jwt (~> 1.0)
85
+ multi_json (~> 1.10)
86
+ string-scrub (0.0.5)
87
+ test-unit (3.0.9)
88
+ power_assert
89
+ thread_safe (0.3.5)
90
+ tzinfo (1.2.2)
91
+ thread_safe (~> 0.1)
92
+ tzinfo-data (1.2015.4)
93
+ tzinfo (>= 1.0.0)
94
+ webmock (1.21.0)
95
+ addressable (>= 2.3.6)
96
+ crack (>= 0.3.2)
97
+ yajl-ruby (1.2.1)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ fluent-plugin-google-cloud!
104
+ mocha (~> 1.1)
105
+ rake (>= 10.3.2)
106
+ test-unit (~> 3.0.2)
107
+ webmock (>= 1.17.0)
@@ -4,7 +4,7 @@ Gem::Specification.new do |gem|
4
4
  gem.summary = %q{Fluentd plugin to stream logs to the Google Cloud Platform's logging API}
5
5
  gem.homepage = 'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
6
6
  gem.license = 'Apache 2.0'
7
- gem.version = '0.3.0'
7
+ gem.version = '0.3.1'
8
8
  gem.authors = ['Todd Derr', 'Alex Robinson']
9
9
  gem.email = ['salty@google.com']
10
10
 
@@ -100,6 +100,7 @@ module Fluent
100
100
  init_api_client()
101
101
 
102
102
  @successful_call = false
103
+ @timenanos_warning = false
103
104
 
104
105
  if @use_metadata_service
105
106
  # Grab metadata about the Google Compute Engine instance that we're on.
@@ -167,10 +168,31 @@ module Fluent
167
168
  'entries' => [],
168
169
  }
169
170
  arr.each do |time, record|
170
- if (record.has_key?('timeNanos'))
171
+ next unless record.is_a? Hash
172
+ if (record.has_key?('timestamp') &&
173
+ record['timestamp'].has_key?('seconds') &&
174
+ record['timestamp'].has_key?('nanos'))
175
+ ts_secs = record['timestamp']['seconds']
176
+ ts_nanos = record['timestamp']['nanos']
177
+ record.delete('timestamp')
178
+ elsif (record.has_key?('timestampSeconds') &&
179
+ record.has_key?('timestampNanos'))
180
+ ts_secs = record['timestampSeconds']
181
+ ts_nanos = record['timestampNanos']
182
+ record.delete('timestampSeconds')
183
+ record.delete('timestampNanos')
184
+ elsif (record.has_key?('timeNanos'))
185
+ # This is deprecated since the precision is insufficient.
186
+ # Use timestampSeconds/timestampNanos instead
171
187
  ts_secs = (record['timeNanos'] / 1000000000).to_i
172
188
  ts_nanos = record['timeNanos'] % 1000000000
173
189
  record.delete('timeNanos')
190
+ if (!@timenanos_warning)
191
+ # Warn the user this is deprecated, but only once to avoid spam.
192
+ @timenanos_warning = true
193
+ $log.warn ("timeNanos is deprecated - please use " +
194
+ "timestampSeconds and timestampNanos instead.")
195
+ end
174
196
  else
175
197
  timestamp = Time.at(time)
176
198
  ts_secs = timestamp.tv_sec
@@ -203,6 +225,8 @@ module Fluent
203
225
  end
204
226
  write_log_entries_request['entries'].push(entry)
205
227
  end
228
+ # Don't send an empty request if we rejected all the entries.
229
+ next if write_log_entries_request['entries'].empty?
206
230
 
207
231
  # Add a prefix to VMEngines logs to prevent namespace collisions,
208
232
  # and also escape the log name.
@@ -264,7 +288,8 @@ module Fluent
264
288
  end
265
289
 
266
290
  def fetch_metadata(metadata_path)
267
- open('http://metadata/computeMetadata/v1/' + metadata_path,
291
+ # Fetch GCE metadata - see https://cloud.google.com/compute/docs/metadata
292
+ open('http://169.254.169.254/computeMetadata/v1/' + metadata_path,
268
293
  {'Metadata-Flavor' => 'Google'}) do |f|
269
294
  f.read
270
295
  end
@@ -335,7 +360,7 @@ module Fluent
335
360
  def init_api_client
336
361
  @client = Google::APIClient.new(
337
362
  :application_name => 'Fluentd Google Cloud Logging plugin',
338
- :application_version => '0.3.0',
363
+ :application_version => '0.3.1',
339
364
  :retries => 1)
340
365
 
341
366
  if @auth_method == 'private_key'
@@ -270,7 +270,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
270
270
  expected_ts = []
271
271
  emit_index = 0
272
272
  [Time.at(123456.789), Time.at(0), Time.now].each do |ts|
273
- # Test both the "native" fluentd timestamp and timeNanos.
273
+ # Test the "native" fluentd timestamp as well as our nanosecond tags.
274
274
  d.emit({'message' => log_entry(emit_index)}, ts.to_f)
275
275
  # The native timestamp currently only supports second granularity
276
276
  # (fluentd issue #461), so strip nanoseconds from the expected value.
@@ -280,6 +280,14 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
280
280
  'timeNanos' => ts.tv_sec * 1000000000 + ts.tv_nsec})
281
281
  expected_ts.push(ts)
282
282
  emit_index += 1
283
+ d.emit({'message' => log_entry(emit_index),
284
+ 'timestamp' => {'seconds' => ts.tv_sec, 'nanos' => ts.tv_nsec}})
285
+ expected_ts.push(ts)
286
+ emit_index += 1
287
+ d.emit({'message' => log_entry(emit_index),
288
+ 'timestampSeconds' => ts.tv_sec, 'timestampNanos' => ts.tv_nsec})
289
+ expected_ts.push(ts)
290
+ emit_index += 1
283
291
  end
284
292
  d.run
285
293
  verify_index = 0
@@ -330,6 +338,16 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
330
338
  end
331
339
  end
332
340
 
341
+ def test_malformed_log
342
+ setup_gce_metadata_stubs
343
+ setup_logging_stubs
344
+ d = create_driver()
345
+ # if the entry is not a hash, the plugin should silently drop it.
346
+ d.emit("a string is not a valid message")
347
+ d.run
348
+ assert @logs_sent.empty?
349
+ end
350
+
333
351
  def test_client_error
334
352
  setup_gce_metadata_stubs
335
353
  # The API Client should not retry this and the plugin should consume
@@ -511,7 +529,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
511
529
  end
512
530
 
513
531
  def stub_metadata_request(metadata_path, response_body)
514
- stub_request(:get, 'http://metadata/computeMetadata/v1/' + metadata_path).
532
+ stub_request(:get, 'http://169.254.169.254/computeMetadata/v1/' + metadata_path).
515
533
  to_return(:body => response_body, :status => 200,
516
534
  :headers => {'Content-Length' => response_body.length})
517
535
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-google-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-08 00:00:00.000000000 Z
13
+ date: 2015-05-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd
@@ -144,6 +144,7 @@ files:
144
144
  - fluent-plugin-google-cloud.gemspec
145
145
  - lib/fluent/plugin/out_google_cloud.rb
146
146
  - CONTRIBUTING
147
+ - Gemfile.lock
147
148
  - Gemfile
148
149
  - README.rdoc
149
150
  homepage: https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud