palkan / isolator
git clone https://github.com/palkan/isolator.git
v1.1.0 · 2y ago
🔥 on GitHub Trending today
Detect non-atomic interactions within DB transactions
+1
stars, 24h · #555
—
stars, 7 days
—
stars, 30 days
1.1k
★ total
36
forks · 6 open issues
Star history starts 2026-10-20; the chart appears after the second daily snapshot.
LanguageRuby
LicenseMIT
Created2018-01-28 (8y ago)
Last push6d ago
Watchers7
OwnerUser
Seen on GitHub Trending
- 2026-10-20 — #18 daily in ruby · +1 ★
GitHub topics
Links
- GitHub: github.com/palkan/isolator
- Releases · Issues · Hacker News mentions
README excerpt
# Isolator Detect non-atomic interactions within DB transactions. Examples: [code] Of course, Isolator can detect _implicit_ transactions too. Consider this pretty common bad practice–enqueueing background job from `after_create` callback: [code] Isolator is supposed to be used in tests and on staging. Isolator is built by Evil Martians , an American design and engineering consultancy for developer tools, AI, and cybersecurity startups . ## Installation Add this line to your application's Gemfile: [code] if you are instrumenting net http (e.g. using an APM on staging or even development) then you may need to force sniffer into prepend mode: see https://github.com/palkan/isolator/issues/44#issuecomment-5475678308 ## Usage Isolator is a plug-n-play tool, so, it begins to work right after required. However, there are some potential caveats: 1) Isolator tries to detect the environment automatically and includes only necessary adapters. Thus the order of loading gems matters: make sure that `isolator` is required in the end (NOTE: in Rails, all adapters loaded after application initialization). 2) Isolator does not distinguish framework-level adapters. For example, `:active_job` spy doesn't take into account which AJ adapter you use; if you are using a safe one (e.g. `Que`) just disable the `:active_job` adapter to avoid false negatives. You can do this by adding an initializer: [code] 4) Isolator tries to detect the `test` environment and slightly change its behavior: first, it respect _transactional tests_; secondly, error raising is turned on by default (see below). 5) Experimental multiple databases has been added in v0.7.0. Please, let us know if you encounter any issues. ### Configuration [code] Isolator relies on [uniform_notifier][] to send custom notifications. **NOTE:** `uniform_notifier` should be installed separately (i.e., added to Gemfile). ### Callbacks Isolator different callbacks so you can inject your own logic or build custom extensions. [code] ### Transactional tests support - Rails' baked-in use_transactional_tests - database_cleaner gem. Make sure that you require isolator _after_ database_cleaner. ### Supported ORMs - `ActiveRecord` >= 6.0 (see older versions of Isolator for previous versions) - `ROM::SQL` (only if Active Support instrumentation extension is loaded). Make sure that you load the extension (`ROM::SQL.load_extensions(:active_support_notifications)`) _before_ requiring isolator. ### Adapters Isolator has a bunch of built-in adapters: - `:http` – built on top of [Sniffer][] - `:active_job` - `:sidekiq` - `:resque` - `:resque_scheduler` - `:sucker_punch` - `:mailer` - `:webmock` – track mocked HTTP requests (unseen by Sniffer) in tests - `:action_cable` You can dynamically enable/disable adapters, e.g.: [code] For `active_job`, be sure to first `require "active_job/base"`. ### Fix Offenses For the actions that should be executed only after successful transaction commit (which is mostly always so), you