Commit 8f5c9531 authored by Stan Hu's avatar Stan Hu

Merge branch 'issue_50528' into 'master'

Log project services sidekiq failures

Closes #50528

See merge request gitlab-org/gitlab-ce!21336
parents 7e473c0e 91847531
......@@ -7,6 +7,10 @@ class ProjectServiceWorker
def perform(hook_id, data)
data = data.with_indifferent_access
Service.find(hook_id).execute(data)
service = Service.find(hook_id)
service.execute(data)
rescue => error
service_class = service&.class&.name || "Not Found"
logger.error class: self.class.name, service_class: service_class, message: error.message
end
end
---
title: Log project services errors when executing async
merge_request:
author:
type: other
# frozen_string_literal: true
require 'spec_helper'
describe ProjectServiceWorker, '#perform' do
let(:worker) { described_class.new }
let(:service) { JiraService.new }
before do
allow(Service).to receive(:find).and_return(service)
end
it 'executes service with given data' do
data = { test: 'test' }
expect(service).to receive(:execute).with(data)
worker.perform(1, data)
end
it 'logs error messages' do
allow(service).to receive(:execute).and_raise(StandardError, 'invalid URL')
expect(Sidekiq.logger).to receive(:error).with({ class: described_class.name, service_class: service.class.name, message: "invalid URL" })
worker.perform(1, {})
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