Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sentry-delayed_job integration #1273

Merged
merged 7 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add example
  • Loading branch information
st0012 committed Feb 9, 2021
commit a017742d6d608812fdfd69225aaea8bd7a4b5b8e
10 changes: 10 additions & 0 deletions sentry-delayed_job/example/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source "https://rubygems.org"

gem "rails"
gem "sqlite3"
gem "delayed_job"
gem 'delayed_job_active_record'
gem "sentry-delayed_job", path: "../"
gem "sentry-ruby", path: "../../sentry-ruby"

gem "pry"
61 changes: 61 additions & 0 deletions sentry-delayed_job/example/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require "pry"
require "active_job"
require "active_record"
require "delayed_job"
require "delayed_job_active_record"
require "logger"

# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
# ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Schema.define do
create_table :delayed_jobs do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
table.text :handler, null: false # YAML-encoded string of the object that will do work
table.text :last_error # reason for last failure (See Note below)
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
table.datetime :locked_at # Set when a client is working on this object
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
table.string :locked_by # Who is working on this object (if locked)
table.string :queue # The name of the queue this job is in
table.timestamps null: true
end
end

class MyJob < ActiveJob::Base
self.queue_adapter = :delayed_job

def perform
raise "foo"
end
end

MyJob.perform_later

enqueued_job = Delayed::Backend::ActiveRecord::Job.last

begin
enqueued_job.invoke_job
rescue => e
puts("active job failed because of \"#{e.message}\"")
end

class Foo
def bar
1 / 0
end
end

Foo.new.delay.bar

enqueued_job = Delayed::Backend::ActiveRecord::Job.last

begin
enqueued_job.invoke_job
rescue => e
puts("inline job failed because of \"#{e.message}\"")
end