Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- Fix `send_default_pii` handling in rails controller spans [#2443](https://github.com/getsentry/sentry-ruby/pull/2443)
- Fixes [#2438](https://github.com/getsentry/sentry-ruby/issues/2438)
- Fix `RescuedExceptionInterceptor` to handle an empty configuration [#2428](https://github.com/getsentry/sentry-ruby/pull/2428)
- Add mutex sync to `SessionFlusher` aggregates [#2469](https://github.com/getsentry/sentry-ruby/pull/2469)
- Fixes [#2468](https://github.com/getsentry/sentry-ruby/issues/2468)

## 5.21.0

Expand Down
12 changes: 8 additions & 4 deletions sentry-ruby/lib/sentry/session_flusher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@pending_aggregates = {}
@release = configuration.release
@environment = configuration.environment
@mutex = Mutex.new

log_debug("[Sessions] Sessions won't be captured without a valid release") unless @release
end
Expand All @@ -18,7 +19,6 @@
return if @pending_aggregates.empty?

@client.capture_envelope(pending_envelope)
@pending_aggregates = {}
end

alias_method :run, :flush
Expand All @@ -42,11 +42,15 @@
end

def pending_envelope
envelope = Envelope.new
aggregates = @mutex.synchronize do
aggregates = @pending_aggregates.values
@pending_aggregates = {}
aggregates

Check warning on line 48 in sentry-ruby/lib/sentry/session_flusher.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/session_flusher.rb#L45-L48

Added lines #L45 - L48 were not covered by tests
end

envelope = Envelope.new

Check warning on line 51 in sentry-ruby/lib/sentry/session_flusher.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/session_flusher.rb#L51

Added line #L51 was not covered by tests
header = { type: "sessions" }
payload = { attrs: attrs, aggregates: @pending_aggregates.values }

payload = { attrs: attrs, aggregates: aggregates }

Check warning on line 53 in sentry-ruby/lib/sentry/session_flusher.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/session_flusher.rb#L53

Added line #L53 was not covered by tests
envelope.add_item(header, payload)
envelope
end
Expand Down
Loading