Socket
Book a DemoInstallSign in
Socket

mongo_profiler

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo_profiler

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

Mongo Profiler

Build Status

Mongo profiling tool which matches queries with code

Database profiling tools are awesome and always useful. I love Mongo profiling. But unfortunately these tools don't match the queries with the source code they are profiling, making hard to find where the slow queries are executed.

The Mongo Profiler is a refinement patch in the moped driver to log all executed queries and their respective callers (Ruby backtrace).

It isn't replacement for the Mongo's built-in profiling, it is just a complementary tool to profile the queries with their respective source code.

An interesting feature in the Mongo Profiler is that we can group queries by "life cycles". For example, in a web application it can be the request.uuid or the request.url, so you will be able to see how many queries, how long did they take, the explain plans etc for each request or url.

Sample App

You can see how it works through the Sample Dashboard and Sample App (source code).

Installation

Add this line to your application's Gemfile:

gem 'mongo_profiler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mongo_profiler

To run the Dashboard you will need also to install sinatra.

gem 'sinatra', require: nil

Usage

Rails application

Gemfile

gem 'mongo_profiler', github: 'phstc/mongo_profiler', require: nil
gem 'sinatra', require: nil

application_controller.rb

# app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  before_filter :set_mongo_profile_group_name

  def set_mongo_profile_group_name
    unless Rails.env.production?
      require 'mongo_profiler'
      MongoProfiler.current_group_name = request.url
    end
  end
end

routes.rb

# config/routes.rb

MyApplication::Application.routes.draw do
  unless Rails.env.production?
    require 'mongo_profiler'
    require 'mongo_profiler/web'
    mount MongoProfiler::Web => '/mongo_profiler'
    # Security with Devise
    # authenticate :user do
    #  mount MongoProfiler::Web => '/mongo_profiler'
    # end
    #
    # authenticate :user, lambda { |u| u.admin? } do
    #  mount MongoProfiler::Web => '/mongo_profiler'
    # end
  end
end

Contributing

  • Fork it ( http://github.com/phstc/mongo_profiler/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 02 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.