Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get controller labels from controller, not params #293

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/prometheus_exporter/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def call(env)
end

def default_labels(env, result)
params = env["action_dispatch.request.parameters"]
controller_instance = env["action_controller.instance"]
action = controller = nil
if params
action = params["action"]
controller = params["controller"]
if controller_instance
action = controller_instance.action_name
controller = controller_instance.controller_name
elsif (cors = env["rack.cors"]) && cors.respond_to?(:preflight?) && cors.preflight?
# if the Rack CORS Middleware identifies the request as a preflight request,
# the stack doesn't get to the point where controllers/actions are defined
Expand Down