Skip to content
Snippets Groups Projects
Commit 13902e40 authored by Pawel Chojnacki's avatar Pawel Chojnacki
Browse files

Memoize only yaml loading method

parent 8b69523b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -23,11 +23,11 @@ module Gitlab
end
 
def additional_metrics_raw
@additional_metrics_raw ||= load_yaml_file&.map(&:deep_symbolize_keys).freeze
load_yaml_file&.map(&:deep_symbolize_keys).freeze
end
 
def load_yaml_file
YAML.load_file(Rails.root.join('config/prometheus/additional_metrics.yml'))
@loaded_yaml_file ||= YAML.load_file(Rails.root.join('config/prometheus/additional_metrics.yml'))
end
end
end
Loading
Loading
Loading
Loading
@@ -33,7 +33,6 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
 
before do
described_class.instance_variable_set :@additional_metrics_raw, nil
allow(described_class).to receive(:load_yaml_file) { YAML.load(sample_yaml) }
end
 
Loading
Loading
@@ -68,10 +67,6 @@ describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do
end
 
shared_examples 'required field' do |field_name|
before do
described_class.instance_variable_set :@additional_metrics_raw, nil
end
context "when #{field_name} is nil" do
before do
allow(described_class).to receive(:load_yaml_file) { YAML.load(field_missing) }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment