peek-sidekiq-1.0.3/0000755000175000017500000000000013152703700013110 5ustar pravipravipeek-sidekiq-1.0.3/CHANGELOG.md0000644000175000017500000000044213152703700014721 0ustar pravipravi# 1.0.3 - Fixed incorrect placement of the instrumented methods in the class. # 1.0.2 - Now rendering duration & calls generated by the page, not global, as per issue #1. Thanks to @mperham for advice on how to do that! # 1.0.1 - Renamed glimpse to peek. # 1.0.0 - Initial release. peek-sidekiq-1.0.3/README.md0000644000175000017500000000200213152703700014361 0ustar pravipravi# Peek::Sidekiq Provide a peek into the Sidekiq calls made within your Rails application. Things this peek view provides: - Duration spent in Sidekiq calls - Number of calls this page created ## Installation Add this line to your application's Gemfile: gem 'peek-sidekiq' And then execute: $ bundle Or install it yourself as: $ gem install peek-sidekiq ## Usage Add the following to your `config/initializers/peek.rb`: ```ruby Peek.into Peek::Views::Sidekiq ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request ## Building and deploying gem - Update the version number in `lib/peek/sidekiq/version.rb` - Update `CHANGELOG.md` Build the gem: gem build peek-sidekiq.gemspec Push to rubygems.org: gem push peek-sidekiq-1.0.3.gem ## Testing the gem locally gem install peek-sidekiq-1.0.3.gem peek-sidekiq-1.0.3/lib/0000755000175000017500000000000013152703700013656 5ustar pravipravipeek-sidekiq-1.0.3/lib/peek/0000755000175000017500000000000013152703700014602 5ustar pravipravipeek-sidekiq-1.0.3/lib/peek/views/0000755000175000017500000000000013152703700015737 5ustar pravipravipeek-sidekiq-1.0.3/lib/peek/views/sidekiq.rb0000644000175000017500000000265213152703700017722 0ustar pravipravirequire 'sidekiq' require 'atomic' class Sidekiq::Client class << self attr_accessor :query_time, :query_count def push_with_timing(*args) start = Time.now push_without_timing(*args) ensure duration = (Time.now - start) @query_time.update { |value| value + duration } @query_count.update { |value| value + 1 } end alias_method_chain :push, :timing def push_bulk_with_timing(*args) start = Time.now push_bulk_without_timing(*args) ensure duration = (Time.now - start) @query_time.update { |value| value + duration } @query_count.update { |value| value + 1 } end end self.query_count = Atomic.new(0) self.query_time = Atomic.new(0) end module Peek module Views class Sidekiq < View def duration ::Sidekiq::Client.query_time.value end def formatted_duration ms = duration * 1000 if ms >= 1000 "%.2fms" % ms else "%.0fms" % ms end end def calls ::Sidekiq::Client.query_count.value end def results {:duration => formatted_duration, :calls => calls} end private def setup_subscribers # Reset each counter when a new request starts before_request do ::Sidekiq::Client.query_time.value = 0 ::Sidekiq::Client.query_count.value = 0 end end end end end peek-sidekiq-1.0.3/lib/peek-sidekiq.rb0000644000175000017500000000013313152703700016553 0ustar pravipravirequire 'peek/views/sidekiq' require 'peek-sidekiq/version' require 'peek-sidekiq/railtie' peek-sidekiq-1.0.3/lib/peek-sidekiq/0000755000175000017500000000000013152703700016231 5ustar pravipravipeek-sidekiq-1.0.3/lib/peek-sidekiq/railtie.rb0000644000175000017500000000012313152703700020203 0ustar pravipravimodule Peek module Sidekiq class Railtie < ::Rails::Engine end end end peek-sidekiq-1.0.3/lib/peek-sidekiq/version.rb0000644000175000017500000000007513152703700020245 0ustar pravipravimodule Peek module Sidekiq VERSION = '1.0.3' end end peek-sidekiq-1.0.3/LICENSE.txt0000644000175000017500000000205413152703700014734 0ustar pravipraviCopyright (c) 2013 David Parry MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. peek-sidekiq-1.0.3/.gitignore0000644000175000017500000000023213152703700015075 0ustar pravipravi*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp peek-sidekiq-1.0.3/Rakefile0000644000175000017500000000003413152703700014552 0ustar pravipravirequire "bundler/gem_tasks" peek-sidekiq-1.0.3/app/0000755000175000017500000000000013152703700013670 5ustar pravipravipeek-sidekiq-1.0.3/app/views/0000755000175000017500000000000013152703700015025 5ustar pravipravipeek-sidekiq-1.0.3/app/views/peek/0000755000175000017500000000000013152703700015751 5ustar pravipravipeek-sidekiq-1.0.3/app/views/peek/views/0000755000175000017500000000000013152703700017106 5ustar pravipravipeek-sidekiq-1.0.3/app/views/peek/views/_sidekiq.html.erb0000644000175000017500000000022613152703700022333 0ustar pravipravi sidekiq peek-sidekiq-1.0.3/Gemfile0000644000175000017500000000014113152703700014377 0ustar pravipravisource 'https://rubygems.org' # Specify your gem's dependencies in peek-sidekiq.gemspec gemspec peek-sidekiq-1.0.3/peek-sidekiq.gemspec0000644000175000017500000000167113152703700017035 0ustar pravipravi# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'peek-sidekiq/version' Gem::Specification.new do |gem| gem.name = 'peek-sidekiq' gem.version = Peek::Sidekiq::VERSION gem.authors = ['David Parry'] gem.email = ['david.parry@suranyami.com'] gem.description = %q{Provide a peek into the Sidekiq calls made within your Rails application.} gem.summary = %q{Provide a peek into the Sidekiq calls made within your Rails application.} gem.homepage = 'https://github.com/suranyami/peek-sidekiq' gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ['lib'] gem.add_dependency 'peek' gem.add_dependency 'sidekiq' gem.add_dependency 'atomic', '>= 1.0.0' end