Class: Profiler::Api::OutboundHttpController

Inherits:
Profiler::ApplicationController show all
Defined in:
app/controllers/profiler/api/outbound_http_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /_profiler/api/outbound_http



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/profiler/api/outbound_http_controller.rb', line 9

def index
  limit = (params[:limit] || 200).to_i
  profiles = Profiler.storage.list(limit: limit)

  requests = profiles.flat_map do |profile|
    http_data = profile.collector_data("http")
    next [] unless http_data && http_data["requests"]&.any?

    http_data["requests"]
      .reject { |req| profiler_url?(req["url"].to_s) }
      .map { |req| req.merge("profile_token" => profile.token, "profile_started_at" => profile.started_at) }
  end

  requests.sort_by! { |r| r["profile_started_at"] }.reverse!

  render json: requests
end