Created
March 9, 2017 15:27
-
-
Save uday-rayala/c3a8234ed4ed93e2d006ae26d367515a to your computer and use it in GitHub Desktop.
MyServiceExperiment
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
class MyServiceExperiment | |
include Scientist::Experiment | |
def enabled? | |
true | |
end | |
def publish(result) | |
statsd_client = Rails.application.config.statsd_client | |
if result.matched? | |
statsd_client.increment "science.#{name}.matched" | |
elsif result.ignored? | |
statsd_client.increment "science.#{name}.ignored" | |
else | |
statsd_client.increment "science.#{name}.mismatched" | |
control = result.control | |
candidate = result.candidates.first | |
info_to_log = { | |
name: name, | |
control_duration: control.duration, | |
candidate_duration: candidate.duration, | |
context: context, | |
control: control, | |
candidate: candidate | |
} | |
RequestStore.store[:experiments] = [info_to_log] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment