File: session.rb

package info (click to toggle)
ruby-sentry-ruby-core 5.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 412 kB
  • sloc: ruby: 3,030; makefile: 8; sh: 4
file content (35 lines) | stat: -rw-r--r-- 801 bytes parent folder | download
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
35
# frozen_string_literal: true

module Sentry
  class Session
    attr_reader :started, :status

    # TODO-neel add :crashed after adding handled mechanism
    STATUSES = %i(ok errored exited)
    AGGREGATE_STATUSES = %i(errored exited)

    def initialize
      @started = Sentry.utc_now
      @status = :ok
    end

    # TODO-neel add :crashed after adding handled mechanism
    def update_from_exception(_exception = nil)
      @status = :errored
    end

    def close
      @status = :exited if @status == :ok
    end

    # truncate seconds from the timestamp since we only care about
    # minute level granularity for aggregation
    def aggregation_key
      Time.utc(started.year, started.month, started.day, started.hour, started.min)
    end

    def deep_dup
      dup
    end
  end
end