Skip to content

Commit

Permalink
Create the session tracker after configure has run
Browse files Browse the repository at this point in the history
Create the session tracker if sessions are enabled to avoid the overhead
of creating it on the first request

By requiring the concurrent gem in the session tracker's initialize
method, we shifted the overhead from startup to the first request.
This caused the first request to go from ~10ms to ~70ms (in the Sinatra
example app run locally), which is quite alot of overhead
  • Loading branch information
imjoehaines committed Jul 22, 2020
1 parent 89a9b62 commit a7c2c2b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/bugsnag.rb
Expand Up @@ -48,6 +48,12 @@ class << self
def configure(validate_api_key=true)
yield(configuration) if block_given?

# Create the session tracker if sessions are enabled to avoid the overhead
# of creating it on the first request. We skip this if we're not validating
# the API key as we use this internally before the user's configure block
# has run, so we don't know if sessions are enabled yet.
session_tracker if validate_api_key && configuration.auto_capture_sessions

check_key_valid if validate_api_key
check_endpoint_setup

Expand Down

0 comments on commit a7c2c2b

Please sign in to comment.