przbadu
przbadu

Reputation: 6049

heroku: ActionController::RoutingError (No route matches [GET] "/newrelic")

ERROR

ActionController::RoutingError (No route matches [GET] "/newrelic")

# and I am getting error page for both staging and production heroku servers

Documentation

https://devcenter.heroku.com/articles/newrelic

GEM

https://github.com/newrelic/rpm

# ruby 2.1.0p0
# rails 4.0.1

Both environment variables NEW_RELIC_LICENSE_KEY and NEW_RELIC_APP_NAME are set to heroku config variable

Gemfile

gem "newrelic_rpm", "~> 3.5.7.59"

config/newrelic.yml

common: &default_settings
  license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
  monitor_mode: true
  developer_mode: false
  log_level: info

  browser_monitoring:
    auto_instrument: true

  audit_log:
    enabled: false
    capture_params: false

  transaction_tracer:
    enabled: true
    transaction_threshold: apdex_f
    record_sql: obfuscated
    stack_trace_threshold: 0.500

  error_collector:
    enabled: true
    capture_source: true
    ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"

development:
  <<: *default_settings
  monitor_mode: true
  developer_mode: true

test:
  <<: *default_settings
  monitor_mode: false

production:
  <<: *default_settings
  monitor_mode: true

staging:
  <<: *default_settings
  monitor_mode: true
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging)

[NOTE: I have two application hosted to heroku:]

And I want to configure new-relic for both environments/servers.

Also, Note that this configuration is working fine in development(localhost) environmet.

EDITED

config/routes.rb

Demo::Application.routes.draw do
  root :to => "home#index"

  devise_for :users,:controllers => {:sessions => "sessions",:omniauth_callbacks => "omniauth_callbacks" }
  post '/tinymce_assets' => 'tinymce_assets#create'
  resources :home

  namespace :admin do
    resources :dashboards

    resources :users do
      member do
        get :reset
        put :reset_pw
        put :delete_record
        put :restore_user
      end
    end
  end

  resources :drives do
    member do
      put :destroy_drive
      post :add_consolidation
      put :delete_consolidation
      post :add_driveorganizer
      put :delete_drive_organizer
      put :restore_drirve
    end
    collection do
       get :recalculate_consolidation
    end
    resources :drive_details do
      resources :images
    end
  end

  resources :products do
    member do
      post :add_category
      put :destroy_pc
      put :delete_product
      put :restore_products
    end
  end

  resources :stores do
    member do
      put :delete_store
    end
  end

  resources :store_products do
    member do
      put :delete_storeproduct
      post :add_package_items
      put :delete_package_item
      put :restore_store_product
      get :get_product_price
    end
    collection do
      get :autocomplete_others
    end
  end

  resources :orders do
    member do
      put :delete_order
      put :restore_order
      get :charge_stripe
    end

    resources :order_items do
      collection do
        post :display_price
      end
      member do
        put :delete_record
      end
    end
  end

  resources :categories do
    member do
      put :delete_category
      put :restore_category
    end

    collection do
      get :move
    end
  end

  namespace :user do
    resources :campaigns do
      member do
        get :single_campaign
      end
      resources :stores 
      resources :carts do 
        collection do
          post :carts_update
          get :checkout_final
          get :payment
          post :payment
          get :update_payment
          get :update_payment_and_redirect
          get :confirmation
          post :confirmation
          get :finish
          post :confirmation_update
          put :empty_cart
          post :shelter_survey
        end
        member do
          put :destroy_oi
          put :checkout
        end
      end
    end
  end

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  # root 'welcome#index'

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end

Thanks

Upvotes: 0

Views: 2437

Answers (1)

Alexis
Alexis

Reputation: 451

Based on the error you're getting, it looks like you're trying to access the route to the New Relic Ruby agent's developer mode in your staging and production environments. Developer mode installs a middleware in your app that responds to any URL prepended with /newrelic. Because you've enabled Developer mode in your development (localhost) environment (the developer_mode key is set to true in your newrelic.yml under development), accessing this route succeeds there, but it fails in staging and production because you don't have developer mode enabled in those environments.

Your current configuration is usually desirable, since Developer mode introduces a large amount of overhead that is generally unacceptable in production. Rather than attempt to access the route in staging or production, use it during development only.

You may also want to consider upgrading the version of the agent you are using, since version 3.5.7 does not fully support Ruby 2.0 or Rails 4. More information on releases can be found at https://docs.newrelic.com/docs/releases/ruby.

Upvotes: 3

Related Questions