Created
February 22, 2024 16:22
-
-
Save adamlogic/13187c1efe2467cce12212ca70b58a2a to your computer and use it in GitHub Desktop.
Scout APM sampling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apply a sample rate to Scout so it only instruments a portion of requests | |
# or jobs. Here's an example of how to use it in a controller action or job: | |
# ScoutApm::Transaction.use_sample_rate 0.001 | |
module ScoutApm | |
module Transaction | |
# Set SCOUT_SAMPLING=false to disable sampling. This will send all transactions to Scout, | |
# and very quickly use up our monthly transaction limit. | |
USE_SAMPLING = ENV["SCOUT_SAMPLING"] != "false" | |
def self.use_sample_rate(rate) | |
if USE_SAMPLING && rand > rate | |
ScoutApm::Transaction.ignore! | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment