fluent-plugin-google-cloud 0.7.20 → 0.7.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/fluent-plugin-google-cloud.gemspec +4 -2
- data/lib/fluent/plugin/monitoring.rb +22 -4
- data/lib/fluent/plugin/out_google_cloud.rb +20 -11
- data/test/plugin/test_driver.rb +14 -1
- data/test/plugin/test_out_google_cloud.rb +0 -6
- data/test/plugin/test_out_google_cloud_grpc.rb +0 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c02beaaa9eb340a7d8cc14d8306adbf706734056c1cf8bd5737e5a4dcf36db8
|
4
|
+
data.tar.gz: b3747ea4d2a10db6b9eb5b2a4b27ad6231e35d339d36a2571f02b803229b7aaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9e660a5b707978a7b910a7df0f815509c92a5e5477f7cd0d9697fdb52d785e4d8a75601c8defcd3f2d97b6a32acc61ee0e1b1f93741f8b8301cf9468bafe6e
|
7
|
+
data.tar.gz: 8dceed3247b00d18d60dd2a222a320d444000ebef37a563de037b41c36ee4a5ef912865ac098c7e1f47c80dc8d21885438bab4867ae87c4785f53375a769c8e3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-google-cloud (0.7.
|
4
|
+
fluent-plugin-google-cloud (0.7.21)
|
5
5
|
fluentd (= 1.6.3)
|
6
6
|
google-api-client (= 0.30.8)
|
7
7
|
google-cloud-logging (= 1.6.6)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
declarative (0.0.10)
|
25
25
|
declarative-option (0.1.0)
|
26
26
|
dig_rb (1.0.1)
|
27
|
-
faraday (0.
|
27
|
+
faraday (0.17.0)
|
28
28
|
multipart-post (>= 1.2, < 3)
|
29
29
|
fluentd (1.6.3)
|
30
30
|
cool.io (>= 1.4.5, < 2.0.0)
|
@@ -120,7 +120,7 @@ GEM
|
|
120
120
|
serverengine (2.1.1)
|
121
121
|
sigdump (~> 0.2.2)
|
122
122
|
sigdump (0.2.4)
|
123
|
-
signet (0.
|
123
|
+
signet (0.12.0)
|
124
124
|
addressable (~> 2.3)
|
125
125
|
faraday (~> 0.9)
|
126
126
|
jwt (>= 1.5, < 3.0)
|
@@ -149,7 +149,7 @@ PLATFORMS
|
|
149
149
|
DEPENDENCIES
|
150
150
|
fluent-plugin-google-cloud!
|
151
151
|
mocha (= 1.9.0)
|
152
|
-
prometheus-client (
|
152
|
+
prometheus-client (< 0.10)
|
153
153
|
rake (= 10.5.0)
|
154
154
|
rubocop (= 0.39.0)
|
155
155
|
test-unit (= 3.3.3)
|
@@ -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.
|
13
|
+
gem.version = '0.7.21'
|
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')
|
@@ -29,7 +29,9 @@ eos
|
|
29
29
|
gem.add_runtime_dependency 'json', '2.2.0'
|
30
30
|
|
31
31
|
gem.add_development_dependency 'mocha', '1.9.0'
|
32
|
-
|
32
|
+
# Keep this the same as in
|
33
|
+
# https://github.com/fluent/fluent-plugin-prometheus/blob/master/fluent-plugin-prometheus.gemspec
|
34
|
+
gem.add_development_dependency 'prometheus-client', '< 0.10'
|
33
35
|
# TODO(qingling128): Upgrade rake to 11.0+ after the following issues are
|
34
36
|
# fixed because rake (11.0+) requires ALL variables to be explicitly
|
35
37
|
# initialized.
|
@@ -13,9 +13,27 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
module Monitoring
|
16
|
+
# Base class for the counter.
|
17
|
+
class BaseCounter
|
18
|
+
def increment(_by: 1, _labels: {})
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Prometheus implementation of counters.
|
24
|
+
class PrometheusCounter < BaseCounter
|
25
|
+
def initialize(prometheus_counter)
|
26
|
+
@counter = prometheus_counter
|
27
|
+
end
|
28
|
+
|
29
|
+
def increment(by: 1, labels: {})
|
30
|
+
@counter.increment(labels, by)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
16
34
|
# Base class for the monitoring registry.
|
17
35
|
class BaseMonitoringRegistry
|
18
|
-
def counter(_name,
|
36
|
+
def counter(_name, _labels, _docstring)
|
19
37
|
nil
|
20
38
|
end
|
21
39
|
end
|
@@ -33,10 +51,10 @@ module Monitoring
|
|
33
51
|
end
|
34
52
|
|
35
53
|
# Exception-driven behavior to avoid synchronization errors.
|
36
|
-
def counter(name,
|
37
|
-
return @registry.counter(name,
|
54
|
+
def counter(name, labels, docstring)
|
55
|
+
return PrometheusCounter.new(@registry.counter(name, docstring, labels))
|
38
56
|
rescue Prometheus::Client::Registry::AlreadyRegisteredError
|
39
|
-
return @registry.get(name)
|
57
|
+
return PrometheusCounter.new(@registry.get(name))
|
40
58
|
end
|
41
59
|
end
|
42
60
|
|
@@ -508,22 +508,27 @@ module Fluent
|
|
508
508
|
registry = Monitoring::MonitoringRegistryFactory.create @monitoring_type
|
509
509
|
@successful_requests_count = registry.counter(
|
510
510
|
:stackdriver_successful_requests_count,
|
511
|
+
[:grpc, :code],
|
511
512
|
'A number of successful requests to the Stackdriver Logging API')
|
512
513
|
@failed_requests_count = registry.counter(
|
513
514
|
:stackdriver_failed_requests_count,
|
514
|
-
|
515
|
-
|
515
|
+
[:grpc, :code],
|
516
|
+
'A number of failed requests to the Stackdriver Logging '\
|
517
|
+
'API, broken down by the error code')
|
516
518
|
@ingested_entries_count = registry.counter(
|
517
519
|
:stackdriver_ingested_entries_count,
|
520
|
+
[:grpc, :code],
|
518
521
|
'A number of log entries ingested by Stackdriver Logging')
|
519
522
|
@dropped_entries_count = registry.counter(
|
520
523
|
:stackdriver_dropped_entries_count,
|
524
|
+
[:grpc, :code],
|
521
525
|
'A number of log entries dropped by the Stackdriver output plugin')
|
522
526
|
@retried_entries_count = registry.counter(
|
523
527
|
:stackdriver_retried_entries_count,
|
524
|
-
|
525
|
-
|
526
|
-
|
528
|
+
[:grpc, :code],
|
529
|
+
'The number of log entries that failed to be ingested by '\
|
530
|
+
'the Stackdriver output plugin due to a transient error '\
|
531
|
+
'and were retried')
|
527
532
|
@ok_code = @use_grpc ? GRPC::Core::StatusCodes::OK : 200
|
528
533
|
end
|
529
534
|
|
@@ -2363,36 +2368,40 @@ module Fluent
|
|
2363
2368
|
# Increment the metric for the number of successful requests.
|
2364
2369
|
def increment_successful_requests_count
|
2365
2370
|
return unless @successful_requests_count
|
2366
|
-
@successful_requests_count.increment(
|
2371
|
+
@successful_requests_count.increment(
|
2372
|
+
labels: { grpc: @use_grpc, code: @ok_code })
|
2367
2373
|
end
|
2368
2374
|
|
2369
2375
|
# Increment the metric for the number of failed requests, labeled by
|
2370
2376
|
# the provided status code.
|
2371
2377
|
def increment_failed_requests_count(code)
|
2372
2378
|
return unless @failed_requests_count
|
2373
|
-
@failed_requests_count.increment(
|
2379
|
+
@failed_requests_count.increment(
|
2380
|
+
labels: { grpc: @use_grpc, code: code })
|
2374
2381
|
end
|
2375
2382
|
|
2376
2383
|
# Increment the metric for the number of log entries, successfully
|
2377
2384
|
# ingested by the Stackdriver Logging API.
|
2378
2385
|
def increment_ingested_entries_count(count)
|
2379
2386
|
return unless @ingested_entries_count
|
2380
|
-
@ingested_entries_count.increment(
|
2381
|
-
|
2387
|
+
@ingested_entries_count.increment(
|
2388
|
+
labels: { grpc: @use_grpc, code: @ok_code }, by: count)
|
2382
2389
|
end
|
2383
2390
|
|
2384
2391
|
# Increment the metric for the number of log entries that were dropped
|
2385
2392
|
# and not ingested by the Stackdriver Logging API.
|
2386
2393
|
def increment_dropped_entries_count(count, code)
|
2387
2394
|
return unless @dropped_entries_count
|
2388
|
-
@dropped_entries_count.increment(
|
2395
|
+
@dropped_entries_count.increment(
|
2396
|
+
labels: { grpc: @use_grpc, code: code }, by: count)
|
2389
2397
|
end
|
2390
2398
|
|
2391
2399
|
# Increment the metric for the number of log entries that were dropped
|
2392
2400
|
# and not ingested by the Stackdriver Logging API.
|
2393
2401
|
def increment_retried_entries_count(count, code)
|
2394
2402
|
return unless @retried_entries_count
|
2395
|
-
@retried_entries_count.increment(
|
2403
|
+
@retried_entries_count.increment(
|
2404
|
+
labels: { grpc: @use_grpc, code: code }, by: count)
|
2396
2405
|
end
|
2397
2406
|
end
|
2398
2407
|
end
|
data/test/plugin/test_driver.rb
CHANGED
@@ -16,6 +16,19 @@ require 'fluent/engine'
|
|
16
16
|
require 'fluent/event'
|
17
17
|
require 'fluent/test/input_test'
|
18
18
|
|
19
|
+
module Fluent
|
20
|
+
module Test
|
21
|
+
# rubocop:disable Style/ClassVars
|
22
|
+
class BufferedOutputTestDriver < InputTestDriver
|
23
|
+
@@run_method = BufferedOutputTestDriver.instance_method(:run)
|
24
|
+
def run(num_waits = 0)
|
25
|
+
@@run_method.bind(self).call(num_waits)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
# rubocop:enable Style/ClassVars
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
19
32
|
module Fluent
|
20
33
|
module Test
|
21
34
|
# Similar to the standard BufferedOutputTestDriver, but allows multiple tags
|
@@ -33,7 +46,7 @@ module Fluent
|
|
33
46
|
self
|
34
47
|
end
|
35
48
|
|
36
|
-
def run(num_waits =
|
49
|
+
def run(num_waits = 0)
|
37
50
|
result = nil
|
38
51
|
super(num_waits) do
|
39
52
|
chunk = @instance.buffer.generate_chunk(
|
@@ -87,16 +87,12 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
87
87
|
d.run
|
88
88
|
assert_prometheus_metric_value(
|
89
89
|
:stackdriver_successful_requests_count, 1, grpc: false, code: 200)
|
90
|
-
assert_prometheus_metric_value(
|
91
|
-
:stackdriver_failed_requests_count, 0, grpc: false)
|
92
90
|
assert_prometheus_metric_value(
|
93
91
|
:stackdriver_ingested_entries_count, 1, grpc: false, code: 200)
|
94
92
|
assert_prometheus_metric_value(
|
95
93
|
:stackdriver_dropped_entries_count, 2, grpc: false, code: 3)
|
96
94
|
assert_prometheus_metric_value(
|
97
95
|
:stackdriver_dropped_entries_count, 1, grpc: false, code: 7)
|
98
|
-
assert_prometheus_metric_value(
|
99
|
-
:stackdriver_retried_entries_count, 0, grpc: false)
|
100
96
|
assert_requested(:post, WRITE_LOG_ENTRIES_URI, times: 1)
|
101
97
|
end
|
102
98
|
|
@@ -120,8 +116,6 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
120
116
|
:stackdriver_ingested_entries_count, 0, grpc: false, code: 200)
|
121
117
|
assert_prometheus_metric_value(
|
122
118
|
:stackdriver_dropped_entries_count, 1, grpc: false, code: 400)
|
123
|
-
assert_prometheus_metric_value(
|
124
|
-
:stackdriver_retried_entries_count, 0, grpc: false)
|
125
119
|
assert_requested(:post, WRITE_LOG_ENTRIES_URI, times: 1)
|
126
120
|
end
|
127
121
|
|
@@ -112,8 +112,6 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
112
112
|
assert_prometheus_metric_value(
|
113
113
|
:stackdriver_dropped_entries_count, 1,
|
114
114
|
grpc: true, code: GRPC::Core::StatusCodes::PERMISSION_DENIED)
|
115
|
-
assert_prometheus_metric_value(
|
116
|
-
:stackdriver_retried_entries_count, 0, grpc: true)
|
117
115
|
end
|
118
116
|
end
|
119
117
|
|
@@ -140,8 +138,6 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
140
138
|
assert_prometheus_metric_value(
|
141
139
|
:stackdriver_dropped_entries_count, 1,
|
142
140
|
grpc: true, code: GRPC::Core::StatusCodes::INVALID_ARGUMENT)
|
143
|
-
assert_prometheus_metric_value(
|
144
|
-
:stackdriver_retried_entries_count, 0, grpc: true)
|
145
141
|
end
|
146
142
|
end
|
147
143
|
|
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.
|
4
|
+
version: 0.7.21
|
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-10-
|
11
|
+
date: 2019-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -140,16 +140,16 @@ dependencies:
|
|
140
140
|
name: prometheus-client
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - "<"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
145
|
+
version: '0.10'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
152
|
+
version: '0.10'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|