fluent-plugin-google-cloud 0.8.6 → 0.10.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.
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require 'prometheus/client'
16
+
15
17
  # Additional assert functions.
16
18
  module Asserts
17
19
  # For an optional field with default values, Protobuf omits the field when it
@@ -19,11 +19,12 @@ Coveralls.wear!
19
19
  require 'google/apis'
20
20
  require 'helper'
21
21
  require 'mocha/test_unit'
22
- require 'webmock/test_unit'
23
22
  require 'prometheus/client'
23
+ require 'webmock/test_unit'
24
24
 
25
25
  require_relative 'asserts'
26
26
  require_relative 'constants'
27
+ require_relative 'utils'
27
28
 
28
29
  module Monitoring
29
30
  # Prevent OpenCensus from writing to the network.
@@ -38,21 +39,11 @@ end
38
39
  module BaseTest
39
40
  include Asserts
40
41
  include Constants
42
+ include Utils
41
43
 
42
44
  def setup
43
45
  Fluent::Test.setup
44
- # delete environment variables that googleauth uses to find credentials.
45
- ENV.delete(CREDENTIALS_PATH_ENV_VAR)
46
- # service account env.
47
- ENV.delete(PRIVATE_KEY_VAR)
48
- ENV.delete(CLIENT_EMAIL_VAR)
49
- ENV.delete(PROJECT_ID_VAR)
50
- # authorized_user env.
51
- ENV.delete(CLIENT_ID_VAR)
52
- ENV.delete(CLIENT_SECRET_VAR)
53
- ENV.delete(REFRESH_TOKEN_VAR)
54
- # home var, which is used to find $HOME/.gcloud/...
55
- ENV.delete('HOME')
46
+ delete_env_vars
56
47
 
57
48
  # Unregister Prometheus metrics.
58
49
  registry = Prometheus::Client.registry
@@ -62,7 +53,7 @@ module BaseTest
62
53
  registry.unregister(:stackdriver_dropped_entries_count)
63
54
  registry.unregister(:stackdriver_retried_entries_count)
64
55
 
65
- setup_auth_stubs
56
+ setup_auth_stubs('https://www.googleapis.com/oauth2/v4/token')
66
57
  @logs_sent = []
67
58
  end
68
59
 
@@ -107,7 +98,7 @@ module BaseTest
107
98
 
108
99
  def test_configure_metadata_missing_parts_on_other_platforms
109
100
  setup_no_metadata_service_stubs
110
- Fluent::GoogleCloudOutput::CredentialsInfo.stubs(:project_id).returns(nil)
101
+ Common::Utils::CredentialsInfo.stubs(:project_id).returns(nil)
111
102
  [[CONFIG_MISSING_METADATA_PROJECT_ID, ['project_id'], false],
112
103
  [CONFIG_MISSING_METADATA_ZONE, [], true],
113
104
  [CONFIG_MISSING_METADATA_VM_ID, [], true],
@@ -131,8 +122,8 @@ module BaseTest
131
122
 
132
123
  def test_configure_ignores_unknown_monitoring_type
133
124
  # Verify that driver creation succeeds when monitoring type is not
134
- # "prometheus" (in which case, we simply don't record metrics),
135
- # and that the counters are set to nil.
125
+ # "prometheus" or "opencensus" (in which case, we simply don't record
126
+ # metrics), and that the counters are set to nil.
136
127
  setup_gce_metadata_stubs
137
128
  create_driver(CONFIG_UNKNOWN_MONITORING_TYPE)
138
129
  assert_nil(Prometheus::Client.registry.get(
@@ -145,6 +136,67 @@ module BaseTest
145
136
  :stackdriver_dropped_entries_count))
146
137
  assert_nil(Prometheus::Client.registry.get(
147
138
  :stackdriver_retried_entries_count))
139
+ assert_nil(OpenCensus::Stats::MeasureRegistry.get(
140
+ Monitoring::MetricTranslator.new(
141
+ :stackdriver_successful_requests_count, {})))
142
+ assert_nil(OpenCensus::Stats::MeasureRegistry.get(
143
+ Monitoring::MetricTranslator.new(
144
+ :stackdriver_failed_requests_count, {})))
145
+ assert_nil(OpenCensus::Stats::MeasureRegistry.get(
146
+ Monitoring::MetricTranslator.new(
147
+ :stackdriver_ingested_entries_count, {})))
148
+ assert_nil(OpenCensus::Stats::MeasureRegistry.get(
149
+ Monitoring::MetricTranslator.new(
150
+ :stackdriver_dropped_entries_count, {})))
151
+ assert_nil(OpenCensus::Stats::MeasureRegistry.get(
152
+ Monitoring::MetricTranslator.new(
153
+ :stackdriver_retried_entries_count, {})))
154
+ end
155
+
156
+ def test_configure_uses_metrics_resource
157
+ setup_gce_metadata_stubs
158
+ [CONFIG_METRICS_RESOURCE_JSON,
159
+ CONFIG_METRICS_RESOURCE_HASH,
160
+ CONFIG_METRICS_RESOURCE_JSON_HASH
161
+ ].each_with_index do |config, index|
162
+ d = create_driver(config)
163
+ assert_equal 'custom_resource', d.instance.monitoring_resource.type, \
164
+ "Index #{index}"
165
+ assert_equal '123', d.instance.monitoring_resource.labels['label1'], \
166
+ "Index #{index}"
167
+ assert_equal 'abc', d.instance.monitoring_resource.labels['label2'], \
168
+ "Index #{index}"
169
+ assert_true d.instance.instance_variable_get(:@enable_monitoring)
170
+ registry = d.instance.instance_variable_get(:@registry)
171
+ assert_not_nil registry
172
+ exporter = registry.instance_variable_get(:@exporter)
173
+ assert_equal 'custom_resource', exporter.resource_type, "Index #{index}"
174
+ assert_equal({ 'label1' => '123', 'label2' => 'abc' },
175
+ exporter.resource_labels, "Index #{index}")
176
+ end
177
+ end
178
+
179
+ def test_configure_metrics_resource_validation
180
+ setup_gce_metadata_stubs
181
+ {
182
+ CONFIG_METRICS_RESOURCE_JSON_NO_TYPE => /type must be a string/,
183
+ CONFIG_METRICS_RESOURCE_JSON_BAD_LABELS => /labels must be a hash/,
184
+ CONFIG_METRICS_RESOURCE_JSON_BAD_KEYS =>
185
+ /unrecognized keys: \[:random\]/,
186
+ CONFIG_METRICS_RESOURCE_JSON_BAD_KEYS_LABELS =>
187
+ /unrecognized keys: \[:"labels\.random"\]/,
188
+ CONFIG_METRICS_RESOURCE_JSON_BAD_KEYS_NO_LABELS =>
189
+ /unrecognized keys: \[:random\]/
190
+ }.each_with_index do |(config, pattern), index|
191
+ begin
192
+ create_driver(config)
193
+ assert false,
194
+ "Invalid config at index #{index} should have raised an error."
195
+ rescue Fluent::ConfigError => error
196
+ assert error.message.match?(pattern), \
197
+ "Index #{index} failed: got #{error.message}."
198
+ end
199
+ end
148
200
  end
149
201
 
150
202
  def test_metadata_loading
@@ -1925,116 +1977,6 @@ module BaseTest
1925
1977
 
1926
1978
  private
1927
1979
 
1928
- def stub_metadata_request(metadata_path, response_body)
1929
- stub_request(:get, 'http://169.254.169.254/computeMetadata/v1/' +
1930
- metadata_path)
1931
- .to_return(body: response_body, status: 200,
1932
- headers: { 'Content-Length' => response_body.length })
1933
- end
1934
-
1935
- def setup_no_metadata_service_stubs
1936
- # Simulate a machine with no metadata service present
1937
- stub_request(:any, %r{http://169.254.169.254/.*})
1938
- .to_raise(Errno::EHOSTUNREACH)
1939
- end
1940
-
1941
- def setup_gce_metadata_stubs
1942
- # Stub the root, used for platform detection by the plugin and 'googleauth'.
1943
- stub_request(:get, 'http://169.254.169.254')
1944
- .to_return(status: 200, headers: { 'Metadata-Flavor' => 'Google' })
1945
-
1946
- # Create stubs for all the GCE metadata lookups the agent needs to make.
1947
- stub_metadata_request('project/project-id', PROJECT_ID)
1948
- stub_metadata_request('instance/zone', FULLY_QUALIFIED_ZONE)
1949
- stub_metadata_request('instance/id', VM_ID)
1950
- stub_metadata_request('instance/attributes/',
1951
- "attribute1\nattribute2\nattribute3")
1952
-
1953
- # Used by 'googleauth' to fetch the default service account credentials.
1954
- stub_request(:get, 'http://169.254.169.254/computeMetadata/v1/' \
1955
- 'instance/service-accounts/default/token')
1956
- .to_return(body: %({"access_token": "#{FAKE_AUTH_TOKEN}"}),
1957
- status: 200,
1958
- headers: { 'Content-Length' => FAKE_AUTH_TOKEN.length,
1959
- 'Content-Type' => 'application/json' })
1960
- end
1961
-
1962
- def setup_ec2_metadata_stubs
1963
- # Stub the root, used for platform detection.
1964
- stub_request(:get, 'http://169.254.169.254')
1965
- .to_return(status: 200, headers: { 'Server' => 'EC2ws' })
1966
-
1967
- # Stub the identity document lookup made by the agent.
1968
- stub_request(:get, 'http://169.254.169.254/latest/dynamic/' \
1969
- 'instance-identity/document')
1970
- .to_return(body: EC2_IDENTITY_DOCUMENT, status: 200,
1971
- headers: { 'Content-Length' => EC2_IDENTITY_DOCUMENT.length })
1972
- end
1973
-
1974
- def setup_auth_stubs
1975
- # Used when loading credentials from a JSON file.
1976
- stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
1977
- .with(body: hash_including(grant_type: AUTH_GRANT_TYPE))
1978
- .to_return(body: %({"access_token": "#{FAKE_AUTH_TOKEN}"}),
1979
- status: 200,
1980
- headers: { 'Content-Length' => FAKE_AUTH_TOKEN.length,
1981
- 'Content-Type' => 'application/json' })
1982
-
1983
- stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
1984
- .with(body: hash_including(grant_type: 'refresh_token'))
1985
- .to_return(body: %({"access_token": "#{FAKE_AUTH_TOKEN}"}),
1986
- status: 200,
1987
- headers: { 'Content-Length' => FAKE_AUTH_TOKEN.length,
1988
- 'Content-Type' => 'application/json' })
1989
- end
1990
-
1991
- def setup_managed_vm_metadata_stubs
1992
- stub_metadata_request(
1993
- 'instance/attributes/',
1994
- "attribute1\ngae_backend_name\ngae_backend_version\nlast_attribute")
1995
- stub_metadata_request('instance/attributes/gae_backend_name',
1996
- MANAGED_VM_BACKEND_NAME)
1997
- stub_metadata_request('instance/attributes/gae_backend_version',
1998
- MANAGED_VM_BACKEND_VERSION)
1999
- end
2000
-
2001
- def setup_k8s_metadata_stubs(should_respond = true)
2002
- if should_respond
2003
- stub_metadata_request(
2004
- 'instance/attributes/',
2005
- "attribute1\ncluster-location\ncluster-name\nlast_attribute")
2006
- stub_metadata_request('instance/attributes/cluster-location',
2007
- K8S_LOCATION2)
2008
- stub_metadata_request('instance/attributes/cluster-name',
2009
- K8S_CLUSTER_NAME)
2010
- else
2011
- ['cluster-location', 'cluster-name'].each do |metadata_name|
2012
- stub_request(:get, %r{.*instance/attributes/#{metadata_name}.*})
2013
- .to_return(status: 404,
2014
- body: 'The requested URL /computeMetadata/v1/instance/' \
2015
- "attributes/#{metadata_name} was not found on this" \
2016
- ' server.')
2017
- end
2018
- end
2019
- end
2020
-
2021
- def setup_dataproc_metadata_stubs
2022
- stub_metadata_request(
2023
- 'instance/attributes/',
2024
- "attribute1\ndataproc-cluster-uuid\ndataproc-cluster-name")
2025
- stub_metadata_request('instance/attributes/dataproc-cluster-name',
2026
- DATAPROC_CLUSTER_NAME)
2027
- stub_metadata_request('instance/attributes/dataproc-cluster-uuid',
2028
- DATAPROC_CLUSTER_UUID)
2029
- stub_metadata_request('instance/attributes/dataproc-region',
2030
- DATAPROC_REGION)
2031
- end
2032
-
2033
- def clear_metrics
2034
- Prometheus::Client.registry.instance_variable_set('@metrics', {})
2035
- OpenCensus::Stats.ensure_recorder.clear_stats
2036
- end
2037
-
2038
1980
  # Provide a stub context that initializes @logs_sent, executes the block and
2039
1981
  # resets WebMock at the end.
2040
1982
  def new_stub_context
@@ -2076,18 +2018,6 @@ module BaseTest
2076
2018
  }
2077
2019
  end
2078
2020
 
2079
- def gke_container_log_entry(log)
2080
- {
2081
- log: log,
2082
- LOCAL_RESOURCE_ID_KEY =>
2083
- "#{CONTAINER_LOCAL_RESOURCE_ID_PREFIX}.#{CONTAINER_NAMESPACE_ID}" \
2084
- ".#{K8S_POD_NAME}.#{K8S_CONTAINER_NAME}"
2085
- }
2086
- end
2087
-
2088
- # TODO(qingling128): Temporary fallback for metadata agent restarts.
2089
- # k8s resources.
2090
-
2091
2021
  def k8s_container_log_entry(log,
2092
2022
  local_resource_id: K8S_LOCAL_RESOURCE_ID)
2093
2023
  {
@@ -45,7 +45,7 @@ end
45
45
 
46
46
  # Constants used by unit tests for Google Cloud Logging plugin.
47
47
  module Constants
48
- include Fluent::GoogleCloudOutput::ServiceConstants
48
+ include Common::ServiceConstants
49
49
  include Fluent::GoogleCloudOutput::ConfigConstants
50
50
  include Fluent::GoogleCloudOutput::InternalConstants
51
51
 
@@ -433,6 +433,56 @@ module Constants
433
433
  monitoring_type not_prometheus
434
434
  ).freeze
435
435
 
436
+ # rubocop:disable Metrics/LineLength
437
+ CONFIG_METRICS_RESOURCE_JSON = %(
438
+ enable_monitoring true
439
+ monitoring_type opencensus
440
+ metrics_resource {"type":"custom_resource","labels":{"label1":"123","label2":"abc"}}
441
+ ).freeze
442
+
443
+ CONFIG_METRICS_RESOURCE_HASH = %(
444
+ enable_monitoring true
445
+ monitoring_type opencensus
446
+ metrics_resource type:custom_resource, labels.label1:123, labels.label2:abc
447
+ ).freeze
448
+
449
+ CONFIG_METRICS_RESOURCE_JSON_HASH = %(
450
+ enable_monitoring true
451
+ monitoring_type opencensus
452
+ metrics_resource {"type":"custom_resource","labels.label1":"123","labels.label2":"abc"}
453
+ ).freeze
454
+
455
+ CONFIG_METRICS_RESOURCE_JSON_NO_TYPE = %(
456
+ enable_monitoring true
457
+ monitoring_type opencensus
458
+ metrics_resource {"labels":{"label1":"123","label2":"abc"}}
459
+ ).freeze
460
+
461
+ CONFIG_METRICS_RESOURCE_JSON_BAD_LABELS = %(
462
+ enable_monitoring true
463
+ monitoring_type opencensus
464
+ metrics_resource {"type":"custom_resource","labels":"123"}
465
+ ).freeze
466
+
467
+ CONFIG_METRICS_RESOURCE_JSON_BAD_KEYS = %(
468
+ enable_monitoring true
469
+ monitoring_type opencensus
470
+ metrics_resource {"type":"custom_resource","labels":{"label1":"123"},"random":"x"}
471
+ ).freeze
472
+
473
+ CONFIG_METRICS_RESOURCE_JSON_BAD_KEYS_LABELS = %(
474
+ enable_monitoring true
475
+ monitoring_type opencensus
476
+ metrics_resource {"type":"custom_resource","labels":{"label1":"123"},"labels.random":"x"}
477
+ ).freeze
478
+
479
+ CONFIG_METRICS_RESOURCE_JSON_BAD_KEYS_NO_LABELS = %(
480
+ enable_monitoring true
481
+ monitoring_type opencensus
482
+ metrics_resource {"type":"custom_resource","labels.label1":"123","random":"x"}
483
+ ).freeze
484
+ # rubocop:enable Metrics/LineLength
485
+
436
486
  # For statusz.
437
487
  CONFIG_STATUSZ = %(
438
488
  statusz_port 5678
@@ -472,11 +522,19 @@ module Constants
472
522
  ).freeze
473
523
 
474
524
  # For analyze_config.
475
- CONFIG_ANALYZE_CONFIG = %(
525
+ CONFIG_ANALYZE_CONFIG_PROMETHEUS = %(
526
+ google_fluentd_config_path \
527
+ test/plugin/data/google-fluentd-custom.conf
528
+ google_fluentd_baseline_config_path \
529
+ test/plugin/data/google-fluentd-baseline.conf
530
+ monitoring_type prometheus
531
+ ).freeze
532
+ CONFIG_ANALYZE_CONFIG_OPENCENSUS = %(
476
533
  google_fluentd_config_path \
477
534
  test/plugin/data/google-fluentd-custom.conf
478
535
  google_fluentd_baseline_config_path \
479
536
  test/plugin/data/google-fluentd-baseline.conf
537
+ monitoring_type opencensus
480
538
  ).freeze
481
539
 
482
540
  # Service configurations for various services.
@@ -16,19 +16,6 @@ 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
-
32
19
  module Fluent
33
20
  module Test
34
21
  # Similar to the standard BufferedOutputTestDriver, but allows multiple tags
@@ -46,7 +33,7 @@ module Fluent
46
33
  self
47
34
  end
48
35
 
49
- def run(num_waits = 0)
36
+ def run(num_waits = 10)
50
37
  result = nil
51
38
  super(num_waits) do
52
39
  chunk = @instance.buffer.generate_chunk(
@@ -15,6 +15,7 @@
15
15
  require_relative '../helper'
16
16
  require_relative 'asserts'
17
17
  require_relative 'constants'
18
+ require_relative 'utils'
18
19
 
19
20
  require 'fluent/test/driver/filter'
20
21
  require 'fluent/plugin/filter_analyze_config'
@@ -24,11 +25,13 @@ class FilterAnalyzeConfigTest < Test::Unit::TestCase
24
25
  include Asserts
25
26
  include Constants
26
27
  include Fluent::AnalyzeConfigFilter::Constants
28
+ include Utils
27
29
 
28
30
  APPLICATION_DEFAULT_CONFIG = ''.freeze
29
31
 
30
32
  def setup
31
33
  Fluent::Test.setup
34
+ delete_env_vars
32
35
  end
33
36
 
34
37
  def test_config_file_does_not_exist
@@ -39,145 +42,155 @@ class FilterAnalyzeConfigTest < Test::Unit::TestCase
39
42
  end
40
43
 
41
44
  def test_analyze_config
42
- create_driver(CONFIG_ANALYZE_CONFIG)
45
+ setup_auth_stubs('https://oauth2.googleapis.com/token')
46
+ setup_gce_metadata_stubs
47
+ [
48
+ [CONFIG_ANALYZE_CONFIG_PROMETHEUS,
49
+ method(:assert_prometheus_metric_value)],
50
+ [CONFIG_ANALYZE_CONFIG_OPENCENSUS,
51
+ method(:assert_opencensus_metric_value)]
52
+ ].each do |config, assert_metric_value|
53
+ clear_metrics
54
+ create_driver(config)
43
55
 
44
- # Default plugins, with default config.
45
- assert_prometheus_metric_value(
46
- :stackdriver_enabled_plugins,
47
- 1,
48
- plugin_name: 'source/syslog/tcp',
49
- is_default_plugin: true,
50
- has_default_value: true,
51
- has_ruby_snippet: false)
52
- assert_prometheus_metric_value(
53
- :stackdriver_enabled_plugins,
54
- 1,
55
- plugin_name: 'source/tail/apache-access',
56
- is_default_plugin: true,
57
- has_default_value: true,
58
- has_ruby_snippet: false)
59
- assert_prometheus_metric_value(
60
- :stackdriver_enabled_plugins,
61
- 1,
62
- plugin_name: 'filter/add_insert_ids',
63
- is_default_plugin: true,
64
- has_default_value: true,
65
- has_ruby_snippet: false)
56
+ # Default plugins, with default config.
57
+ assert_metric_value.call(
58
+ :stackdriver_enabled_plugins,
59
+ 1,
60
+ plugin_name: 'source/syslog/tcp',
61
+ is_default_plugin: true,
62
+ has_default_value: true,
63
+ has_ruby_snippet: false)
64
+ assert_metric_value.call(
65
+ :stackdriver_enabled_plugins,
66
+ 1,
67
+ plugin_name: 'source/tail/apache-access',
68
+ is_default_plugin: true,
69
+ has_default_value: true,
70
+ has_ruby_snippet: false)
71
+ assert_metric_value.call(
72
+ :stackdriver_enabled_plugins,
73
+ 1,
74
+ plugin_name: 'filter/add_insert_ids',
75
+ is_default_plugin: true,
76
+ has_default_value: true,
77
+ has_ruby_snippet: false)
66
78
 
67
- # Default plugins, with custom config.
68
- assert_prometheus_metric_value(
69
- :stackdriver_enabled_plugins,
70
- 1,
71
- plugin_name: 'match/google_cloud',
72
- is_default_plugin: true,
73
- has_default_value: false,
74
- has_ruby_snippet: false)
79
+ # Default plugins, with custom config.
80
+ assert_metric_value.call(
81
+ :stackdriver_enabled_plugins,
82
+ 1,
83
+ plugin_name: 'match/google_cloud',
84
+ is_default_plugin: true,
85
+ has_default_value: false,
86
+ has_ruby_snippet: false)
75
87
 
76
- # Custom plugins, some with embedded Ruby.
77
- assert_prometheus_metric_value(
78
- :stackdriver_enabled_plugins,
79
- 1,
80
- plugin_name: 'filter',
81
- is_default_plugin: false,
82
- has_default_value: false,
83
- has_ruby_snippet: false)
84
- assert_prometheus_metric_value(
85
- :stackdriver_enabled_plugins,
86
- 1,
87
- plugin_name: 'filter/record_transformer',
88
- is_default_plugin: false,
89
- has_default_value: false,
90
- has_ruby_snippet: true)
91
- assert_prometheus_metric_value(
92
- :stackdriver_enabled_plugins,
93
- 1,
94
- plugin_name: 'match/stdout',
95
- is_default_plugin: false,
96
- has_default_value: false,
97
- has_ruby_snippet: true)
88
+ # Custom plugins, some with embedded Ruby.
89
+ assert_metric_value.call(
90
+ :stackdriver_enabled_plugins,
91
+ 1,
92
+ plugin_name: 'filter',
93
+ is_default_plugin: false,
94
+ has_default_value: false,
95
+ has_ruby_snippet: false)
96
+ assert_metric_value.call(
97
+ :stackdriver_enabled_plugins,
98
+ 1,
99
+ plugin_name: 'filter/record_transformer',
100
+ is_default_plugin: false,
101
+ has_default_value: false,
102
+ has_ruby_snippet: true)
103
+ assert_metric_value.call(
104
+ :stackdriver_enabled_plugins,
105
+ 1,
106
+ plugin_name: 'match/stdout',
107
+ is_default_plugin: false,
108
+ has_default_value: false,
109
+ has_ruby_snippet: true)
98
110
 
99
- # For out_google_cloud, 3 params are present.
100
- assert_prometheus_metric_value(
101
- :stackdriver_config_usage,
102
- 1,
103
- plugin_name: 'google_cloud',
104
- param: 'adjust_invalid_timestamps',
105
- is_present: true,
106
- has_default_value: true)
107
- assert_prometheus_metric_value(
108
- :stackdriver_config_usage,
109
- 1,
110
- plugin_name: 'google_cloud',
111
- param: 'autoformat_stackdriver_trace',
112
- is_present: true,
113
- has_default_value: false)
114
- assert_prometheus_metric_value(
115
- :stackdriver_config_usage,
116
- 1,
117
- plugin_name: 'google_cloud',
118
- param: 'coerce_to_utf8',
119
- is_present: true,
120
- has_default_value: false)
121
- # The remaining "google_cloud" params are not present.
122
- # The are no params for "detect_exceptions".
123
- %w(
124
- auth_method
125
- detect_json
126
- enable_monitoring
127
- gcm_service_address
128
- grpc_compression_algorithm
129
- http_request_key
130
- insert_id_key
131
- label_map
132
- labels
133
- labels_key
134
- logging_api_url
135
- monitoring_type
136
- non_utf8_replacement_string
137
- operation_key
138
- private_key_email
139
- private_key_passphrase
140
- private_key_path
141
- project_id
142
- source_location_key
143
- span_id_key
144
- statusz_port
145
- trace_key
146
- trace_sampled_key
147
- use_grpc
148
- use_metadata_service
149
- vm_id
150
- vm_name
151
- zone
152
- ).each do |p|
153
- assert_prometheus_metric_value(
111
+ # For out_google_cloud, 3 params are present.
112
+ assert_metric_value.call(
154
113
  :stackdriver_config_usage,
155
114
  1,
156
115
  plugin_name: 'google_cloud',
157
- param: p,
158
- is_present: false,
116
+ param: 'adjust_invalid_timestamps',
117
+ is_present: true,
118
+ has_default_value: true)
119
+ assert_metric_value.call(
120
+ :stackdriver_config_usage,
121
+ 1,
122
+ plugin_name: 'google_cloud',
123
+ param: 'autoformat_stackdriver_trace',
124
+ is_present: true,
159
125
  has_default_value: false)
160
- end
126
+ assert_metric_value.call(
127
+ :stackdriver_config_usage,
128
+ 1,
129
+ plugin_name: 'google_cloud',
130
+ param: 'coerce_to_utf8',
131
+ is_present: true,
132
+ has_default_value: false)
133
+ # The remaining "google_cloud" params are not present.
134
+ # The are no params for "detect_exceptions".
135
+ %w(
136
+ auth_method
137
+ detect_json
138
+ enable_monitoring
139
+ gcm_service_address
140
+ grpc_compression_algorithm
141
+ http_request_key
142
+ insert_id_key
143
+ label_map
144
+ labels
145
+ labels_key
146
+ logging_api_url
147
+ monitoring_type
148
+ non_utf8_replacement_string
149
+ operation_key
150
+ private_key_email
151
+ private_key_passphrase
152
+ private_key_path
153
+ project_id
154
+ source_location_key
155
+ span_id_key
156
+ statusz_port
157
+ trace_key
158
+ trace_sampled_key
159
+ use_grpc
160
+ use_metadata_service
161
+ vm_id
162
+ vm_name
163
+ zone
164
+ ).each do |p|
165
+ assert_metric_value.call(
166
+ :stackdriver_config_usage,
167
+ 1,
168
+ plugin_name: 'google_cloud',
169
+ param: p,
170
+ is_present: false,
171
+ has_default_value: false)
172
+ end
161
173
 
162
- # We also export values for the bools.
163
- assert_prometheus_metric_value(
164
- :stackdriver_config_bool_values,
165
- 1,
166
- plugin_name: 'google_cloud',
167
- param: 'adjust_invalid_timestamps',
168
- value: true)
169
- assert_prometheus_metric_value(
170
- :stackdriver_config_bool_values,
171
- 1,
172
- plugin_name: 'google_cloud',
173
- param: 'autoformat_stackdriver_trace',
174
- value: false)
175
- assert_prometheus_metric_value(
176
- :stackdriver_config_bool_values,
177
- 1,
178
- plugin_name: 'google_cloud',
179
- param: 'coerce_to_utf8',
180
- value: true)
174
+ # We also export values for the bools.
175
+ assert_metric_value.call(
176
+ :stackdriver_config_bool_values,
177
+ 1,
178
+ plugin_name: 'google_cloud',
179
+ param: 'adjust_invalid_timestamps',
180
+ value: true)
181
+ assert_metric_value.call(
182
+ :stackdriver_config_bool_values,
183
+ 1,
184
+ plugin_name: 'google_cloud',
185
+ param: 'autoformat_stackdriver_trace',
186
+ value: false)
187
+ assert_metric_value.call(
188
+ :stackdriver_config_bool_values,
189
+ 1,
190
+ plugin_name: 'google_cloud',
191
+ param: 'coerce_to_utf8',
192
+ value: true)
193
+ end
181
194
  end
182
195
 
183
196
  def create_driver(conf = APPLICATION_DEFAULT_CONFIG)