Skip to content

Excluded host requests still makes calls to Redis. #482

Closed

Description

@mosca1337

Excluded host requests still makes calls to Redis. It would be great if the ab_test method simply returned the control instead of querying for an alternative.

    def ab_test(metric_descriptor, control = nil, *alternatives)
      if !exclude_visitor?
        begin
          experiment = ExperimentCatalog.find_or_initialize(metric_descriptor, control, *alternatives)
          alternative = if Split.configuration.enabled
            experiment.save
            trial = Trial.new(:user => ab_user, :experiment => experiment,
                :override => override_alternative(experiment.name), :exclude => exclude_visitor?,
                :disabled => split_generically_disabled?)
            alt = trial.choose!(self)
            alt ? alt.name : nil
          else
            control_variable(experiment.control)
          end
        rescue Errno::ECONNREFUSED, Redis::BaseError, SocketError => e
          raise(e) unless Split.configuration.db_failover
          Split.configuration.db_failover_on_db_error.call(e)

          if Split.configuration.db_failover_allow_parameter_override
            alternative = override_alternative(experiment.name) if override_present?(experiment.name)
            alternative = control_variable(experiment.control) if split_generically_disabled?
          end
        ensure
          alternative ||= control_variable(experiment.control)
        end
      else
        alternative = control
      end

      if block_given?
        metadata = trial ? trial.metadata : {}
        yield(alternative, metadata)
      else
        alternative
      end
    end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions