gitlab-rspec-metrics-exporter 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13c71733398a56974ce732bd0f2a331420982910db0f1c0357de219c497193ed
4
- data.tar.gz: '060792b540f4e2cfa9a0e7e2d10a63ea1f6322c5ecec8314e03c5882a338ee4a'
3
+ metadata.gz: bfcda9d8209ff8d2719c8b39f4995b4734de3295e8a47367900a5e32e962e665
4
+ data.tar.gz: 1e76c49aa5de797691a639445f2ba00704c9893069c60960520ed56fb5bd080c
5
5
  SHA512:
6
- metadata.gz: af2a21de1d98187d66fff03023c8af1c9659d41378d6ba5f98d8a536fbbc65a6fd4c44297a1751d91a2207e277feed7c75e35b622051d5522b81a2c54881db96
7
- data.tar.gz: 9c5071641bdef4ac086f483258b2c62b484d63fb87e749f8bdd5af5712c884d1ee537574789f5fbfb9622922f2155dfd4266be2f25568348b28d9e89bfcc577f
6
+ metadata.gz: 2e6577d25018d3d9ea858cef1da7f27004fc31edc7efff4d8e76e6e1ec8397145b39818d758bee871c41802e0da791aa6612e5dd8f57a187209dbcfaf3c39644
7
+ data.tar.gz: d902dc4c706552fb2d3e225b67c575f7585cfa21b45996ec55ca172fe380597f8b85867c36cdfe284203cb3ba3950649a23d57f04c0a0514bc6ed631492c56c0
data/README.md CHANGED
@@ -41,17 +41,20 @@ When the `ConfigHelper.configure!` helper is used, the options marked with an
41
41
  options can also be set explicitly via yielded `config` object; explicit
42
42
  values always take precedence over the corresponding environment variable.
43
43
 
44
- | Option | Env var | Description |
45
- | ---------------------------- | ----------------------------- | ------------------------------------------------------------- |
46
- | `observer_url` | `GLCI_OBSERVER_URL` | Observer service base URL |
47
- | `observer_token` | `GLCI_OBSERVER_AUTH_TOKEN` | Auth token sent as `X-Gitlab-Token` |
48
- | `run_type` | `GLCI_TEST_METRICS_RUN_TYPE` | Suite name (falls back to `CI_JOB_NAME` or `"unknown"`) |
49
- | `extra_rspec_metadata_keys` | _(none)_ | Additional `example.metadata` keys to include in metrics |
50
- | `spec_file_path_prefix` | _(none)_ | Prepended to file paths (useful for monorepos) |
51
- | `skip_record_proc` | _(none)_ | Lambda receiving an example; return `true` to skip exporting |
52
- | `test_retried_proc` | _(none)_ | Lambda receiving an example; return `true` if it was a retry |
53
- | `custom_metrics_proc` | _(none)_ | Lambda returning a hash merged into every metric record |
54
- | `logger` | _(none)_ | Ruby `Logger` instance |
44
+ <!-- markdownlint-disable line-length -->
45
+ | Option | Env var | Description |
46
+ | ---------------------------- | ------------------------------ | ---------------------------------------------------------------------------- |
47
+ | `observer_url` | `GLCI_OBSERVER_URL` | Observer service base URL |
48
+ | `observer_token` | `GLCI_OBSERVER_AUTH_TOKEN` | Auth token sent as `X-Gitlab-Token` |
49
+ | `run_type` | `GLCI_TEST_METRICS_RUN_TYPE` | Suite name (falls back to `test_level`, then `CI_JOB_NAME`, or `"unknown"`) |
50
+ | `test_level` | `GLCI_TEST_METRICS_TEST_LEVEL` | Suite-wide test level / tier (e.g. `unit`, `integration`) |
51
+ | `extra_rspec_metadata_keys` | _(none)_ | Additional `example.metadata` keys to include in metrics |
52
+ | `spec_file_path_prefix` | _(none)_ | Prepended to file paths (useful for monorepos) |
53
+ | `skip_record_proc` | _(none)_ | Lambda receiving an example; return `true` to skip exporting |
54
+ | `test_retried_proc` | _(none)_ | Lambda receiving an example; return `true` if it was a retry |
55
+ | `custom_metrics_proc` | _(none)_ | Lambda returning a hash merged into every metric record |
56
+ | `logger` | _(none)_ | Ruby `Logger` instance |
57
+ <!-- markdownlint-enable line-length -->
55
58
 
56
59
  The config helper also reads two control-flow variables that gate whether the
57
60
  exporter activates at all:
@@ -19,6 +19,7 @@ module Gitlab
19
19
  end
20
20
 
21
21
  attr_accessor :run_type,
22
+ :test_level,
22
23
  :observer_url,
23
24
  :observer_token
24
25
  attr_writer :extra_rspec_metadata_keys,
@@ -62,6 +62,7 @@ module Gitlab
62
62
 
63
63
  def configure_exporter!(config, run_type)
64
64
  config.run_type = run_type || default_run_type unless env_present?(config.run_type)
65
+ config.test_level = ENV.fetch("GLCI_TEST_METRICS_TEST_LEVEL", nil) unless env_present?(config.test_level)
65
66
 
66
67
  configure_observer!(config)
67
68
  end
@@ -77,7 +78,9 @@ module Gitlab
77
78
  end
78
79
 
79
80
  def default_run_type
80
- @default_run_type ||= ENV.fetch("GLCI_TEST_METRICS_RUN_TYPE") { ENV.fetch("CI_JOB_NAME", nil) }
81
+ @default_run_type ||= %w[GLCI_TEST_METRICS_RUN_TYPE GLCI_TEST_METRICS_TEST_LEVEL CI_JOB_NAME]
82
+ .filter_map { |name| ENV.fetch(name, nil) }
83
+ .find { |value| env_present?(value) }
81
84
  end
82
85
 
83
86
  def observer_url
@@ -59,6 +59,7 @@ module Gitlab
59
59
  feature_category: example.metadata[:feature_category] || "",
60
60
  test_retried: config.test_retried_proc.call(example),
61
61
  run_type: run_type,
62
+ test_level: test_level,
62
63
  spec_file_path_prefix: config.spec_file_path_prefix,
63
64
  pipeline_type: pipeline_type
64
65
  }
@@ -191,7 +192,17 @@ module Gitlab
191
192
  #
192
193
  # @return [String]
193
194
  def run_type
194
- config.run_type || ci_job_name || "unknown"
195
+ config.run_type || test_level || ci_job_name || "unknown"
196
+ end
197
+
198
+ # Configured suite-wide test level
199
+ #
200
+ # @return [String, nil]
201
+ def test_level
202
+ value = config.test_level
203
+ return nil if value.nil? || value.to_s.empty?
204
+
205
+ value
195
206
  end
196
207
 
197
208
  # Metrics value cast to a valid type
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module RSpecMetricsExporter
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-rspec-metrics-exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Developer Experience