Skip to content

Instantly share code, notes, and snippets.

@uday-rayala
Created March 9, 2017 15:27
Show Gist options
  • Save uday-rayala/c3a8234ed4ed93e2d006ae26d367515a to your computer and use it in GitHub Desktop.
Save uday-rayala/c3a8234ed4ed93e2d006ae26d367515a to your computer and use it in GitHub Desktop.
MyServiceExperiment
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