-
-
Notifications
You must be signed in to change notification settings - Fork 479
/
session.rb
34 lines (26 loc) · 868 Bytes
/
session.rb
1
2
3
4
5
6
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
# frozen_string_literal: true
module Sentry
class Session
attr_reader :started, :status, :aggregation_key
STATUSES = %i[ok errored crashed exited]
AGGREGATE_STATUSES = %i[errored crashed exited]
def initialize
@started = Sentry.utc_now
@status = :ok
# truncate seconds from the timestamp since we only care about
# minute level granularity for aggregation
@aggregation_key = Time.utc(@started.year, @started.month, @started.day, @started.hour, @started.min)
end
def update_from_error_event(event)
return unless event.is_a?(ErrorEvent) && event.exception
crashed = event.exception.values.any? { |e| e.mechanism.handled == false }
@status = crashed ? :crashed : :errored
end
def close
@status = :exited if @status == :ok
end
def deep_dup
dup
end
end
end