lib/promoted/ruby/client.rb
# Delivers shadow traffic from the given metrics args.
# Assumes that the args have already been normalized since this
# method should only be called from inside prepare_for_logging.
Delivers shadow traffic from the given metrics args.
Assumes that the args have already been normalized since this
method should only be called from inside prepare_for_logging.
Delivers shadow traffic from the given metrics args . Assumes that the args have already been normalized since this method should only be called from inside prepare_for_logging .
def deliver_shadow_traffic args, headers
          delivery_request_builder = RequestBuilder.new
          delivery_request_builder.set_request_params args
          delivery_request_params = delivery_request_builder.delivery_request_params
          delivery_request_params[:client_info][:traffic_type] = Promoted::Ruby::Client::TRAFFIC_TYPE['SHADOW']
          begin
            @pager.validate_paging(delivery_request_builder.full_insertion, delivery_request_builder.request[:paging])
          rescue InvalidPagingError => err
            @logger.warn("Shadow traffic call failed with invalid paging #{err}") if @logger
            return
          end
          start_time = Time.now
          response = nil
          begin
            response = send_request(delivery_request_params, @delivery_endpoint, @delivery_timeout_millis, @delivery_api_key, headers, @async_shadow_traffic)
          rescue StandardError => err
            @logger.warn("Shadow traffic call failed with #{err}") if @logger
            return
          end
          if !@async_shadow_traffic
            ellapsed_time = Time.now - start_time
            insertions = response && response[:insertion] || []
            @logger.info("Shadow traffic call completed in #{ellapsed_time.to_f * 1000} ms with #{insertions.length} insertions") if @logger
          end
        end
def deliver_shadow_traffic args , headers delivery_request_builder = RequestBuilder . new delivery_request_builder . set_request_params args delivery_request_params = delivery_request_builder . delivery_request_params delivery_request_params [ :client_info ] [ :traffic_type ] = Promoted :: Ruby :: Client :: TRAFFIC_TYPE [ 'SHADOW' ] begin @pager . validate_paging ( delivery_request_builder . full_insertion , delivery_request_builder . request [ :paging ] ) rescue InvalidPagingError => err @logger . warn ( "Shadow traffic call failed with invalid paging #{err}" ) if @logger return end start_time = Time . now response = nil begin response = send_request ( delivery_request_params , @delivery_endpoint , @delivery_timeout_millis , @delivery_api_key , headers , @async_shadow_traffic ) rescue StandardError => err @logger . warn ( "Shadow traffic call failed with #{err}" ) if @logger return end if ! @async_shadow_traffic ellapsed_time = Time . now - start_time insertions = response && response [ :insertion ] || [ ] @logger . info ( "Shadow traffic call completed in #{ellapsed_time.to_f * 1000} ms with #{insertions.length} insertions" ) if @logger end end
Delivers shadow traffic from the given metrics args.
Delivers shadow traffic from the given metrics args .
# Invalid input, log and skip. # Call Delivery API and log/ignore errors.
args
headers