Sha256: fb259cae99db30497657aad2a05b346409849aafbf5a92c9808066270f6a9b87

Contents?: true

Size: 936 Bytes

Versions: 7

Compression:

Stored size: 936 Bytes

Contents

require "#{Rails.root}/app/jobs/test_job"

class BasicController < ApplicationController
  # Reads & writes from cache, reads from DB, and queues a Resque job.
  #
  # Example trace:
  #
  # ----------------------- Rack -----------------------------
  #    -------------- ActionController --------------------
  #      --- ActiveSupport -- ActiveRecord -- Resque ---
  #        ----- Redis ----                 -- Redis --
  #
  def default
    # Read from the database
    records = Test.where(version: 0)

    # Queue job
    Resque.enqueue(Jobs::Test, job_id: request.request_id, records: records.map(&:to_json))

    # Return response
    render json: { job_id: request.request_id }
  end

  # Runs a recursive implementation of fibonacci.
  # Provides a basic load on CPU, stack frames, response time.
  def fibonacci
    fib(rand(25..35))
    head :ok
  end

  private

  def fib(n)
    n <= 1 ? n : fib(n-1) + fib(n-2)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-0.51.1 integration/apps/rails-five/app/controllers/basic_controller.rb
ddtrace-0.51.0 integration/apps/rails-five/app/controllers/basic_controller.rb
ddtrace-0.50.0 integration/apps/rails-five/app/controllers/basic_controller.rb
ddtrace-0.49.0 integration/apps/rails-five/app/controllers/basic_controller.rb
ddtrace-0.48.0 integration/apps/rails-five/app/controllers/basic_controller.rb
ddtrace-0.47.0 integration/apps/rails-five/app/controllers/basic_controller.rb
ddtrace-0.46.0 integration/apps/rails-five/app/controllers/basic_controller.rb