Ruby Rack is what most Ruby Web frameworks like Rails are built on top of. Rails is one of the most popular frameworks.
Moesif is an API analytics and monitoring platform. moesif-rack is a middleware that makes integration with Moesif easy for Rack based applications and frameworks, including Rails.
This example is a Rails web application with Moesif Rack integrated. Its based on the quick start tutorials of Rails and this popular blog post regarding RESTful APIs on Rails
moesif-rack's documentation has detailed installation instructions and configuration options. Key changes to the base example to enable Moesif:
- Add
gem 'moesif_rack'
to the Gemfile - Modify the
config/application.rb
to use your Moesif Application Id.
Your Moesif Application Id can be found in the Moesif Portal. After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.
You can always find your Moesif Application Id at any time by logging into the Moesif Portal, click on the top right menu, and then clicking Installation.
-
Verify Ruby and Rails versions is 2.3 and above via
ruby -v
Verify Rails is 5.0 or higher viarails --version
-
Install all dependencies via
bundle install
-
Be sure to edit the
config/application.rb
to change the application id to your real one obtained from Moesif.
# config/application.rb
moesif_options = {
'application_id' => 'Your application Id'
}
- To run
bin/rails server
You may have to run bin/rails db:migrate RAILS_ENV=development
first to set up db.
- To see a list of routes that you can run tests against run
rake routes
. Send some requests to the API routes and verify that the API calls are captured in your Moesif account.