bugsnag / bugsnag-laravel

BugSnag notifier for the Laravel PHP framework. Monitor and report Laravel errors.
https://docs.bugsnag.com/platforms/php/laravel/
MIT License
876 stars 129 forks source link

BUGSNAG_CAPTURE_SESSIONS is slowing down every request. Set by default. #438

Closed jonathan-bird closed 3 years ago

jonathan-bird commented 3 years ago

Describe the bug

By default when you install the dependency, BUGSNAG_CAPTURE_SESSIONS is set to true if you don't publish the vendor config file.

It's taken me weeks to be able to debug our application and why it was slower on the live site than test site. If you have this set to true, it was increasing every request by 150ms. We have all XL instances on AWS so knew it wasn't caused by infrastructure.

Playing around more, I switched this to false, immediately dropped request from 300-350ms down to 150ms. Turning it back to true immediately increased it back. I spun up another instance to check this on another config and found the same thing again.

We are checking the "Document Request Time" in chrome. In network tab, under "doc", you can see the actual document total request time.

I would expect that it should be heavily documented since this is the case, and disabled by default. The trade-off of a slow request is not worth having the session logs in Bugsnag... especially not on any medium to large application.

Steps to reproduce

  1. Install on any application.
  2. Don't publish the vendor config file
  3. Since bugsnag capture sessions is set, note the request time.
  4. Set BUGSNAG_CAPTURE_SESSIONS=false in the .env file and clear any config caches (and recache)
  5. Run the request again, note the request time. For us, on multiple instances, it was 150ms less when disabling this.

Environment

GrahamCampbell commented 3 years ago

By default, this is set to false: https://github.com/bugsnag/bugsnag-laravel/blob/master/config/bugsnag.php#L286.

jonathan-bird commented 3 years ago

Yeah I just found this too. When I published the config, it worked fine by default, but without it (which is what I had), was reverting to true.

Seems strange it adds so much to a request too. I'm in Aus so maybe they use a US server? But I wouldn't expect a request with such basic information to be more than 50ms. I would also expect it to be batched & queue'd as the recommended solution. What do you think? I saw the batch config, but couldn't tell if this was for reporting sessions or only for errors as it says - https://docs.bugsnag.com/platforms/php/laravel/configuration-options/#batch-sending

yousif-bugsnag commented 3 years ago

Hi @jonathan-bird,

You're correct, the BUGSNAG_BATCH_SENDING config option is only for errors and doesn't apply to session reporting.

BUGSNAG_CAPTURE_SESSIONS should always default to false if there is no config file - if you're seeing behaviour other than this please feel free to re-open the issue with a repro case.