Module: Sentry::Cron::MonitorCheckIns::Patch

Defined in:
lib/sentry/cron/monitor_check_ins.rb

Instance Method Summary collapse

Instance Method Details

#perform(*args, **opts) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sentry/cron/monitor_check_ins.rb', line 7

def perform(*args, **opts)
  slug = self.class.sentry_monitor_slug
  monitor_config = self.class.sentry_monitor_config

  check_in_id = Sentry.capture_check_in(slug,
                                        :in_progress,
                                        monitor_config: monitor_config)

  start = Sentry.utc_now.to_i

  begin
    # need to do this on ruby <= 2.6 sadly
    ret = method(:perform).super_method.arity == 0 ? super() : super
    duration = Sentry.utc_now.to_i - start

    Sentry.capture_check_in(slug,
                            :ok,
                            check_in_id: check_in_id,
                            duration: duration,
                            monitor_config: monitor_config)

    ret
  rescue Exception
    duration = Sentry.utc_now.to_i - start

    Sentry.capture_check_in(slug,
                            :error,
                            check_in_id: check_in_id,
                            duration: duration,
                            monitor_config: monitor_config)

    raise
  end
end