Skip to content

Commit d872488

Browse files
authored
Memoize session.aggregation_key (#1892)
1 parent 67bbcd7 commit d872488

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
- Support rack 3 [#1884](https://github.com/getsentry/sentry-ruby/pull/1884)
66
- We no longer need the `HTTP_VERSION` check for ignoring the header
77

8+
### Bug Fixes
9+
10+
- Memoize session.aggregation_key [#1892](https://github.com/getsentry/sentry-ruby/pull/1892)
11+
- Fixes [#1891](https://github.com/getsentry/sentry-ruby/issues/1891)
12+
813
## 5.4.2
914

1015
### Bug Fixes

sentry-ruby/lib/sentry/session.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Sentry
44
class Session
5-
attr_reader :started, :status
5+
attr_reader :started, :status, :aggregation_key
66

77
# TODO-neel add :crashed after adding handled mechanism
88
STATUSES = %i(ok errored exited)
@@ -11,6 +11,10 @@ class Session
1111
def initialize
1212
@started = Sentry.utc_now
1313
@status = :ok
14+
15+
# truncate seconds from the timestamp since we only care about
16+
# minute level granularity for aggregation
17+
@aggregation_key = Time.utc(@started.year, @started.month, @started.day, @started.hour, @started.min)
1418
end
1519

1620
# TODO-neel add :crashed after adding handled mechanism
@@ -22,12 +26,6 @@ def close
2226
@status = :exited if @status == :ok
2327
end
2428

25-
# truncate seconds from the timestamp since we only care about
26-
# minute level granularity for aggregation
27-
def aggregation_key
28-
Time.utc(started.year, started.month, started.day, started.hour, started.min)
29-
end
30-
3129
def deep_dup
3230
dup
3331
end

0 commit comments

Comments
 (0)