{"id":16073828,"url":"https://github.com/phstc/mongo_profiler","last_synced_at":"2025-09-11T15:31:34.314Z","repository":{"id":13649092,"uuid":"16342567","full_name":"phstc/mongo_profiler","owner":"phstc","description":"Mongo profiling tool which matches queries with code","archived":false,"fork":false,"pushed_at":"2014-10-20T13:45:06.000Z","size":1624,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-28T19:29:39.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phstc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-29T11:14:54.000Z","updated_at":"2015-05-01T18:34:28.000Z","dependencies_parsed_at":"2022-09-13T12:41:13.753Z","dependency_job_id":null,"html_url":"https://github.com/phstc/mongo_profiler","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fmongo_profiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fmongo_profiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fmongo_profiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fmongo_profiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phstc","download_url":"https://codeload.github.com/phstc/mongo_profiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232655308,"owners_count":18556491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T08:23:07.504Z","updated_at":"2025-01-06T00:20:02.274Z","avatar_url":"https://github.com/phstc.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mongo Profiler\n\n[![Build Status](https://travis-ci.org/phstc/mongo_profiler.svg)](https://travis-ci.org/phstc/mongo_profiler)\n\n**Mongo profiling tool which matches queries with code**\n\nDatabase profiling tools are awesome and always useful. I love [Mongo profiling](http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/). 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.\n\nThe Mongo Profiler is a \u003cdel\u003erefinement\u003c/del\u003e patch in the [moped driver](https://github.com/mongoid/moped) to log all executed queries and their respective callers ([Ruby backtrace](http://www.ruby-doc.org/core-2.1.1/Kernel.html#method-i-caller)).\n\nIt 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.\n\nAn 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.\n\n## Sample App\n\nYou can see how it works through the [Sample Dashboard](https://mongo-profiler-sample-app.herokuapp.com/mongo_profiler) and [Sample App](https://mongo-profiler-sample-app.herokuapp.com) ([source code](https://github.com/phstc/mongo_profiler_sample_app)).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mongo_profiler'\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install mongo_profiler\n```\n\nTo run the Dashboard you will need also to install [sinatra](https://github.com/sinatra/sinatra).\n\n```ruby\ngem 'sinatra', require: nil\n```\n\n## Usage\n\n### Rails application\n\n### Gemfile\n\n```\ngem 'mongo_profiler', github: 'phstc/mongo_profiler', require: nil\ngem 'sinatra', require: nil\n```\n\n#### application_controller.rb\n\n```ruby\n# app/controllers/application_controller.rb\n\nclass ApplicationController \u003c ActionController::Base\n\n  before_filter unless: -\u003e { Rails.env.production? } do |controller|\n    require 'mongo_profiler'\n    Thread.current['mongo_profiler_group_name'] = request.url\n  end\nend\n```\n\n#### routes.rb\n\n```ruby\n# config/routes.rb\n\nMyApplication::Application.routes.draw do\n  unless Rails.env.production?\n    require 'mongo_profiler'\n    require 'mongo_profiler/web'\n    mount MongoProfiler::Web =\u003e '/mongo_profiler'\n    # Security with Devise\n    # authenticate :user do\n    #  mount MongoProfiler::Web =\u003e '/mongo_profiler'\n    # end\n    #\n    # authenticate :user, lambda { |u| u.admin? } do\n    #  mount MongoProfiler::Web =\u003e '/mongo_profiler'\n    # end\n  end\nend\n```\n\n## Contributing\n\n1. Fork it ( http://github.com/phstc/mongo_profiler/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Fmongo_profiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphstc%2Fmongo_profiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Fmongo_profiler/lists"}