Class: ErrorTrackingIssueLinkWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, ExclusiveLeaseGuard, Gitlab::Utils::StrongMemoize
Defined in:
app/workers/error_tracking_issue_link_worker.rb

Overview

Creates a link in Sentry between a Sentry issue and a GitLab issue. If the link already exists, no changes will occur. If a link to a different GitLab issue exists, a new link

will still be created, but will not be visible in Sentry
until the prior link is deleted.

Constant Summary collapse

LEASE_TIMEOUT =
15.minutes

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from ExclusiveLeaseGuard

#exclusive_lease, #lease_release?, #log_error, #release_lease, #renew_lease!, #try_obtain_lease

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue


18
19
20
# File 'app/workers/error_tracking_issue_link_worker.rb', line 18

def issue
  @issue
end

Instance Method Details

#perform(issue_id) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/workers/error_tracking_issue_link_worker.rb', line 20

def perform(issue_id)
  @issue = Issue.find_by_id(issue_id)

  return unless valid?

  try_obtain_lease do
    logger.info("Linking Sentry issue #{sentry_issue_id} to GitLab issue #{issue.id}")

    sentry_client.create_issue_link(integration_id, sentry_issue_id, issue)
  rescue Sentry::Client::Error => e
    logger.info("Failed to link Sentry issue #{sentry_issue_id} to GitLab issue #{issue.id} with error: #{e.message}")
  end
end