Skip to content

Commit

Permalink
misc: Add activejob-traceable to have context on active jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
rsempe committed Aug 30, 2022
1 parent bfc0c1a commit 9c0d2d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.1'

gem 'activejob-traceable'
gem 'analytics-ruby', '~> 2.4.0', require: 'segment/analytics'
gem 'bcrypt'
gem 'bootsnap', require: false
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ GEM
activejob (7.0.3.1)
activesupport (= 7.0.3.1)
globalid (>= 0.3.6)
activejob-traceable (0.3.5)
activejob
activesupport
activemodel (7.0.3.1)
activesupport (= 7.0.3.1)
activerecord (7.0.3.1)
Expand Down Expand Up @@ -330,6 +333,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activejob-traceable
analytics-ruby (~> 2.4.0)
aws-sdk-s3
bcrypt
Expand Down
15 changes: 15 additions & 0 deletions config/initializers/activejob_traceable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'current_context'

ActiveJob::Traceable.tracing_info_getter = lambda do
{
membership: CurrentContext.membership,
}
end

ActiveJob::Traceable.tracing_info_setter = lambda do |attributes|
return unless attributes

CurrentContext.membership = attributes[:membership]
end

0 comments on commit 9c0d2d7

Please sign in to comment.