fluent-plugin-google-cloud 0.7.25 → 0.7.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89427f2aab235046a1d959d81d19a26fceeb0d4c54dae2df843d5fe70173066f
4
- data.tar.gz: 6f79fae5f86701f8f5a1bf2bbb9cb591d8015bebe4e5265802fd082809d32ba7
3
+ metadata.gz: 290b02a112003353bd252ef93c3396da3365ccaaf526eba52714e7fce67237dc
4
+ data.tar.gz: b822671a321a196e99de4b4ca2d544d0d80b896e44c44329847ffe8b028f98e9
5
5
  SHA512:
6
- metadata.gz: aa43b2f4f2e41bb8f8dcb47d1e02681c2e186227c8f88fcd3796187bf20e5f7896b59d1251123629172e6e2c5d11e3a390ff91adf92be54eaec19684176a6df7
7
- data.tar.gz: beb857a9ef37a97ff7124bc35ac3de2108e0fa203a70165f36db09d49253285120a41c81028af5379480c379e66753e69f4f734fc7d945e757bf9f265df2e858
6
+ metadata.gz: 5ee271add74cdfd193f5ab944a9ee3d0e7e6af460d3ce7e52b2dbdccea087cfc675091fac1096beed80d798dbacde92e1aeb1c2bb778d33ccbf59f444be04c90
7
+ data.tar.gz: e30da388572c84243d5616701e4fb6ae8b282289c36eae355a3c8141afb72fe017bae2974c9c91504ef4cf42ef52d50457b400d8840ee79344281cc4fd9d5e95
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-google-cloud (0.7.25)
4
+ fluent-plugin-google-cloud (0.7.26)
5
5
  fluentd (= 1.6.3)
6
6
  google-api-client (= 0.30.8)
7
7
  google-cloud-logging (= 1.6.6)
@@ -131,7 +131,7 @@ GEM
131
131
  unicode-display_width (~> 1.0, >= 1.0.1)
132
132
  ruby-progressbar (1.10.1)
133
133
  safe_yaml (1.0.5)
134
- serverengine (2.1.1)
134
+ serverengine (2.2.0)
135
135
  sigdump (~> 0.2.2)
136
136
  sigdump (0.2.4)
137
137
  signet (0.12.0)
@@ -10,7 +10,7 @@ eos
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.7.25'
13
+ gem.version = '0.7.26'
14
14
  gem.authors = ['Stackdriver Agents Team']
15
15
  gem.email = ['stackdriver-agents@google.com']
16
16
  gem.required_ruby_version = Gem::Requirement.new('>= 2.2')
@@ -15,8 +15,7 @@
15
15
  module Monitoring
16
16
  # Base class for the counter.
17
17
  class BaseCounter
18
- def increment(_by: 1, _labels: {})
19
- nil
18
+ def increment(*)
20
19
  end
21
20
  end
22
21
 
@@ -54,7 +53,7 @@ module Monitoring
54
53
  end
55
54
 
56
55
  def counter(_name, _labels, _docstring)
57
- nil
56
+ BaseCounter.new
58
57
  end
59
58
 
60
59
  def export
@@ -254,6 +254,7 @@ module Fluent
254
254
 
255
255
  PLUGIN_NAME = 'Fluentd Google Cloud Logging plugin'.freeze
256
256
 
257
+ # Follows semver.org format.
257
258
  PLUGIN_VERSION = begin
258
259
  # Extract plugin version from file path.
259
260
  match_data = __FILE__.match(
@@ -268,7 +269,9 @@ module Fluent
268
269
  proc { |spec,| __FILE__.include?(spec.full_gem_path) }) do |spec,|
269
270
  spec.version.to_s
270
271
  end
271
- matching_version
272
+ # If no matching version was found, return a valid but obviously wrong
273
+ # value.
274
+ matching_version || '0.0.0-unknown'
272
275
  end
273
276
  end.freeze
274
277
 
@@ -481,6 +484,7 @@ module Fluent
481
484
  @retried_entries_count = nil
482
485
 
483
486
  @ok_code = nil
487
+ @uptime_update_time = Time.now.to_i
484
488
  end
485
489
 
486
490
  def configure(conf)
@@ -553,6 +557,12 @@ module Fluent
553
557
  .create(@monitoring_type, @project_id, @resource)
554
558
  # Export metrics every 60 seconds.
555
559
  timer_execute(:export_metrics, 60) { @registry.export }
560
+ # Uptime should be a gauge, but the metric definition is a counter and
561
+ # we can't change it.
562
+ @uptime_metric = @registry.counter(
563
+ :uptime, [:version], 'Uptime of Logging agent')
564
+ update_uptime
565
+ timer_execute(:update_uptime, 1) { update_uptime }
556
566
  @successful_requests_count = @registry.counter(
557
567
  :stackdriver_successful_requests_count,
558
568
  [:grpc, :code],
@@ -773,6 +783,18 @@ module Fluent
773
783
  true
774
784
  end
775
785
 
786
+ def self.version_string
787
+ @version_string ||= "google-fluentd/#{PLUGIN_VERSION}"
788
+ end
789
+
790
+ def update_uptime
791
+ now = Time.now.to_i
792
+ @uptime_metric.increment(
793
+ by: now - @uptime_update_time,
794
+ labels: { version: Fluent::GoogleCloudOutput.version_string })
795
+ @uptime_update_time = now
796
+ end
797
+
776
798
  private
777
799
 
778
800
  def write_html_response(data, conn, code, response)
@@ -2046,6 +2046,30 @@ module BaseTest
2046
2046
  end
2047
2047
  end
2048
2048
 
2049
+ def test_uptime_metric
2050
+ setup_gce_metadata_stubs
2051
+ [
2052
+ [ENABLE_PROMETHEUS_CONFIG, method(:assert_prometheus_metric_value)],
2053
+ [ENABLE_OPENCENSUS_CONFIG, method(:assert_opencensus_metric_value)]
2054
+ ].each do |config, assert_metric_value|
2055
+ clear_metrics
2056
+ start_time = Time.now.to_i
2057
+ d = create_driver(config)
2058
+ d.run
2059
+ begin
2060
+ # Retry to protect from time races.
2061
+ retries ||= 0
2062
+ expected = Time.now.to_i - start_time
2063
+ d.instance.update_uptime
2064
+ assert_metric_value.call(
2065
+ :uptime, expected, version: Fluent::GoogleCloudOutput.version_string)
2066
+ rescue Test::Unit::AssertionFailedError
2067
+ retry if (retries += 1) < 3
2068
+ end
2069
+ assert_not_equal 3, retries
2070
+ end
2071
+ end
2072
+
2049
2073
  private
2050
2074
 
2051
2075
  def stub_metadata_request(metadata_path, response_body)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-google-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.25
4
+ version: 0.7.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stackdriver Agents Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-09 00:00:00.000000000 Z
11
+ date: 2019-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd