Skip to content

Commit

Permalink
Require 'concurrent' only when needed
Browse files Browse the repository at this point in the history
This helps reduce the memory overhead of Bugsnag when session tracking
isn't enabled by ~4 MiB
  • Loading branch information
imjoehaines committed Jul 22, 2020
1 parent f81c855 commit 89a9b62
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/bugsnag/session_tracker.rb
@@ -1,11 +1,9 @@
require 'thread'
require 'time'
require 'securerandom'
require 'concurrent'

module Bugsnag
class SessionTracker

THREAD_SESSION = "bugsnag_session"
SESSION_PAYLOAD_VERSION = "1.0"
MUTEX = Mutex.new
Expand All @@ -27,6 +25,8 @@ def self.get_current_session
##
# Initializes the session tracker.
def initialize
require 'concurrent'

@session_counts = Concurrent::Hash.new(0)
end

Expand Down Expand Up @@ -139,4 +139,4 @@ def deliver(session_payload)
Bugsnag::Delivery[Bugsnag.configuration.delivery_method].deliver(Bugsnag.configuration.session_endpoint, payload, Bugsnag.configuration, options)
end
end
end
end

0 comments on commit 89a9b62

Please sign in to comment.