Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-09-29 03:07:49 +00:00
parent 0914eb1a9c
commit c201d59a4f
5 changed files with 21 additions and 70 deletions

View file

@ -1,8 +0,0 @@
---
name: add_timing_to_certain_cache_actions
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/94966
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/371657
milestone: '15.4'
type: development
group: group::code review
default_enabled: false

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
class ScheduleIndexRemovalForCiBuildsMetadata < Gitlab::Database::Migration[2.0]
disable_ddl_transaction!
TABLE_NAME = :ci_builds_metadata
INDEX_NAME = :index_ci_builds_metadata_on_build_id
def up
prepare_async_index_removal(TABLE_NAME, :build_id, name: INDEX_NAME)
end
def down
unprepare_async_index(TABLE_NAME, :build_id, name: INDEX_NAME)
end
end

View file

@ -0,0 +1 @@
fb6b88494168ef86863f41570a2bad1141d6c6e2305522bf622413702e3b3493

View file

@ -126,7 +126,6 @@ module Gitlab
end
def increment_cache_metric(render_type:, total_count:, miss_count:)
return unless Feature.enabled?(:add_timing_to_certain_cache_actions)
return unless caller_id
metric_name = :cached_object_operations_total
@ -146,7 +145,6 @@ module Gitlab
end
def time_action(render_type:, &block)
if Feature.enabled?(:add_timing_to_certain_cache_actions)
real_start = Gitlab::Metrics::System.monotonic_time
presented_object = yield
@ -154,9 +152,6 @@ module Gitlab
real_duration_histogram(render_type).observe({}, Gitlab::Metrics::System.monotonic_time - real_start)
presented_object
else
yield
end
end
def real_duration_histogram(render_type)

View file

@ -54,31 +54,6 @@ RSpec.shared_examples_for 'object cache helper' do
allow(Gitlab::ApplicationContext).to receive(:current_context_attribute).with(:caller_id).and_return(caller_id)
end
context 'when feature flag is off' do
before do
stub_feature_flags(add_timing_to_certain_cache_actions: false)
end
it 'does not call increment' do
expect(transaction).not_to receive(:increment).with(:cached_object_operations_total, any_args)
subject
end
it 'does not call histogram' do
expect(Gitlab::Metrics).not_to receive(:histogram)
subject
end
it "is valid JSON" do
parsed = Gitlab::Json.parse(subject.to_s)
expect(parsed).to be_a(Hash)
expect(parsed["id"]).to eq(presentable.id)
end
end
it 'increments the counter' do
expect(transaction)
.to receive(:increment)
@ -157,34 +132,6 @@ RSpec.shared_examples_for 'collection cache helper' do
allow(Gitlab::ApplicationContext).to receive(:current_context_attribute).with(:caller_id).and_return(caller_id)
end
context 'when feature flag is off' do
before do
stub_feature_flags(add_timing_to_certain_cache_actions: false)
end
it 'does not call increment' do
expect(transaction).not_to receive(:increment).with(:cached_object_operations_total, any_args)
subject
end
it 'does not call histogram' do
expect(Gitlab::Metrics).not_to receive(:histogram)
subject
end
it "is valid JSON" do
parsed = Gitlab::Json.parse(subject.to_s)
expect(parsed).to be_an(Array)
presentable.each_with_index do |item, i|
expect(parsed[i]["id"]).to eq(item.id)
end
end
end
context 'when presentable has a group by clause' do
let(:presentable) { MergeRequest.group(:id) }