Commit 0e64c90f authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '232654-refactor-logging-for-project-missing-project_feature' into 'master'

Use Gitlab::ErrorTracking track & raise vs. logger

See merge request gitlab-org/gitlab!39979
parents cd46cc0c 5381ebf0
---
title: Use Gitlab::ErrorTracking in place of project.logger for indexing errors
merge_request: 39979
author:
type: fixed
......@@ -44,9 +44,8 @@ module Elastic
# When this happens, log the errors to help with debugging, and raise the error to prevent indexing bad data
TRACKED_FEATURE_SETTINGS.each do |feature|
data[feature] = target.project_feature.public_send(feature) # rubocop:disable GitlabSecurity/PublicSend
rescue NoMethodError => err
target.logger.error("Elasticsearch failed to read feature #{feature} for #{target.class} #{target.id}: #{err}")
raise
rescue NoMethodError => e
Gitlab::ErrorTracking.track_and_raise_exception(e, project_id: target.id, feature: feature)
end
data
......
......@@ -33,7 +33,10 @@ RSpec.describe Elastic::Latest::ProjectInstanceProxy do
it 'raises an error for a project with an empty project_feature' do
allow(project).to receive(:project_feature).and_return(nil)
expect(project.logger).to receive(:error)
expect(Gitlab::ErrorTracking).to receive(:track_and_raise_exception).with(
NoMethodError,
project_id: project.id,
feature: 'issues_access_level').and_call_original
expect { subject.as_indexed_json }.to raise_error NoMethodError
end
end
......
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