Class: InnerPerformance::SaveEventJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/inner_performance/save_event_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(type:, created_at:, event:, name:, duration:, db_runtime:, properties: {}, traces: []) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/jobs/inner_performance/save_event_job.rb', line 5

def perform(type:, created_at:, event:, name:, duration:, db_runtime:, properties: {}, traces: [])
  event = InnerPerformance::Event.create(
    type: type,
    created_at: created_at,
    event: event,
    name: name,
    duration: duration,
    db_runtime: db_runtime,
    properties: properties,
  )

  if InnerPerformance.configuration.traces_enabled && traces.any?
    InnerPerformance::Trace.insert_all(
      traces.map do |trace|
        InnerPerformance::TraceForInsertInitializer.new(trace: trace, event: event)
      end,
    )
  end

  InnerPerformance::CleanupJob.perform_later if InnerPerformance.configuration.cleanup_immediately
end