airbrake / airbrake-ruby

A plain Ruby Airbrake notifier
https://airbrake.io
MIT License
79 stars 67 forks source link

Is Airbrake.merge_context thread safe? #658

Closed sjain closed 3 years ago

sjain commented 3 years ago

We are using Airbrake with shoryuken gem. We have noticed atleast one instance where the airbrake reported context is different from the one where error occured. Upon closer look, I find that we are relying on Airbrake.merge_context to setup the context before we process each shoryuken request. We are calling Airbrake.notify when error/exception occurs, which as I understand, is an async call by default.

Perusing the gem code seems to suggest that Airbrake.notify does the right thing of storing the context inside Notifier for async notification to pickup. However, I don't see any Thread.current in the call chain from Airbrake to NoticeNotifier etc. I wonder if this Airbrake code is threadsafe?

This documentation does not make it explicit: https://github.com/airbrake/airbrake-ruby#airbrakemerge_context

scottsbaldwin commented 3 years ago

@kyrylo can you take a look at this?