Commit d6aace3f authored by Marius Bobin's avatar Marius Bobin

Instrument job inclusion in the pipeline logger

With this instrumentation we can observe how many builds a pipeline
could have and how long it takes to compute if they should be persisted.
parent 40080f73
...@@ -53,13 +53,18 @@ module Gitlab ...@@ -53,13 +53,18 @@ module Gitlab
end end
def context def context
Gitlab::Ci::Pipeline::Seed::Context.new(pipeline, root_variables: root_variables) Gitlab::Ci::Pipeline::Seed::Context.new(
pipeline,
root_variables: root_variables,
logger: logger
)
end end
def root_variables def root_variables
logger.instrument(:pipeline_seed_merge_variables) do logger.instrument(:pipeline_seed_merge_variables) do
::Gitlab::Ci::Variables::Helpers.merge_variables( ::Gitlab::Ci::Variables::Helpers.merge_variables(
@command.yaml_processor_result.root_variables, @command.workflow_rules_result.variables @command.yaml_processor_result.root_variables,
@command.workflow_rules_result.variables
) )
end end
end end
......
...@@ -58,7 +58,6 @@ module Gitlab ...@@ -58,7 +58,6 @@ module Gitlab
if pipeline.persisted? if pipeline.persisted?
attributes[:pipeline_builds_tags_count] = pipeline.tags_count attributes[:pipeline_builds_tags_count] = pipeline.tags_count
attributes[:pipeline_builds_distinct_tags_count] = pipeline.distinct_tags_count attributes[:pipeline_builds_distinct_tags_count] = pipeline.distinct_tags_count
attributes[:pipeline_id] = pipeline.id attributes[:pipeline_id] = pipeline.id
end end
......
...@@ -41,6 +41,7 @@ module Gitlab ...@@ -41,6 +41,7 @@ module Gitlab
def included? def included?
strong_memoize(:inclusion) do strong_memoize(:inclusion) do
logger.instrument(:pipeline_seed_build_inclusion) do
if @using_rules if @using_rules
rules_result.pass? rules_result.pass?
elsif @using_only || @using_except elsif @using_only || @using_except
...@@ -50,6 +51,7 @@ module Gitlab ...@@ -50,6 +51,7 @@ module Gitlab
end end
end end
end end
end
def errors def errors
return unless included? return unless included?
...@@ -122,6 +124,8 @@ module Gitlab ...@@ -122,6 +124,8 @@ module Gitlab
private private
delegate :logger, to: :@context
def all_of_only? def all_of_only?
@only.all? { |spec| spec.satisfied_by?(@pipeline, evaluate_context) } @only.all? { |spec| spec.satisfied_by?(@pipeline, evaluate_context) }
end end
......
...@@ -5,11 +5,18 @@ module Gitlab ...@@ -5,11 +5,18 @@ module Gitlab
module Pipeline module Pipeline
module Seed module Seed
class Context class Context
attr_reader :pipeline, :root_variables attr_reader :pipeline, :root_variables, :logger
def initialize(pipeline, root_variables: []) def initialize(pipeline, root_variables: [], logger: nil)
@pipeline = pipeline @pipeline = pipeline
@root_variables = root_variables @root_variables = root_variables
@logger = logger || build_logger
end
private
def build_logger
::Gitlab::Ci::Pipeline::Logger.new(project: pipeline.project)
end end
end end
end end
......
...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do ...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do
let(:pipeline) { build(:ci_empty_pipeline, project: project, sha: head_sha) } let(:pipeline) { build(:ci_empty_pipeline, project: project, sha: head_sha) }
let(:root_variables) { [] } let(:root_variables) { [] }
let(:seed_context) { double(pipeline: pipeline, root_variables: root_variables) } let(:seed_context) { Gitlab::Ci::Pipeline::Seed::Context.new(pipeline, root_variables: root_variables) }
let(:attributes) { { name: 'rspec', ref: 'master', scheduling_type: :stage, when: 'on_success' } } let(:attributes) { { name: 'rspec', ref: 'master', scheduling_type: :stage, when: 'on_success' } }
let(:previous_stages) { [] } let(:previous_stages) { [] }
let(:current_stage) { double(seeds_names: [attributes[:name]]) } let(:current_stage) { double(seeds_names: [attributes[:name]]) }
......
...@@ -6,7 +6,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Pipeline do ...@@ -6,7 +6,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Pipeline do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let(:seed_context) { double(pipeline: pipeline, root_variables: []) } let(:seed_context) { Gitlab::Ci::Pipeline::Seed::Context.new(pipeline, root_variables: []) }
let(:stages_attributes) do let(:stages_attributes) do
[ [
......
...@@ -6,7 +6,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Stage do ...@@ -6,7 +6,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Stage do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) } let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:previous_stages) { [] } let(:previous_stages) { [] }
let(:seed_context) { double(pipeline: pipeline, root_variables: []) } let(:seed_context) { Gitlab::Ci::Pipeline::Seed::Context.new(pipeline, root_variables: []) }
let(:attributes) do let(:attributes) do
{ name: 'test', { name: 'test',
......
...@@ -36,6 +36,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -36,6 +36,7 @@ RSpec.describe Ci::CreatePipelineService do
'pipeline_creation_duration_s' => counters, 'pipeline_creation_duration_s' => counters,
'pipeline_size_count' => counters, 'pipeline_size_count' => counters,
'pipeline_step_gitlab_ci_pipeline_chain_seed_duration_s' => counters, 'pipeline_step_gitlab_ci_pipeline_chain_seed_duration_s' => counters,
'pipeline_seed_build_inclusion_duration_s' => counters,
'pipeline_builds_tags_count' => a_kind_of(Numeric), 'pipeline_builds_tags_count' => a_kind_of(Numeric),
'pipeline_builds_distinct_tags_count' => a_kind_of(Numeric) 'pipeline_builds_distinct_tags_count' => a_kind_of(Numeric)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment