{"id":13395024,"url":"https://github.com/peek/peek","last_synced_at":"2025-05-12T20:52:50.875Z","repository":{"id":7343276,"uuid":"8666568","full_name":"peek/peek","owner":"peek","description":"Take a peek into your Rails applications.","archived":false,"fork":false,"pushed_at":"2024-04-26T00:50:43.000Z","size":232,"stargazers_count":3177,"open_issues_count":17,"forks_count":149,"subscribers_count":58,"default_branch":"master","last_synced_at":"2024-10-29T21:28:00.885Z","etag":null,"topics":["elasticsearch","peek","redis","ruby"],"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/peek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-03-09T07:22:46.000Z","updated_at":"2024-10-28T16:05:33.000Z","dependencies_parsed_at":"2024-05-01T13:19:51.094Z","dependency_job_id":"b3a4258c-04b2-4d1f-8a9e-c035b4bafce3","html_url":"https://github.com/peek/peek","commit_stats":{"total_commits":262,"total_committers":46,"mean_commits":5.695652173913044,"dds":"0.29007633587786263","last_synced_commit":"d6c13747a4889375c7af5290af4340ad68f13f2d"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peek%2Fpeek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peek%2Fpeek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peek%2Fpeek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peek%2Fpeek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peek","download_url":"https://codeload.github.com/peek/peek/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247934838,"owners_count":21020729,"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":["elasticsearch","peek","redis","ruby"],"created_at":"2024-07-30T17:01:39.548Z","updated_at":"2025-04-08T22:14:06.438Z","avatar_url":"https://github.com/peek.png","language":"Ruby","readme":"# Peek\n\n[![Build Status](https://travis-ci.org/peek/peek.svg?branch=master)](https://travis-ci.org/peek/peek) [![Gem Version](https://badge.fury.io/rb/peek.svg)](http://badge.fury.io/rb/peek) [![Inline docs](http://inch-ci.org/github/peek/peek.svg)](http://inch-ci.org/github/peek/peek)\n\nTake a peek into your Rails application.\n\n![Preview](https://f.cloud.github.com/assets/79995/244991/03cee1fa-8a74-11e2-8e33-283cf1298a60.png)\n\nThis is a profiling tool originally built at GitHub to help us get an insight into our application. Now, we have extracted this into Peek, so that other Rails applications can experience the same benefit.\n\nPeek puts a little bar on top of your application to show you all sorts of helpful information about your application. From the screenshot above, you can see that Peek provides information about database queries, cache, Resque workers and more. However, this is only part of Peek's beauty.\n\nThe true beauty of Peek lies in the fact that it is an extensible platform. If there are some performance metrics that you need but are not available on Peek, you can find them in the list of available [Peek Views](#available-peek-views) and integrate them into Peek. Even if you do not find what you want on Peek Views, you can always [create your own](#creating-your-own-peek-item).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'peek'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install peek\n\n## Usage\n\nNow that Peek is installed, you'll need to mount the engine within your `config/routes.rb`\nfile:\n\n```ruby\nSome::Application.routes.draw do\n  mount Peek::Railtie =\u003e '/peek'\n  root to: 'home#show'\nend\n```\n\nTo pick which views you want to see in your Peek bar, just create a file at\n`config/initializers/peek.rb` that has a list of the views you'd like to include:\n\n```ruby\nPeek.into Peek::Views::Git, nwo: 'github/janky'\nPeek.into Peek::Views::Mysql2\nPeek.into Peek::Views::Redis\nPeek.into Peek::Views::Dalli\n```\n\nFeel free to pick and install from the [list](https://github.com/peek/peek#available-peek-views) or create your own. The order they\nare added to Peek is the order they will appear in your bar.\n\nNext, to render the Peek bar in your application, add the following snippet\njust after the opening `\u003cbody\u003e` tag in your application layout.\n\n```erb\n\u003c%= render 'peek/bar' %\u003e\n```\n\nIt will look like:\n\n```erb\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eApplication\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003c%= render 'peek/bar' %\u003e\n    \u003c%= yield %\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nPeek fetches the data collected throughout your requests by using the unique request id\nthat was assigned to the request by Rails. It will call out to its own controller at\n[Peek::ResultsController](https://github.com/peek/peek/blob/master/app/controllers/peek/results_controller.rb) which will render the data and be inserted into the bar.\n\nNow that you have the partials in your application, you will need to include the\nCSS and JS that help make Peek :sparkles:\n\nIn `app/assets/stylesheets/application.scss`:\n\n```scss\n//= require peek\n```\n\nIn `app/assets/javascripts/application.coffee`:\n\n```coffeescript\n#= require jquery\n#= require jquery_ujs\n#= require peek\n```\n\nNote: Each additional view may have their own CSS and JS that you may need to require\nwhich should be stated in their usage documentation.\n\n### Configuring the default adapter\n\nFor Peek to work, it keeps track of all requests made in your application\nso it can report back and display that information in the Peek bar. By default\nit stores this information in memory, which is not recommended for production environments.\n\nIn production environments you may have application servers on multiple hosts.\nPeek will not be able to access the request data if it was saved in memory on\nanother host. Peek provides additional adapters for multi server environments.\n\nYou can configure which adapter Peek uses by updating your application\nconfig or an individual environment config file. We'll use production as an example.\n\nNote: Peek does not provide the dependencies for each of these adapters. If you use these\nadapters be sure to include their dependencies in your application.\n\n- Redis - The [redis](https://github.com/redis/redis-rb) gem\n- Dalli - The [dalli](https://github.com/mperham/dalli) gem\n- Elasticsearch - The [elasticsearch](https://github.com/elasticsearch/elasticsearch-ruby) gem\n\n```ruby\nPeeked::Application.configure do\n  # ...\n\n  # Redis with no options\n  config.peek.adapter = :redis\n\n  # Redis with options\n  config.peek.adapter = :redis, {\n    client: Redis.new,\n    expires_in: 60 * 30 # =\u003e 30 minutes in seconds\n  }\n\n  # Memcache with no options\n  config.peek.adapter = :memcache\n\n  # Memcache with options\n  config.peek.adapter = :memcache, {\n    client: Dalli::Client.new,\n    expires_in: 60 * 30 # =\u003e 30 minutes in seconds\n  }\n\n  # Elasticsearch with no options\n  config.peek.adapter = :elasticsearch\n\n  # Elasticsearch with options\n  config.peek.adapter = :elasticsearch, {\n    client: Elasticsearch::Client.new,\n    expires_in: 60 * 30, # =\u003e 30 minutes in seconds\n    index: 'peek_requests_index',\n    type: 'peek_request'\n  }\n\n  # ...\nend\n```\n\nPeek doesn't persist the request data forever. It uses a safe 30 minute cache\nlength so that data will be available if you'd like to aggregate it or\nuse it for other Peek views. You can update this to be 30 seconds if you don't\nwant the data to be available for these or other uses.\n\n### Customizing the bar\n\nYou can customize the appearance of the bar by customizing it in your own application's CSS.\n\nOne common example is fixing the peek bar to the bottom, rather than top, of a page, for use with [Bootstrap](http://getbootstrap.com/):\n\n```css\n#peek {\n  position: fixed;\n  bottom: 0;\n  left: 0;\n  right: 0;\n  z-index: 999;\n}\n```\n\n## Using Peek with PJAX\n\nIt just works.\n\n## Using Peek with Turbolinks\n\nIt just works.\n\n## Access Control\n\nPeek will only render in development and staging environments. If you'd\nlike to whitelist a select number of users to view Peek in production you\ncan override the `peek_enabled?` guard in `ApplicationController`:\n\n```ruby\nclass ApplicationController \u003c ActionController::Base\n  def peek_enabled?\n    current_user.staff?\n  end\nend\n```\n\n## Available Peek views\n\n- [peek-active_resource](https://github.com/gotmayonase/peek-active_resource)\n- [peek-alt-routes](https://github.com/mkcode/peek-alt-routes)\n- [peek-dalli](https://github.com/peek/peek-dalli)\n- [peek-delayed_job](https://github.com/18F/peek-delayed_job)\n- [peek-devise](https://github.com/gencer/peek-devise)\n- [peek-faraday](https://github.com/grk/peek-faraday)\n- [peek-flexirest](https://github.com/andyjeffries/peek-flexirest)\n- [peek-gc](https://github.com/peek/peek-gc)\n- [peek-git](https://github.com/peek/peek-git)\n- [peek-host](https://github.com/jacobbednarz/peek-host)\n- [peek-mongo](https://github.com/peek/peek-mongo)\n- [peek-moped](https://github.com/nodkz/peek-moped)\n- [peek-mysql2](https://github.com/peek/peek-mysql2)\n- [peek-performance_bar](https://github.com/peek/peek-performance_bar)\n- [peek-pg](https://github.com/peek/peek-pg)\n- [peek-rblineprof](https://github.com/peek/peek-rblineprof)\n- [peek-redis](https://github.com/peek/peek-redis)\n- [peek-resque](https://github.com/peek/peek-resque)\n- [peek-sidekiq](https://github.com/suranyami/peek-sidekiq)\n- [peek-svn](https://github.com/neilco/peek-svn)\n- Unicorn :soon:\n\nFeel free to submit a Pull Request adding your own Peek item to this list.\n\n## Creating your own Peek item\n\nEach Peek item is a self contained Rails engine which gives you the power to\nuse all features of Ruby on Rails to dig in deep within your application and\nreport it back to the Peek bar. A Peek item is just a custom class that\nis responsible for fetching and building the data that should be reported back\nto the user.\n\nThere are still some docs to be written, but if you'd like to check out a simple\nexample of how to create your own, just checkout [peek-git](https://github.com/peek/peek-git).\nTo just look at an example view, there is [Peek::Views::Git](https://github.com/peek/peek-git/blob/master/lib/peek/views/git.rb).\n\n## Contributing\n\n1. Fork it\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\n","funding_links":[],"categories":["Ruby","Maintenance \u0026 Monitoring","Profiler and Optimization","Gems","Profiler","Performance tools","Production"],"sub_categories":["App Instrumentation","Profiling and Performance"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeek%2Fpeek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeek%2Fpeek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeek%2Fpeek/lists"}