Module: Perfgate::Fingerprints::Components
- Defined in:
- lib/perfgate/fingerprints/components.rb
Overview
Collects the run-level fingerprint component values referenced by
the strict/informational field lists in config.fingerprint (spec
section 15.1/15.2). workload_definition_hash is deliberately
excluded here: it is computed per-workload
(see WorkloadDefinition) and compared per-workload in the
comparison engine, not as a run-wide component.
Class Method Summary collapse
- .ci_provider ⇒ Object
- .collect(config: Perfgate.configuration) ⇒ Object
- .cpu_model ⇒ Object
- .database_adapter ⇒ Object
- .database_version_major ⇒ Object
-
.dataset_hash(config) ⇒ Object
Applications provide their own dataset fingerprint hook (spec section 12.3, e.g. a fixture set version or seed migration number); Baseline only ever stores its hash, never the raw value, to avoid leaking application data into shared run artifacts.
-
.dependency_lock_hash ⇒ Object
Deferred: hashing Gemfile.lock (or equivalent) is a small addition but out of Milestone 3's explicit scope; left nil until wired up.
- .informational_components ⇒ Object
- .operating_system ⇒ Object
- .rails_version ⇒ Object
- .strict_components(config) ⇒ Object
Class Method Details
.ci_provider ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/perfgate/fingerprints/components.rb', line 83 def ci_provider return "github_actions" if ENV["GITHUB_ACTIONS"] return "gitlab_ci" if ENV["GITLAB_CI"] return "circleci" if ENV["CIRCLECI"] nil end |
.collect(config: Perfgate.configuration) ⇒ Object
17 18 19 |
# File 'lib/perfgate/fingerprints/components.rb', line 17 def collect(config: Perfgate.configuration) strict_components(config).merge(informational_components) end |
.cpu_model ⇒ Object
79 80 81 |
# File 'lib/perfgate/fingerprints/components.rb', line 79 def cpu_model ENV.fetch("PERFGATE_CPU_MODEL", nil) end |
.database_adapter ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/perfgate/fingerprints/components.rb', line 49 def database_adapter return nil unless defined?(::ActiveRecord::Base) ::ActiveRecord::Base.connection.adapter_name rescue StandardError nil end |
.database_version_major ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/perfgate/fingerprints/components.rb', line 57 def database_version_major return nil unless defined?(::ActiveRecord::Base) version = ::ActiveRecord::Base.connection.database_version version.to_s.split(".").first rescue StandardError, NotImplementedError nil end |
.dataset_hash(config) ⇒ Object
Applications provide their own dataset fingerprint hook (spec section 12.3, e.g. a fixture set version or seed migration number); Baseline only ever stores its hash, never the raw value, to avoid leaking application data into shared run artifacts.
70 71 72 73 |
# File 'lib/perfgate/fingerprints/components.rb', line 70 def dataset_hash(config) raw = config.dataset_fingerprint.call "sha256:#{Digest::SHA256.hexdigest(raw.to_s)}" end |
.dependency_lock_hash ⇒ Object
Deferred: hashing Gemfile.lock (or equivalent) is a small addition but out of Milestone 3's explicit scope; left nil until wired up.
93 94 95 |
# File 'lib/perfgate/fingerprints/components.rb', line 93 def dependency_lock_hash nil end |
.informational_components ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/perfgate/fingerprints/components.rb', line 33 def informational_components { "operating_system" => , "cpu_model" => cpu_model, "cpu_count" => Etc.nprocessors.to_s, "memory_bytes" => nil, "ci_provider" => ci_provider, "runner_image" => ENV.fetch("PERFGATE_RUNNER_IMAGE", nil), "dependency_lock_hash" => dependency_lock_hash } end |
.operating_system ⇒ Object
75 76 77 |
# File 'lib/perfgate/fingerprints/components.rb', line 75 def RbConfig::CONFIG["host_os"] end |
.rails_version ⇒ Object
45 46 47 |
# File 'lib/perfgate/fingerprints/components.rb', line 45 def rails_version defined?(::Rails) ? ::Rails.version : nil end |
.strict_components(config) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/perfgate/fingerprints/components.rb', line 21 def strict_components(config) { "ruby_engine" => RUBY_ENGINE, "ruby_version" => RUBY_VERSION, "rails_version" => rails_version, "baseline_version_major" => Perfgate::VERSION.split(".").first, "database_adapter" => database_adapter, "database_version_major" => database_version_major, "dataset_hash" => dataset_hash(config) } end |