Commit 75520ee1 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Pass related_class to the context as a string

Since the Gitlab::ApplicationContext wants a string, this means that
anything else will not be passed to Labkit for logging.

We did this to avoid logging huge objects that could contain sensitive
information.

This also caused the ReactiveCachingWorker to miss it's related
class sometimes: We schedule this in
ReactiveCaching#refresh_reactive_cache! using self.class, this
would then filtered out since Class is not a String.
parent 259b4789
......@@ -15,7 +15,7 @@ class ReactiveCachingWorker # rubocop:disable Scalability/IdempotentWorker
def self.context_for_arguments(arguments)
class_name, *_other_args = arguments
Gitlab::ApplicationContext.new(related_class: class_name)
Gitlab::ApplicationContext.new(related_class: class_name.to_s)
end
def perform(class_name, id, *args)
......
......@@ -37,5 +37,13 @@ describe ReactiveCachingWorker do
expect(scheduled_job).to include('meta.related_class' => 'Environment')
end
it 'sets the related class on the job when it was passed as a class' do
described_class.perform_async(Project, 1, 'other', 'argument')
scheduled_job = described_class.jobs.first
expect(scheduled_job).to include('meta.related_class' => 'Project')
end
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