diff options
Diffstat (limited to 'lib/bulk_imports/pipeline/runner.rb')
-rw-r--r-- | lib/bulk_imports/pipeline/runner.rb | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/lib/bulk_imports/pipeline/runner.rb b/lib/bulk_imports/pipeline/runner.rb index ef9575d1e96..81f8dee30d9 100644 --- a/lib/bulk_imports/pipeline/runner.rb +++ b/lib/bulk_imports/pipeline/runner.rb @@ -99,7 +99,7 @@ module BulkImports end def log_import_failure(exception, step) - attributes = { + failure_attributes = { bulk_import_entity_id: context.entity.id, pipeline_class: pipeline, pipeline_step: step, @@ -108,16 +108,18 @@ module BulkImports correlation_id_value: Labkit::Correlation::CorrelationId.current_or_new_id } - error( - bulk_import_id: context.bulk_import_id, - pipeline_step: step, - exception_class: exception.class.to_s, - exception_message: exception.message, - message: "Pipeline failed", - importer: 'gitlab_migration' + log_exception( + exception, + log_params( + { + bulk_import_id: context.bulk_import_id, + pipeline_step: step, + message: 'Pipeline failed' + } + ) ) - BulkImports::Failure.create(attributes) + BulkImports::Failure.create(failure_attributes) end def info(extra = {}) @@ -128,17 +130,15 @@ module BulkImports logger.warn(log_params(extra)) end - def error(extra = {}) - logger.error(log_params(extra)) - end - def log_params(extra) defaults = { bulk_import_id: context.bulk_import_id, bulk_import_entity_id: context.entity.id, bulk_import_entity_type: context.entity.source_type, + source_full_path: context.entity.source_full_path, pipeline_class: pipeline, context_extra: context.extra, + source_version: context.entity.bulk_import.source_version_info.to_s, importer: 'gitlab_migration' } @@ -150,6 +150,19 @@ module BulkImports def logger @logger ||= Gitlab::Import::Logger.build end + + def log_exception(exception, payload) + Gitlab::ExceptionLogFormatter.format!(exception, payload) + logger.error(structured_payload(payload)) + end + + def structured_payload(payload = {}) + context = Gitlab::ApplicationContext.current.merge( + 'class' => self.class.name + ) + + payload.stringify_keys.merge(context) + end end end end |