diff --git a/lib/gitlab/ci/config/external/file/component.rb b/lib/gitlab/ci/config/external/file/component.rb index 026e7f6757da5556039dd7b85207efa78995d0cd..b34c303785b7b0a37d4fa0664cb3dd27025a4f08 100644 --- a/lib/gitlab/ci/config/external/file/component.rb +++ b/lib/gitlab/ci/config/external/file/component.rb @@ -62,6 +62,13 @@ def validate_content! attr_reader :path, :version + def content_result + context.logger.instrument(:config_component_fetch_content_hash) do + super + end + end + strong_memoize_attr :content_result + def component_result ::Ci::Components::FetchService.new( address: location, diff --git a/spec/lib/gitlab/ci/config/external/file/component_spec.rb b/spec/lib/gitlab/ci/config/external/file/component_spec.rb index ec5d38fd6b9844f4fffff96930cfcc295293b20c..fea3603c1674b6cf214934d94399a3f623bea18e 100644 --- a/spec/lib/gitlab/ci/config/external/file/component_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/component_spec.rb @@ -210,4 +210,26 @@ end end end + + describe '#load_and_validate_expanded_hash!' do + let(:logger) { instance_double(::Gitlab::Ci::Pipeline::Logger, :instrument) } + + let(:context_params) do + { + project: context_project, + sha: 'context_sha', + user: user, + variables: project_variables, + logger: logger + } + end + + it 'tracks the content load time' do + expect(logger).to receive(:instrument).once.ordered.with(:config_component_fetch_content_hash).and_yield + expect(logger).to receive(:instrument).once.ordered.with(:config_file_fetch_content_hash).and_yield + expect(logger).to receive(:instrument).once.ordered.with(:config_file_expand_content_includes).and_yield + + external_resource.load_and_validate_expanded_hash! + end + end end