Class: Gitlab::RSpecMetricsExporter::Config
- Inherits:
-
Object
- Object
- Gitlab::RSpecMetricsExporter::Config
- Includes:
- Singleton
- Defined in:
- lib/gitlab/rspec_metrics_exporter/config.rb
Instance Attribute Summary collapse
-
#custom_metrics_proc ⇒ Proc
A lambda that return hash with additional custom metrics.
-
#extra_rspec_metadata_keys ⇒ Array<Symbol>
Extra rspec metadata keys to include in exported metrics.
-
#logger ⇒ Logger
Logger instance.
-
#observer_token ⇒ Object
Returns the value of attribute observer_token.
-
#observer_url ⇒ Object
Returns the value of attribute observer_url.
-
#run_type ⇒ Object
Returns the value of attribute run_type.
-
#skip_record_proc ⇒ Proc
A lambda that determines whether to skip recording a test result.
-
#spec_file_path_prefix ⇒ String
Extra path prefix for constructing full file path within mono-repository setups.
-
#test_retried_proc ⇒ Proc
A lambda that determines whether a test was retried or not.
Class Method Summary collapse
Instance Method Summary collapse
-
#observer_configured? ⇒ Boolean
Whether observer export is configured.
Instance Attribute Details
#custom_metrics_proc ⇒ Proc
A lambda that return hash with additional custom metrics
74 75 76 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 74 def custom_metrics_proc @custom_metrics_proc ||= ->(_example) { {} } end |
#extra_rspec_metadata_keys ⇒ Array<Symbol>
Extra rspec metadata keys to include in exported metrics
43 44 45 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 43 def @extra_rspec_metadata_keys ||= [] end |
#logger ⇒ Logger
Logger instance
81 82 83 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 81 def logger @logger ||= Logger.new($stdout, level: Logger::INFO) end |
#observer_token ⇒ Object
Returns the value of attribute observer_token.
21 22 23 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 21 def observer_token @observer_token end |
#observer_url ⇒ Object
Returns the value of attribute observer_url.
21 22 23 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 21 def observer_url @observer_url end |
#run_type ⇒ Object
Returns the value of attribute run_type.
21 22 23 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 21 def run_type @run_type end |
#skip_record_proc ⇒ Proc
A lambda that determines whether to skip recording a test result
This is useful when you would want to skip initial failure when retrying specs is set up in a separate process and you want to avoid duplicate records
60 61 62 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 60 def skip_record_proc @skip_record_proc ||= ->(_example) { false } end |
#spec_file_path_prefix ⇒ String
Extra path prefix for constructing full file path within mono-repository setups
50 51 52 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 50 def spec_file_path_prefix @spec_file_path_prefix ||= "" end |
#test_retried_proc ⇒ Proc
A lambda that determines whether a test was retried or not
67 68 69 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 67 def test_retried_proc @test_retried_proc ||= ->(_example) { false } end |
Class Method Details
.configuration ⇒ Object
12 13 14 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 12 def configuration Config.instance end |
.configure {|configuration| ... } ⇒ Object
16 17 18 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 16 def configure yield(configuration) end |
Instance Method Details
#observer_configured? ⇒ Boolean
Whether observer export is configured
Export is considered enabled when all required attributes are set
36 37 38 |
# File 'lib/gitlab/rspec_metrics_exporter/config.rb', line 36 def observer_configured? [observer_url, observer_token].none? { |value| value.nil? || value.to_s.empty? } end |