Commit 6a2ac46d authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '38332-rename-gitlab-sentry-into' into 'master'

Rename `Gitlab::Sentry` into service-agnostic `Gitlab::ErrorTracking`

See merge request gitlab-org/gitlab!21738
parents aef06bb8 035e7359
...@@ -165,7 +165,7 @@ class ApplicationController < ActionController::Base ...@@ -165,7 +165,7 @@ class ApplicationController < ActionController::Base
end end
def log_exception(exception) def log_exception(exception)
Gitlab::Sentry.track_exception(exception) Gitlab::ErrorTracking.track_exception(exception)
backtrace_cleaner = request.env["action_dispatch.backtrace_cleaner"] backtrace_cleaner = request.env["action_dispatch.backtrace_cleaner"]
application_trace = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).application_trace application_trace = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).application_trace
...@@ -533,7 +533,7 @@ class ApplicationController < ActionController::Base ...@@ -533,7 +533,7 @@ class ApplicationController < ActionController::Base
end end
def sentry_context(&block) def sentry_context(&block)
Gitlab::Sentry.with_context(current_user, &block) Gitlab::ErrorTracking.with_context(current_user, &block)
end end
def allow_gitaly_ref_name_caching def allow_gitaly_ref_name_caching
......
...@@ -98,7 +98,7 @@ module IssuableActions ...@@ -98,7 +98,7 @@ module IssuableActions
error_message = "Destroy confirmation not provided for #{issuable.human_class_name}" error_message = "Destroy confirmation not provided for #{issuable.human_class_name}"
exception = RuntimeError.new(error_message) exception = RuntimeError.new(error_message)
Gitlab::Sentry.track_exception( Gitlab::ErrorTracking.track_exception(
exception, exception,
project_path: issuable.project.full_path, project_path: issuable.project.full_path,
issuable_type: issuable.class.name, issuable_type: issuable.class.name,
......
...@@ -44,7 +44,7 @@ module IconsHelper ...@@ -44,7 +44,7 @@ module IconsHelper
def sprite_icon(icon_name, size: nil, css_class: nil) def sprite_icon(icon_name, size: nil, css_class: nil)
if known_sprites&.exclude?(icon_name) if known_sprites&.exclude?(icon_name)
exception = ArgumentError.new("#{icon_name} is not a known icon in @gitlab-org/gitlab-svg") exception = ArgumentError.new("#{icon_name} is not a known icon in @gitlab-org/gitlab-svg")
Gitlab::Sentry.track_and_raise_for_dev_exception(exception) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(exception)
end end
css_classes = [] css_classes = []
......
...@@ -57,7 +57,7 @@ module UsersHelper ...@@ -57,7 +57,7 @@ module UsersHelper
unless user.association(:status).loaded? unless user.association(:status).loaded?
exception = RuntimeError.new("Status was not preloaded") exception = RuntimeError.new("Status was not preloaded")
Gitlab::Sentry.track_and_raise_for_dev_exception(exception, user: user.inspect) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(exception, user: user.inspect)
end end
return unless user.status return unless user.status
......
...@@ -289,7 +289,7 @@ module Ci ...@@ -289,7 +289,7 @@ module Ci
begin begin
build.deployment.drop! build.deployment.drop!
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e, build_id: build.id) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, build_id: build.id)
end end
true true
......
...@@ -26,7 +26,7 @@ module Ci ...@@ -26,7 +26,7 @@ module Ci
create_ref(sha, path) create_ref(sha, path)
rescue => e rescue => e
Gitlab::Sentry Gitlab::ErrorTracking
.track_exception(e, pipeline_id: pipeline.id) .track_exception(e, pipeline_id: pipeline.id)
end end
...@@ -37,7 +37,7 @@ module Ci ...@@ -37,7 +37,7 @@ module Ci
rescue Gitlab::Git::Repository::NoRepository rescue Gitlab::Git::Repository::NoRepository
# no-op # no-op
rescue => e rescue => e
Gitlab::Sentry Gitlab::ErrorTracking
.track_exception(e, pipeline_id: pipeline.id) .track_exception(e, pipeline_id: pipeline.id)
end end
......
...@@ -335,7 +335,7 @@ module Clusters ...@@ -335,7 +335,7 @@ module Clusters
rescue Kubeclient::HttpError => e rescue Kubeclient::HttpError => e
kubeclient_error_status(e.message) kubeclient_error_status(e.message)
rescue => e rescue => e
Gitlab::Sentry.track_exception(e, cluster_id: id) Gitlab::ErrorTracking.track_exception(e, cluster_id: id)
:unknown_failure :unknown_failure
else else
......
...@@ -76,7 +76,7 @@ module Clusters ...@@ -76,7 +76,7 @@ module Clusters
message: error.message message: error.message
}) })
Gitlab::Sentry.track_exception(error, cluster_id: cluster&.id, application_id: id) Gitlab::ErrorTracking.track_exception(error, cluster_id: cluster&.id, application_id: id)
end end
end end
end end
......
...@@ -52,7 +52,7 @@ module GroupDescendant ...@@ -52,7 +52,7 @@ module GroupDescendant
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/49404' issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/49404'
} }
Gitlab::Sentry.track_and_raise_for_dev_exception(exception, extras) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(exception, extras)
end end
if parent.nil? && hierarchy_top.present? if parent.nil? && hierarchy_top.present?
......
...@@ -37,7 +37,7 @@ module Storage ...@@ -37,7 +37,7 @@ module Storage
send_update_instructions send_update_instructions
write_projects_repository_config write_projects_repository_config
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e, Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e,
full_path_before_last_save: full_path_before_last_save, full_path_before_last_save: full_path_before_last_save,
full_path: full_path, full_path: full_path,
action: 'move_dir') action: 'move_dir')
......
...@@ -1514,7 +1514,7 @@ class MergeRequest < ApplicationRecord ...@@ -1514,7 +1514,7 @@ class MergeRequest < ApplicationRecord
end end
end end
rescue ActiveRecord::LockWaitTimeout => e rescue ActiveRecord::LockWaitTimeout => e
Gitlab::Sentry.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
raise RebaseLockTimeout, REBASE_LOCK_MESSAGE raise RebaseLockTimeout, REBASE_LOCK_MESSAGE
end end
......
...@@ -104,7 +104,7 @@ class Upload < ApplicationRecord ...@@ -104,7 +104,7 @@ class Upload < ApplicationRecord
# Help sysadmins find missing upload files # Help sysadmins find missing upload files
if persisted? && !exist if persisted? && !exist
exception = RuntimeError.new("Uploaded file does not exist") exception = RuntimeError.new("Uploaded file does not exist")
Gitlab::Sentry.track_exception(exception, self.attributes) Gitlab::ErrorTracking.track_exception(exception, self.attributes)
Gitlab::Metrics.counter(:upload_file_does_not_exist_total, _('The number of times an upload record could not find its file')).increment Gitlab::Metrics.counter(:upload_file_does_not_exist_total, _('The number of times an upload record could not find its file')).increment
end end
......
...@@ -23,7 +23,7 @@ module Uploads ...@@ -23,7 +23,7 @@ module Uploads
unless in_uploads?(path) unless in_uploads?(path)
message = "Path '#{path}' is not in uploads dir, skipping" message = "Path '#{path}' is not in uploads dir, skipping"
logger.warn(message) logger.warn(message)
Gitlab::Sentry.track_and_raise_for_dev_exception( Gitlab::ErrorTracking.track_and_raise_for_dev_exception(
RuntimeError.new(message), uploads_dir: storage_dir) RuntimeError.new(message), uploads_dir: storage_dir)
return return
end end
......
...@@ -46,7 +46,7 @@ module Ci ...@@ -46,7 +46,7 @@ module Ci
message: "Failed to archive trace. message: #{error.message}.", message: "Failed to archive trace. message: #{error.message}.",
job_id: job.id) job_id: job.id)
Gitlab::Sentry Gitlab::ErrorTracking
.track_and_raise_for_dev_exception(error, .track_and_raise_for_dev_exception(error,
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/51502', issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/51502',
job_id: job.id ) job_id: job.id )
......
...@@ -15,7 +15,7 @@ module Ci ...@@ -15,7 +15,7 @@ module Ci
data: data data: data
} }
rescue => e rescue => e
Gitlab::Sentry.track_exception(e, project_id: project.id) Gitlab::ErrorTracking.track_exception(e, project_id: project.id)
{ {
status: :error, status: :error,
key: key(base_pipeline, head_pipeline), key: key(base_pipeline, head_pipeline),
......
...@@ -13,7 +13,7 @@ module Ci ...@@ -13,7 +13,7 @@ module Ci
build.enqueue! build.enqueue!
rescue => e rescue => e
Gitlab::Sentry.track_exception(e, build_id: build.id) Gitlab::ErrorTracking.track_exception(e, build_id: build.id)
build.drop(:unmet_prerequisites) build.drop(:unmet_prerequisites)
end end
......
...@@ -128,7 +128,7 @@ module Ci ...@@ -128,7 +128,7 @@ module Ci
end end
def track_exception_for_build(ex, build) def track_exception_for_build(ex, build)
Gitlab::Sentry.track_exception(ex, Gitlab::ErrorTracking.track_exception(ex,
build_id: build.id, build_id: build.id,
build_name: build.name, build_name: build.name,
build_stage: build.stage, build_stage: build.stage,
......
...@@ -21,7 +21,7 @@ module Clusters ...@@ -21,7 +21,7 @@ module Clusters
group_ids: app.cluster.group_ids group_ids: app.cluster.group_ids
} }
Gitlab::Sentry.track_exception(error, meta) Gitlab::ErrorTracking.track_exception(error, meta)
end end
def log_event(event) def log_event(event)
......
...@@ -51,7 +51,7 @@ module Projects ...@@ -51,7 +51,7 @@ module Projects
digests = deleted_tags.values.uniq digests = deleted_tags.values.uniq
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
Gitlab::Sentry.track_and_raise_for_dev_exception(ArgumentError.new('multiple tag digests')) if digests.many? Gitlab::ErrorTracking.track_and_raise_for_dev_exception(ArgumentError.new('multiple tag digests')) if digests.many?
deleted_tags deleted_tags
end end
......
...@@ -25,13 +25,13 @@ module Projects ...@@ -25,13 +25,13 @@ module Projects
success success
rescue Gitlab::UrlBlocker::BlockedUrlError => e rescue Gitlab::UrlBlocker::BlockedUrlError => e
Gitlab::Sentry.track_exception(e, project_path: project.full_path, importer: project.import_type) Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type)
error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: e.message }) error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: e.message })
rescue => e rescue => e
message = Projects::ImportErrorFilter.filter_message(e.message) message = Projects::ImportErrorFilter.filter_message(e.message)
Gitlab::Sentry.track_exception(e, project_path: project.full_path, importer: project.import_type) Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type)
error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: message }) error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: message })
end end
......
...@@ -32,7 +32,7 @@ module Prometheus ...@@ -32,7 +32,7 @@ module Prometheus
success(result) success(result)
rescue TypeError, ArgumentError => exception rescue TypeError, ArgumentError => exception
log_error(exception.message) log_error(exception.message)
Gitlab::Sentry.track_exception(exception, extra: { Gitlab::ErrorTracking.track_exception(exception, extra: {
template_string: query, template_string: query,
variables: predefined_context variables: predefined_context
}) })
......
...@@ -15,7 +15,7 @@ class DeleteStoredFilesWorker ...@@ -15,7 +15,7 @@ class DeleteStoredFilesWorker
unless klass unless klass
message = "Unknown class '#{class_name}'" message = "Unknown class '#{class_name}'"
logger.error(message) logger.error(message)
Gitlab::Sentry.track_and_raise_for_dev_exception(RuntimeError.new(message)) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(RuntimeError.new(message))
return return
end end
......
...@@ -11,7 +11,7 @@ class PagesDomainRemovalCronWorker ...@@ -11,7 +11,7 @@ class PagesDomainRemovalCronWorker
PagesDomain.for_removal.find_each do |domain| PagesDomain.for_removal.find_each do |domain|
domain.destroy! domain.destroy!
rescue => e rescue => e
Gitlab::Sentry.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
end end
end end
end end
...@@ -38,7 +38,7 @@ class RunPipelineScheduleWorker ...@@ -38,7 +38,7 @@ class RunPipelineScheduleWorker
Rails.logger.error "Failed to create a scheduled pipeline. " \ Rails.logger.error "Failed to create a scheduled pipeline. " \
"schedule_id: #{schedule.id} message: #{error.message}" "schedule_id: #{schedule.id} message: #{error.message}"
Gitlab::Sentry Gitlab::ErrorTracking
.track_and_raise_for_dev_exception(error, .track_and_raise_for_dev_exception(error,
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/41231', issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/41231',
schedule_id: schedule.id) schedule_id: schedule.id)
......
...@@ -80,7 +80,7 @@ class StuckCiJobsWorker ...@@ -80,7 +80,7 @@ class StuckCiJobsWorker
end end
def track_exception_for_build(ex, build) def track_exception_for_build(ex, build)
Gitlab::Sentry.track_exception(ex, Gitlab::ErrorTracking.track_exception(ex,
build_id: build.id, build_id: build.id,
build_name: build.name, build_name: build.name,
build_stage: build.stage, build_stage: build.stage,
......
...@@ -29,7 +29,7 @@ module Sidekiq ...@@ -29,7 +29,7 @@ module Sidekiq
MSG MSG
rescue Sidekiq::Worker::EnqueueFromTransactionError => e rescue Sidekiq::Worker::EnqueueFromTransactionError => e
::Rails.logger.error(e.message) if ::Rails.env.production? ::Rails.logger.error(e.message) if ::Rails.env.production?
Gitlab::Sentry.track_and_raise_for_dev_exception(e) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
end end
end end
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
require 'gitlab/current_settings' require 'gitlab/current_settings'
Gitlab::Sentry.configure Gitlab::ErrorTracking.configure
...@@ -142,21 +142,21 @@ It should be noted that manual logging of exceptions is not allowed, as: ...@@ -142,21 +142,21 @@ It should be noted that manual logging of exceptions is not allowed, as:
1. It is very likely that manually logged exceptions will end-up across 1. It is very likely that manually logged exceptions will end-up across
multiple files, which increases burden scraping all logging files. multiple files, which increases burden scraping all logging files.
To avoid duplicating and having consistent behavior the `Gitlab::Sentry` To avoid duplicating and having consistent behavior the `Gitlab::ErrorTracking`
provides helper methods to track exceptions: provides helper methods to track exceptions:
1. `Gitlab::Sentry.track_and_raise_exception`: this method logs, 1. `Gitlab::ErrorTracking.track_and_raise_exception`: this method logs,
sends exception to Sentry (if configured) and re-raises the exception, sends exception to Sentry (if configured) and re-raises the exception,
1. `Gitlab::Sentry.track_exception`: this method only logs 1. `Gitlab::ErrorTracking.track_exception`: this method only logs
and sends exception to Sentry (if configured), and sends exception to Sentry (if configured),
1. `Gitlab::Sentry.log_exception`: this method only logs the exception, 1. `Gitlab::ErrorTracking.log_exception`: this method only logs the exception,
and DOES NOT send the exception to Sentry, and DOES NOT send the exception to Sentry,
1. `Gitlab::Sentry.track_and_raise_for_dev_exception`: this method logs, 1. `Gitlab::ErrorTracking.track_and_raise_for_dev_exception`: this method logs,
sends exception to Sentry (if configured) and re-raises the exception sends exception to Sentry (if configured) and re-raises the exception
for development and test enviroments. for development and test enviroments.
It is advised to only use `Gitlab::Sentry.track_and_raise_exception` It is advised to only use `Gitlab::ErrorTracking.track_and_raise_exception`
and `Gitlab::Sentry.track_exception` as presented on below examples. and `Gitlab::ErrorTracking.track_exception` as presented on below examples.
Consider adding additional extra parameters to provide more context Consider adding additional extra parameters to provide more context
for each tracked exception. for each tracked exception.
...@@ -170,7 +170,7 @@ class MyService < ::BaseService ...@@ -170,7 +170,7 @@ class MyService < ::BaseService
success success
rescue => e rescue => e
Gitlab::Sentry.track_exception(e, project_id: project.id) Gitlab::ErrorTracking.track_exception(e, project_id: project.id)
error('Exception occurred') error('Exception occurred')
end end
...@@ -184,7 +184,7 @@ class MyService < ::BaseService ...@@ -184,7 +184,7 @@ class MyService < ::BaseService
success success
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_exception(e, project_id: project.id) Gitlab::ErrorTracking.track_and_raise_exception(e, project_id: project.id)
end end
end end
``` ```
......
...@@ -126,7 +126,7 @@ module EE ...@@ -126,7 +126,7 @@ module EE
status: :error status: :error
}.merge(opts) }.merge(opts)
rescue Kubeclient::HttpError => e rescue Kubeclient::HttpError => e
::Gitlab::Sentry.track_exception(e) ::Gitlab::ErrorTracking.track_exception(e)
{ {
error: _('Kubernetes API returned status code: %{error_code}') % { error: _('Kubernetes API returned status code: %{error_code}') % {
......
...@@ -106,7 +106,7 @@ class JenkinsDeprecatedService < CiService ...@@ -106,7 +106,7 @@ class JenkinsDeprecatedService < CiService
begin begin
src = Nokogiri.parse(response).css('img.build-caption-status-icon,.build-caption>img').first.attributes['src'].value src = Nokogiri.parse(response).css('img.build-caption-status-icon,.build-caption>img').first.attributes['src'].value
rescue NoMethodError => ex rescue NoMethodError => ex
Gitlab::Sentry.track_exception(ex, response: response) Gitlab::ErrorTracking.track_exception(ex, response: response)
return :error return :error
end end
......
...@@ -392,7 +392,7 @@ module API ...@@ -392,7 +392,7 @@ module API
# conan sends two upload requests, the first has no file, so we skip record creation if file.size == 0 # conan sends two upload requests, the first has no file, so we skip record creation if file.size == 0
::Packages::Conan::CreatePackageFileService.new(current_package, uploaded_file, params.merge(conan_file_type: file_type)).execute unless params['file.size'] == 0 ::Packages::Conan::CreatePackageFileService.new(current_package, uploaded_file, params.merge(conan_file_type: file_type)).execute unless params['file.size'] == 0
rescue ObjectStorage::RemoteStoreError => e rescue ObjectStorage::RemoteStoreError => e
Gitlab::Sentry.track_exception(e, file_name: params[:file_name], project_id: project.id) Gitlab::ErrorTracking.track_exception(e, file_name: params[:file_name], project_id: project.id)
forbidden! forbidden!
end end
......
...@@ -26,9 +26,9 @@ module EE ...@@ -26,9 +26,9 @@ module EE
def log_error!(extra_context = {}) def log_error!(extra_context = {})
error = LimitExceededError.new(message) error = LimitExceededError.new(message)
# TODO: change this to Gitlab::Sentry.log_exception(error, extra_context) # TODO: change this to Gitlab::ErrorTracking.log_exception(error, extra_context)
# https://gitlab.com/gitlab-org/gitlab/issues/32906 # https://gitlab.com/gitlab-org/gitlab/issues/32906
::Gitlab::Sentry.track_exception(error, extra_context) ::Gitlab::ErrorTracking.track_exception(error, extra_context)
end end
end end
end end
......
...@@ -18,7 +18,7 @@ module Gitlab ...@@ -18,7 +18,7 @@ module Gitlab
rescue JSON::ParserError rescue JSON::ParserError
raise LicenseScanningParserError, 'JSON parsing failed' raise LicenseScanningParserError, 'JSON parsing failed'
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
raise LicenseScanningParserError, 'License scanning report parsing failed' raise LicenseScanningParserError, 'License scanning report parsing failed'
end end
end end
......
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
metrics_report.add_metric(name, metric_values.first) metrics_report.add_metric(name, metric_values.first)
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
raise MetricsParserError, "Metrics parsing failed" raise MetricsParserError, "Metrics parsing failed"
end end
end end
......
...@@ -17,7 +17,7 @@ module Gitlab ...@@ -17,7 +17,7 @@ module Gitlab
rescue JSON::ParserError rescue JSON::ParserError
raise SecurityReportParserError, 'JSON parsing failed' raise SecurityReportParserError, 'JSON parsing failed'
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
raise SecurityReportParserError, "#{report.type} security report parsing failed" raise SecurityReportParserError, "#{report.type} security report parsing failed"
end end
......
...@@ -54,7 +54,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do ...@@ -54,7 +54,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
end end
it 'logs the error' do it 'logs the error' do
expect(Gitlab::Sentry).to receive(:track_exception).with( expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(EE::Gitlab::Ci::Limit::LimitExceededError), instance_of(EE::Gitlab::Ci::Limit::LimitExceededError),
project_id: project.id, plan: namespace.actual_plan_name project_id: project.id, plan: namespace.actual_plan_name
) )
...@@ -83,7 +83,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do ...@@ -83,7 +83,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
end end
it 'does not log any error' do it 'does not log any error' do
expect(Gitlab::Sentry).not_to receive(:track_exception) expect(Gitlab::ErrorTracking).not_to receive(:track_exception)
subject subject
end end
......
...@@ -56,7 +56,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do ...@@ -56,7 +56,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do
end end
it 'logs the error' do it 'logs the error' do
expect(Gitlab::Sentry).to receive(:track_exception).with( expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(EE::Gitlab::Ci::Limit::LimitExceededError), instance_of(EE::Gitlab::Ci::Limit::LimitExceededError),
project_id: project.id, plan: namespace.actual_plan_name project_id: project.id, plan: namespace.actual_plan_name
) )
...@@ -85,7 +85,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do ...@@ -85,7 +85,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do
end end
it 'does not log any error' do it 'does not log any error' do
expect(Gitlab::Sentry).not_to receive(:track_exception) expect(Gitlab::ErrorTracking).not_to receive(:track_exception)
subject subject
end end
......
...@@ -72,7 +72,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do ...@@ -72,7 +72,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do
end end
it 'logs the error' do it 'logs the error' do
expect(Gitlab::Sentry).to receive(:track_exception).with( expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(EE::Gitlab::Ci::Limit::LimitExceededError), instance_of(EE::Gitlab::Ci::Limit::LimitExceededError),
project_id: project.id, plan: namespace.actual_plan_name project_id: project.id, plan: namespace.actual_plan_name
) )
...@@ -124,7 +124,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do ...@@ -124,7 +124,7 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do
end end
it 'does not log any error' do it 'does not log any error' do
expect(Gitlab::Sentry).not_to receive(:track_exception) expect(Gitlab::ErrorTracking).not_to receive(:track_exception)
subject subject
end end
......
...@@ -384,8 +384,8 @@ module API ...@@ -384,8 +384,8 @@ module API
def handle_api_exception(exception) def handle_api_exception(exception)
if report_exception?(exception) if report_exception?(exception)
define_params_for_grape_middleware define_params_for_grape_middleware
Gitlab::Sentry.with_context(current_user) do Gitlab::ErrorTracking.with_context(current_user) do
Gitlab::Sentry.track_exception(exception, params) Gitlab::ErrorTracking.track_exception(exception, params)
end end
end end
......
...@@ -45,7 +45,7 @@ module Gitlab ...@@ -45,7 +45,7 @@ module Gitlab
backtrace = Gitlab::Profiler.clean_backtrace(ex.backtrace) backtrace = Gitlab::Profiler.clean_backtrace(ex.backtrace)
error = { type: :pull_request, iid: pull_request.iid, errors: ex.message, trace: backtrace, raw_response: pull_request.raw } error = { type: :pull_request, iid: pull_request.iid, errors: ex.message, trace: backtrace, raw_response: pull_request.raw }
Gitlab::Sentry.log_exception(ex, error) Gitlab::ErrorTracking.log_exception(ex, error)
# Omit the details from the database to avoid blowing up usage in the error column # Omit the details from the database to avoid blowing up usage in the error column
error.delete(:trace) error.delete(:trace)
......
...@@ -133,7 +133,7 @@ module Gitlab ...@@ -133,7 +133,7 @@ module Gitlab
log_info(stage: 'import_repository', message: 'finished import') log_info(stage: 'import_repository', message: 'finished import')
rescue Gitlab::Shell::Error => e rescue Gitlab::Shell::Error => e
Gitlab::Sentry.log_exception( Gitlab::ErrorTracking.log_exception(
e, e,
stage: 'import_repository', message: 'failed import', error: e.message stage: 'import_repository', message: 'failed import', error: e.message
) )
...@@ -167,7 +167,7 @@ module Gitlab ...@@ -167,7 +167,7 @@ module Gitlab
batch.each do |pull_request| batch.each do |pull_request|
import_bitbucket_pull_request(pull_request) import_bitbucket_pull_request(pull_request)
rescue StandardError => e rescue StandardError => e
Gitlab::Sentry.log_exception( Gitlab::ErrorTracking.log_exception(
e, e,
stage: 'import_pull_requests', iid: pull_request.iid, error: e.message stage: 'import_pull_requests', iid: pull_request.iid, error: e.message
) )
...@@ -182,7 +182,7 @@ module Gitlab ...@@ -182,7 +182,7 @@ module Gitlab
client.delete_branch(project_key, repository_slug, branch.name, branch.sha) client.delete_branch(project_key, repository_slug, branch.name, branch.sha)
project.repository.delete_branch(branch.name) project.repository.delete_branch(branch.name)
rescue BitbucketServer::Connection::ConnectionError => e rescue BitbucketServer::Connection::ConnectionError => e
Gitlab::Sentry.log_exception( Gitlab::ErrorTracking.log_exception(
e, e,
stage: 'delete_temp_branches', branch: branch.name, error: e.message stage: 'delete_temp_branches', branch: branch.name, error: e.message
) )
...@@ -297,7 +297,7 @@ module Gitlab ...@@ -297,7 +297,7 @@ module Gitlab
# a regular note. # a regular note.
create_fallback_diff_note(merge_request, comment, position) create_fallback_diff_note(merge_request, comment, position)
rescue StandardError => e rescue StandardError => e
Gitlab::Sentry.log_exception( Gitlab::ErrorTracking.log_exception(
e, e,
stage: 'create_diff_note', comment_id: comment.id, error: e.message stage: 'create_diff_note', comment_id: comment.id, error: e.message
) )
...@@ -338,7 +338,7 @@ module Gitlab ...@@ -338,7 +338,7 @@ module Gitlab
merge_request.notes.create!(pull_request_comment_attributes(replies)) merge_request.notes.create!(pull_request_comment_attributes(replies))
end end
rescue StandardError => e rescue StandardError => e
Gitlab::Sentry.log_exception( Gitlab::ErrorTracking.log_exception(
e, e,
stage: 'import_standalone_pr_comments', merge_request_id: merge_request.id, comment_id: comment.id, error: e.message stage: 'import_standalone_pr_comments', merge_request_id: merge_request.id, comment_id: comment.id, error: e.message
) )
......
...@@ -95,7 +95,7 @@ module Gitlab ...@@ -95,7 +95,7 @@ module Gitlab
end end
def track_and_raise_for_dev_exception(error) def track_and_raise_for_dev_exception(error)
Gitlab::Sentry.track_and_raise_for_dev_exception(error, @context.sentry_payload) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(error, @context.sentry_payload)
end end
# Overriden in EE # Overriden in EE
......
...@@ -21,7 +21,7 @@ module Gitlab ...@@ -21,7 +21,7 @@ module Gitlab
rescue Gitlab::Ci::YamlProcessor::ValidationError => ex rescue Gitlab::Ci::YamlProcessor::ValidationError => ex
error(ex.message, config_error: true) error(ex.message, config_error: true)
rescue => ex rescue => ex
Gitlab::Sentry.track_exception(ex, Gitlab::ErrorTracking.track_exception(ex,
project_id: project.id, project_id: project.id,
sha: @pipeline.sha sha: @pipeline.sha
) )
......
...@@ -35,7 +35,7 @@ module Gitlab ...@@ -35,7 +35,7 @@ module Gitlab
# match the blob, which is a bug. But we shouldn't fail to render # match the blob, which is a bug. But we shouldn't fail to render
# completely in that case, even though we want to report the error. # completely in that case, even though we want to report the error.
rescue RangeError => e rescue RangeError => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/45441') Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/45441')
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module Gitlab module Gitlab
module Sentry module ErrorTracking
class << self class << self
def configure def configure
Raven.configure do |config| Raven.configure do |config|
...@@ -113,7 +113,7 @@ module Gitlab ...@@ -113,7 +113,7 @@ module Gitlab
Gitlab::ExceptionLogFormatter.format!(exception, log_hash) Gitlab::ExceptionLogFormatter.format!(exception, log_hash)
Gitlab::Sentry::Logger.error(log_hash) Gitlab::ErrorTracking::Logger.error(log_hash)
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module Gitlab module Gitlab
module Sentry module ErrorTracking
class Logger < ::Gitlab::JsonLogger class Logger < ::Gitlab::JsonLogger
def self.file_name_noext def self.file_name_noext
'exceptions_json' 'exceptions_json'
......
...@@ -67,7 +67,7 @@ module Gitlab ...@@ -67,7 +67,7 @@ module Gitlab
File.read(cert_file).scan(PEM_REGEX).map do |cert| File.read(cert_file).scan(PEM_REGEX).map do |cert|
OpenSSL::X509::Certificate.new(cert).to_pem OpenSSL::X509::Certificate.new(cert).to_pem
rescue OpenSSL::OpenSSLError => e rescue OpenSSL::OpenSSLError => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e, cert_file: cert_file) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, cert_file: cert_file)
nil nil
end.compact end.compact
end.uniq.join("\n") end.uniq.join("\n")
......
...@@ -91,7 +91,7 @@ module Gitlab ...@@ -91,7 +91,7 @@ module Gitlab
project.repository.add_branch(project.creator, source_branch, pull_request.source_branch_sha) project.repository.add_branch(project.creator, source_branch, pull_request.source_branch_sha)
rescue Gitlab::Git::CommandError => e rescue Gitlab::Git::CommandError => e
Gitlab::Sentry.track_exception(e, Gitlab::ErrorTracking.track_exception(e,
source_branch: source_branch, source_branch: source_branch,
project_id: merge_request.project.id, project_id: merge_request.project.id,
merge_request_id: merge_request.id) merge_request_id: merge_request.id)
......
...@@ -110,7 +110,7 @@ module Gitlab ...@@ -110,7 +110,7 @@ module Gitlab
folder_contents = Dir.children(tmp_dir) folder_contents = Dir.children(tmp_dir)
# This means we left a GPG-agent process hanging. Logging the problem in # This means we left a GPG-agent process hanging. Logging the problem in
# sentry will make this more visible. # sentry will make this more visible.
Gitlab::Sentry.track_and_raise_for_dev_exception(e, Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e,
issue_url: 'https://gitlab.com/gitlab-org/gitlab/issues/20918', issue_url: 'https://gitlab.com/gitlab-org/gitlab/issues/20918',
tmp_dir: tmp_dir, contents: folder_contents) tmp_dir: tmp_dir, contents: folder_contents)
end end
......
...@@ -32,7 +32,7 @@ module Gitlab ...@@ -32,7 +32,7 @@ module Gitlab
# Will inform you if there needs to be `calls_gitaly: true` as a kwarg in the field declaration # Will inform you if there needs to be `calls_gitaly: true` as a kwarg in the field declaration
# if there is at least 1 Gitaly call involved with the field resolution. # if there is at least 1 Gitaly call involved with the field resolution.
error = RuntimeError.new("Gitaly is called for field '#{type_object.name}' on #{type_object.owner.try(:name)} - please either specify a constant complexity or add `calls_gitaly: true` to the field declaration") error = RuntimeError.new("Gitaly is called for field '#{type_object.name}' on #{type_object.owner.try(:name)} - please either specify a constant complexity or add `calls_gitaly: true` to the field declaration")
Gitlab::Sentry.track_and_raise_for_dev_exception(error) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(error)
end end
end end
end end
......
...@@ -18,7 +18,7 @@ module Gitlab ...@@ -18,7 +18,7 @@ module Gitlab
variables: variables variables: variables
}) })
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
default_initial_values(query) default_initial_values(query)
end end
...@@ -38,7 +38,7 @@ module Gitlab ...@@ -38,7 +38,7 @@ module Gitlab
GraphqlLogger.info(memo.except!(:time_started, :query)) GraphqlLogger.info(memo.except!(:time_started, :query))
rescue => e rescue => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
end end
private private
......
...@@ -61,7 +61,7 @@ module Gitlab ...@@ -61,7 +61,7 @@ module Gitlab
tokens = lexer.lex(text, continue: continue) tokens = lexer.lex(text, continue: continue)
Timeout.timeout(timeout_time) { @formatter.format(tokens, tag: tag).html_safe } Timeout.timeout(timeout_time) { @formatter.format(tokens, tag: tag).html_safe }
rescue Timeout::Error => e rescue Timeout::Error => e
Gitlab::Sentry.track_and_raise_for_dev_exception(e) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
highlight_plain(text) highlight_plain(text)
rescue rescue
highlight_plain(text) highlight_plain(text)
......
...@@ -82,7 +82,7 @@ module Gitlab ...@@ -82,7 +82,7 @@ module Gitlab
end end
def log_import_failure(relation_key, relation_index, exception) def log_import_failure(relation_key, relation_index, exception)
Gitlab::Sentry.track_exception(exception, Gitlab::ErrorTracking.track_exception(exception,
project_id: @importable.id, relation_key: relation_key, relation_index: relation_index) project_id: @importable.id, relation_key: relation_key, relation_index: relation_index)
ImportFailure.create( ImportFailure.create(
......
...@@ -56,7 +56,7 @@ module Gitlab ...@@ -56,7 +56,7 @@ module Gitlab
end end
def error(error) def error(error)
Gitlab::Sentry.track_exception(error, log_base_data) Gitlab::ErrorTracking.track_exception(error, log_base_data)
add_error_message(error.message) add_error_message(error.message)
end end
......
...@@ -126,7 +126,7 @@ module Gitlab ...@@ -126,7 +126,7 @@ module Gitlab
true true
rescue => e rescue => e
Gitlab::Sentry.track_exception(e, path: path, new_path: new_path, storage: storage) Gitlab::ErrorTracking.track_exception(e, path: path, new_path: new_path, storage: storage)
false false
end end
...@@ -158,7 +158,7 @@ module Gitlab ...@@ -158,7 +158,7 @@ module Gitlab
true true
rescue => e rescue => e
Rails.logger.warn("Repository does not exist: #{e} at: #{name}.git") # rubocop:disable Gitlab/RailsLogger Rails.logger.warn("Repository does not exist: #{e} at: #{name}.git") # rubocop:disable Gitlab/RailsLogger
Gitlab::Sentry.track_exception(e, path: name, storage: storage) Gitlab::ErrorTracking.track_exception(e, path: name, storage: storage)
false false
end end
...@@ -267,7 +267,7 @@ module Gitlab ...@@ -267,7 +267,7 @@ module Gitlab
def mv_namespace(storage, old_name, new_name) def mv_namespace(storage, old_name, new_name)
Gitlab::GitalyClient::NamespaceService.new(storage).rename(old_name, new_name) Gitlab::GitalyClient::NamespaceService.new(storage).rename(old_name, new_name)
rescue GRPC::InvalidArgument => e rescue GRPC::InvalidArgument => e
Gitlab::Sentry.track_exception(e, old_name: old_name, new_name: new_name, storage: storage) Gitlab::ErrorTracking.track_exception(e, old_name: old_name, new_name: new_name, storage: storage)
false false
end end
......
...@@ -8,7 +8,7 @@ module Gitlab::UsageDataCounters ...@@ -8,7 +8,7 @@ module Gitlab::UsageDataCounters
class << self class << self
def redis_key(event) def redis_key(event)
Gitlab::Sentry.track_and_raise_for_dev_exception(UnknownEvent.new, event: event) unless known_events.include?(event.to_s) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(UnknownEvent.new, event: event) unless known_events.include?(event.to_s)
"USAGE_#{prefix}_#{event}".upcase "USAGE_#{prefix}_#{event}".upcase
end end
......
...@@ -62,7 +62,7 @@ module Sentry ...@@ -62,7 +62,7 @@ module Sentry
def handle_mapping_exceptions(&block) def handle_mapping_exceptions(&block)
yield yield
rescue KeyError => e rescue KeyError => e
Gitlab::Sentry.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
raise MissingKeysError, "Sentry API response is missing keys. #{e.message}" raise MissingKeysError, "Sentry API response is missing keys. #{e.message}"
end end
...@@ -118,7 +118,7 @@ module Sentry ...@@ -118,7 +118,7 @@ module Sentry
def handle_request_exceptions def handle_request_exceptions
yield yield
rescue Gitlab::HTTP::Error => e rescue Gitlab::HTTP::Error => e
Gitlab::Sentry.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
raise_error 'Error when connecting to Sentry' raise_error 'Error when connecting to Sentry'
rescue Net::OpenTimeout rescue Net::OpenTimeout
raise_error 'Connection to Sentry timed out' raise_error 'Connection to Sentry timed out'
...@@ -129,7 +129,7 @@ module Sentry ...@@ -129,7 +129,7 @@ module Sentry
rescue Errno::ECONNREFUSED rescue Errno::ECONNREFUSED
raise_error 'Connection refused' raise_error 'Connection refused'
rescue => e rescue => e
Gitlab::Sentry.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
raise_error "Sentry request failed due to #{e.class}" raise_error "Sentry request failed due to #{e.class}"
end end
......
...@@ -1159,7 +1159,7 @@ describe Projects::IssuesController do ...@@ -1159,7 +1159,7 @@ describe Projects::IssuesController do
end end
it "prevents deletion if destroy_confirm is not set" do it "prevents deletion if destroy_confirm is not set" do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
...@@ -1168,7 +1168,7 @@ describe Projects::IssuesController do ...@@ -1168,7 +1168,7 @@ describe Projects::IssuesController do
end end
it "prevents deletion in JSON format if destroy_confirm is not set" do it "prevents deletion in JSON format if destroy_confirm is not set" do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, format: 'json' } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, format: 'json' }
......
...@@ -620,7 +620,7 @@ describe Projects::MergeRequestsController do ...@@ -620,7 +620,7 @@ describe Projects::MergeRequestsController do
end end
it "prevents deletion if destroy_confirm is not set" do it "prevents deletion if destroy_confirm is not set" do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
...@@ -629,7 +629,7 @@ describe Projects::MergeRequestsController do ...@@ -629,7 +629,7 @@ describe Projects::MergeRequestsController do
end end
it "prevents deletion in JSON format if destroy_confirm is not set" do it "prevents deletion in JSON format if destroy_confirm is not set" do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, format: 'json' } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, format: 'json' }
......
...@@ -157,7 +157,7 @@ describe Gitlab::Ci::Config do ...@@ -157,7 +157,7 @@ describe Gitlab::Ci::Config do
describe '.new' do describe '.new' do
it 'raises error' do it 'raises error' do
expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
expect { config }.to raise_error( expect { config }.to raise_error(
described_class::ConfigError, described_class::ConfigError,
...@@ -367,7 +367,7 @@ describe Gitlab::Ci::Config do ...@@ -367,7 +367,7 @@ describe Gitlab::Ci::Config do
end end
it 'raises error TimeoutError' do it 'raises error TimeoutError' do
expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
expect { config }.to raise_error( expect { config }.to raise_error(
described_class::ConfigError, described_class::ConfigError,
......
...@@ -105,7 +105,7 @@ describe Gitlab::Diff::Highlight do ...@@ -105,7 +105,7 @@ describe Gitlab::Diff::Highlight do
end end
it 'keeps the original rich line' do it 'keeps the original rich line' do
allow(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
code = %q{+ raise RuntimeError, "System commands must be given as an array of strings"} code = %q{+ raise RuntimeError, "System commands must be given as an array of strings"}
...@@ -114,7 +114,7 @@ describe Gitlab::Diff::Highlight do ...@@ -114,7 +114,7 @@ describe Gitlab::Diff::Highlight do
end end
it 'reports to Sentry if configured' do it 'reports to Sentry if configured' do
expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).and_call_original
expect { subject }. to raise_exception(RangeError) expect { subject }. to raise_exception(RangeError)
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::Sentry do describe Gitlab::ErrorTracking do
let(:exception) { RuntimeError.new('boom') } let(:exception) { RuntimeError.new('boom') }
let(:issue_url) { 'http://gitlab.com/gitlab-org/gitlab-foss/issues/1' } let(:issue_url) { 'http://gitlab.com/gitlab-org/gitlab-foss/issues/1' }
...@@ -76,8 +76,8 @@ describe Gitlab::Sentry do ...@@ -76,8 +76,8 @@ describe Gitlab::Sentry do
) )
end end
it 'calls Gitlab::Sentry::Logger.error with formatted payload' do it 'calls Gitlab::ErrorTracking::Logger.error with formatted payload' do
expect(Gitlab::Sentry::Logger).to receive(:error) expect(Gitlab::ErrorTracking::Logger).to receive(:error)
.with(a_hash_including(*expected_payload_includes)) .with(a_hash_including(*expected_payload_includes))
described_class.track_and_raise_for_dev_exception( described_class.track_and_raise_for_dev_exception(
...@@ -97,8 +97,8 @@ describe Gitlab::Sentry do ...@@ -97,8 +97,8 @@ describe Gitlab::Sentry do
.to raise_error(RuntimeError) .to raise_error(RuntimeError)
end end
it 'calls Gitlab::Sentry::Logger.error with formatted payload' do it 'calls Gitlab::ErrorTracking::Logger.error with formatted payload' do
expect(Gitlab::Sentry::Logger).to receive(:error) expect(Gitlab::ErrorTracking::Logger).to receive(:error)
.with(a_hash_including(*expected_payload_includes)) .with(a_hash_including(*expected_payload_includes))
expect do expect do
...@@ -134,8 +134,8 @@ describe Gitlab::Sentry do ...@@ -134,8 +134,8 @@ describe Gitlab::Sentry do
) )
end end
it 'calls Gitlab::Sentry::Logger.error with formatted payload' do it 'calls Gitlab::ErrorTracking::Logger.error with formatted payload' do
expect(Gitlab::Sentry::Logger).to receive(:error) expect(Gitlab::ErrorTracking::Logger).to receive(:error)
.with(a_hash_including(*expected_payload_includes)) .with(a_hash_including(*expected_payload_includes))
described_class.track_exception( described_class.track_exception(
......
...@@ -86,7 +86,7 @@ describe Gitlab::GitalyClient do ...@@ -86,7 +86,7 @@ describe Gitlab::GitalyClient do
describe '.stub_certs' do describe '.stub_certs' do
it 'skips certificates if OpenSSLError is raised and report it' do it 'skips certificates if OpenSSLError is raised and report it' do
expect(Gitlab::Sentry) expect(Gitlab::ErrorTracking)
.to receive(:track_and_raise_for_dev_exception) .to receive(:track_and_raise_for_dev_exception)
.with( .with(
a_kind_of(OpenSSL::X509::CertificateError), a_kind_of(OpenSSL::X509::CertificateError),
......
...@@ -301,7 +301,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi ...@@ -301,7 +301,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
it 'ignores Git command errors when creating a branch' do it 'ignores Git command errors when creating a branch' do
expect(project.repository).to receive(:add_branch).and_raise(Gitlab::Git::CommandError) expect(project.repository).to receive(:add_branch).and_raise(Gitlab::Git::CommandError)
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original
mr = insert_git_data mr = insert_git_data
......
...@@ -182,14 +182,14 @@ describe Gitlab::Gpg do ...@@ -182,14 +182,14 @@ describe Gitlab::Gpg do
expected_tmp_dir = nil expected_tmp_dir = nil
expect(described_class).to receive(:cleanup_tmp_dir).and_raise(expected_exception) expect(described_class).to receive(:cleanup_tmp_dir).and_raise(expected_exception)
allow(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
described_class.using_tmp_keychain do described_class.using_tmp_keychain do
expected_tmp_dir = described_class.current_home_dir expected_tmp_dir = described_class.current_home_dir
FileUtils.touch(File.join(expected_tmp_dir, 'dummy.file')) FileUtils.touch(File.join(expected_tmp_dir, 'dummy.file'))
end end
expect(Gitlab::Sentry).to have_received(:track_and_raise_for_dev_exception).with( expect(Gitlab::ErrorTracking).to have_received(:track_and_raise_for_dev_exception).with(
expected_exception, expected_exception,
issue_url: 'https://gitlab.com/gitlab-org/gitlab/issues/20918', issue_url: 'https://gitlab.com/gitlab-org/gitlab/issues/20918',
tmp_dir: expected_tmp_dir, contents: ['dummy.file'] tmp_dir: expected_tmp_dir, contents: ['dummy.file']
......
...@@ -49,7 +49,7 @@ describe Gitlab::ImportExport::Shared do ...@@ -49,7 +49,7 @@ describe Gitlab::ImportExport::Shared do
it 'updates the import JID' do it 'updates the import JID' do
import_state = create(:import_state, project: project, jid: 'jid-test') import_state = create(:import_state, project: project, jid: 'jid-test')
expect(Gitlab::Sentry) expect(Gitlab::ErrorTracking)
.to receive(:track_exception) .to receive(:track_exception)
.with(error, hash_including(import_jid: import_state.jid)) .with(error, hash_including(import_jid: import_state.jid))
......
...@@ -3522,7 +3522,7 @@ describe Ci::Build do ...@@ -3522,7 +3522,7 @@ describe Ci::Build do
end end
it 'can drop the build' do it 'can drop the build' do
expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
expect { build.drop! }.not_to raise_error expect { build.drop! }.not_to raise_error
......
...@@ -1004,7 +1004,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -1004,7 +1004,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
it { is_expected.to eq(connection_status: :unknown_failure) } it { is_expected.to eq(connection_status: :unknown_failure) }
it 'notifies Sentry' do it 'notifies Sentry' do
expect(Gitlab::Sentry).to receive(:track_exception) expect(Gitlab::ErrorTracking).to receive(:track_exception)
.with(instance_of(StandardError), hash_including(cluster_id: cluster.id)) .with(instance_of(StandardError), hash_including(cluster_id: cluster.id))
subject subject
......
...@@ -82,7 +82,7 @@ describe GroupDescendant do ...@@ -82,7 +82,7 @@ describe GroupDescendant do
end end
it 'tracks the exception when a parent was not preloaded' do it 'tracks the exception when a parent was not preloaded' do
expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).and_call_original
expect { described_class.build_hierarchy([subsub_group]) }.to raise_error(ArgumentError) expect { described_class.build_hierarchy([subsub_group]) }.to raise_error(ArgumentError)
end end
...@@ -91,7 +91,7 @@ describe GroupDescendant do ...@@ -91,7 +91,7 @@ describe GroupDescendant do
expected_hierarchy = { parent => { subgroup => subsub_group } } expected_hierarchy = { parent => { subgroup => subsub_group } }
# this does not raise in production, so stubbing it here. # this does not raise in production, so stubbing it here.
allow(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
expect(described_class.build_hierarchy([subsub_group])).to eq(expected_hierarchy) expect(described_class.build_hierarchy([subsub_group])).to eq(expected_hierarchy)
end end
......
...@@ -281,7 +281,7 @@ describe Namespace do ...@@ -281,7 +281,7 @@ describe Namespace do
move_dir_result move_dir_result
end end
expect(Gitlab::Sentry).to receive(:should_raise_for_dev?).and_return(false) # like prod expect(Gitlab::ErrorTracking).to receive(:should_raise_for_dev?).and_return(false) # like prod
namespace.update(path: namespace.full_path + '_new') namespace.update(path: namespace.full_path + '_new')
end end
......
...@@ -171,7 +171,7 @@ describe Upload do ...@@ -171,7 +171,7 @@ describe Upload do
it 'sends a message to Sentry' do it 'sends a message to Sentry' do
upload = create(:upload, :issuable_upload) upload = create(:upload, :issuable_upload)
expect(Gitlab::Sentry).to receive(:track_exception).with(instance_of(RuntimeError), upload.attributes) expect(Gitlab::ErrorTracking).to receive(:track_exception).with(instance_of(RuntimeError), upload.attributes)
upload.exist? upload.exist?
end end
......
...@@ -46,7 +46,7 @@ describe 'GraphQL' do ...@@ -46,7 +46,7 @@ describe 'GraphQL' do
end end
it 'logs the exception in Sentry and continues with the request' do it 'logs the exception in Sentry and continues with the request' do
expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception).at_least(1).times expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).at_least(1).times
expect(Gitlab::GraphqlLogger).to receive(:info) expect(Gitlab::GraphqlLogger).to receive(:info)
post_graphql(query, variables: {}) post_graphql(query, variables: {})
...@@ -146,7 +146,7 @@ describe 'GraphQL' do ...@@ -146,7 +146,7 @@ describe 'GraphQL' do
end end
it "logs a warning that the 'calls_gitaly' field declaration is missing" do it "logs a warning that the 'calls_gitaly' field declaration is missing" do
expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception).once expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).once
post_graphql(query, current_user: user) post_graphql(query, current_user: user)
end end
......
...@@ -229,8 +229,8 @@ describe API::Helpers do ...@@ -229,8 +229,8 @@ describe API::Helpers do
stub_sentry_settings stub_sentry_settings
expect(Gitlab::Sentry).to receive(:sentry_dsn).and_return(Gitlab.config.sentry.dsn) expect(Gitlab::ErrorTracking).to receive(:sentry_dsn).and_return(Gitlab.config.sentry.dsn)
Gitlab::Sentry.configure Gitlab::ErrorTracking.configure
Raven.client.configuration.encoding = 'json' Raven.client.configuration.encoding = 'json'
end end
......
...@@ -59,7 +59,7 @@ describe Ci::ArchiveTraceService, '#execute' do ...@@ -59,7 +59,7 @@ describe Ci::ArchiveTraceService, '#execute' do
let(:job) { create(:ci_build, :running, :trace_live) } let(:job) { create(:ci_build, :running, :trace_live) }
it 'increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive' do it 'increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive' do
expect(Gitlab::Sentry) expect(Gitlab::ErrorTracking)
.to receive(:track_and_raise_for_dev_exception) .to receive(:track_and_raise_for_dev_exception)
.with(::Gitlab::Ci::Trace::ArchiveError, .with(::Gitlab::Ci::Trace::ArchiveError,
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/51502', issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/51502',
......
...@@ -528,7 +528,7 @@ describe Ci::CreatePipelineService do ...@@ -528,7 +528,7 @@ describe Ci::CreatePipelineService do
end end
it 'logs error' do it 'logs error' do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original
execute_service execute_service
end end
...@@ -613,7 +613,7 @@ describe Ci::CreatePipelineService do ...@@ -613,7 +613,7 @@ describe Ci::CreatePipelineService do
end end
it 'logs error' do it 'logs error' do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original
execute_service execute_service
end end
......
...@@ -51,7 +51,7 @@ describe Ci::PrepareBuildService do ...@@ -51,7 +51,7 @@ describe Ci::PrepareBuildService do
it 'drops the build and notifies Sentry' do it 'drops the build and notifies Sentry' do
expect(build).to receive(:drop).with(:unmet_prerequisites).once expect(build).to receive(:drop).with(:unmet_prerequisites).once
expect(Gitlab::Sentry).to receive(:track_exception) expect(Gitlab::ErrorTracking).to receive(:track_exception)
.with(instance_of(Kubeclient::HttpError), hash_including(build_id: build.id)) .with(instance_of(Kubeclient::HttpError), hash_including(build_id: build.id))
subject subject
......
...@@ -514,7 +514,7 @@ module Ci ...@@ -514,7 +514,7 @@ module Ci
subject { execute(specific_runner, {}) } subject { execute(specific_runner, {}) }
it 'does drop the build and logs both failures' do it 'does drop the build and logs both failures' do
expect(Gitlab::Sentry).to receive(:track_exception) expect(Gitlab::ErrorTracking).to receive(:track_exception)
.with(anything, a_hash_including(build_id: pending_job.id)) .with(anything, a_hash_including(build_id: pending_job.id))
.twice .twice
.and_call_original .and_call_original
...@@ -540,7 +540,7 @@ module Ci ...@@ -540,7 +540,7 @@ module Ci
subject { execute(specific_runner, {}) } subject { execute(specific_runner, {}) }
it 'does drop the build and logs failure' do it 'does drop the build and logs failure' do
expect(Gitlab::Sentry).to receive(:track_exception) expect(Gitlab::ErrorTracking).to receive(:track_exception)
.with(anything, a_hash_including(build_id: pending_job.id)) .with(anything, a_hash_including(build_id: pending_job.id))
.once .once
.and_call_original .and_call_original
......
...@@ -12,7 +12,7 @@ shared_examples 'logs kubernetes errors' do ...@@ -12,7 +12,7 @@ shared_examples 'logs kubernetes errors' do
end end
it 'logs into kubernetes.log and Sentry' do it 'logs into kubernetes.log and Sentry' do
expect(Gitlab::Sentry).to receive(:track_exception).with( expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
error, error,
hash_including(error_hash) hash_including(error_hash)
) )
......
...@@ -63,7 +63,7 @@ describe Ci::ArchiveTracesCronWorker do ...@@ -63,7 +63,7 @@ describe Ci::ArchiveTracesCronWorker do
let!(:build) { create(:ci_build, :success, :trace_live, finished_at: finished_at) } let!(:build) { create(:ci_build, :success, :trace_live, finished_at: finished_at) }
before do before do
allow(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
allow_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!).and_raise('Unexpected error') allow_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!).and_raise('Unexpected error')
end end
......
...@@ -42,7 +42,7 @@ describe RunPipelineScheduleWorker do ...@@ -42,7 +42,7 @@ describe RunPipelineScheduleWorker do
before do before do
allow(Ci::CreatePipelineService).to receive(:new) { raise ActiveRecord::StatementInvalid } allow(Ci::CreatePipelineService).to receive(:new) { raise ActiveRecord::StatementInvalid }
expect(Gitlab::Sentry) expect(Gitlab::ErrorTracking)
.to receive(:track_and_raise_for_dev_exception) .to receive(:track_and_raise_for_dev_exception)
.with(ActiveRecord::StatementInvalid, .with(ActiveRecord::StatementInvalid,
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/41231', issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/41231',
......
...@@ -30,7 +30,7 @@ describe StuckCiJobsWorker do ...@@ -30,7 +30,7 @@ describe StuckCiJobsWorker do
it "does drop the job and logs the reason" do it "does drop the job and logs the reason" do
job.update_columns(yaml_variables: '[{"key" => "value"}]') job.update_columns(yaml_variables: '[{"key" => "value"}]')
expect(Gitlab::Sentry).to receive(:track_exception) expect(Gitlab::ErrorTracking).to receive(:track_exception)
.with(anything, a_hash_including(build_id: job.id)) .with(anything, a_hash_including(build_id: job.id))
.once .once
.and_call_original .and_call_original
......
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