Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tracing a set of Resque jobs.
# In the web request
def start_job(*args)
# Log the fact that we're starting a job, and send the job with the current
# task id
ctx = Oboe::Context.toString
Oboe::API.log_entry('job', { :Async => true })
task_id = Oboe::Context.toString unless not Oboe::Context.isValid
Oboe::Context.fromString(ctx)
Resque.enqueue(Processdoc, task_id, *args)
end
# Worker one
class ProcessDoc
@queue = :file_serve
@task_name = :process_doc
def self.perform(xtrace, doc)
# Make sure to continue the task here
result, xtrace = Oboe::API.start_trace(@task_name, xtrace) do
# Do work here
doc.process
puts "did some work on", doc.name
end
# Relinquish control of current task, and pass ID to second worker
Resque.enqueue(Archive, xtrace, doc)
end
end
# Worker two
class ArchiveDoc
@queue = :file_serve
@task_name = :archive_doc
def self.perform(task_id, doc)
# Make sure to continue the task here
result, xtrace = Oboe::API.start_trace(@task_name, task_id) do
# Do work here
puts "did some more work, stored a file in S3"
end
# Finish the job, pushing back onto the context temporarily
Oboe::Context.fromString(xtrace)
Oboe::API.log_exit('job')
Oboe::Context.clear()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.