instance method
set_context
Ruby on Rails 8.1.2
Since v8.1.2Signature
set_context(context)
Sets context data that will be included with all events emitted by the reporter. Context data should be scoped to the job or request, and is reset automatically before and after each request and job.
Rails.event.set_context(user_agent: "TestAgent") Rails.event.set_context(job_id: "abc123") Rails.event.tagged("graphql") do Rails.event.notify("user_created", { id: 123 }) end # Emits event: # { # name: "user_created", # payload: { id: 123 }, # tags: { graphql: true }, # context: { user_agent: "TestAgent", job_id: "abc123" }, # timestamp: 1738964843208679035 # source_location: { filepath: "path/to/file.rb", lineno: 123, label: "UserService#create" } # }
Parameters
-
contextreq
Source
# File activesupport/lib/active_support/event_reporter.rb, line 520
def set_context(context)
context_store.set_context(context)
end
Defined in activesupport/lib/active_support/event_reporter.rb line 520
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::EventReporter