memory_tracker 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee21ddd01489caff91646a6b69ae34fc06287051
4
- data.tar.gz: db8b533390f526e2ff491e32786d8a2c61c1b34e
3
+ metadata.gz: ed7411c3ae8a1b418508a857bad90241f23b6d75
4
+ data.tar.gz: 3179b61d06cc3ced27d8028e9a6682ad209270a9
5
5
  SHA512:
6
- metadata.gz: cc733329597a3ebedc4813ae8e74f986c1fec2b4da4970144030b3965bc21a2050e5c79cafd327cc642ff65c9e7ba73a8c25dc3714ba65bc70f5aa4534b6f326
7
- data.tar.gz: 6b483e4c0f7205044fcadb37e3f9f0033324d0b2f7be1dc0edde324bf182401e606431f072b0750ad4549d085952fac99475320e244dcdf194970a37730fd0fc
6
+ metadata.gz: 66da2d7a7c95b15b208f216220db2fca964e11c5657a4120136523c7c51b5daa9034f0d372c1e86651955fad44dde80374976abdf80aa19e9f1ac639fe09f18c
7
+ data.tar.gz: 168ba701e08ca80c37fda873e32eef965a76e70b698d45a1d2192beabf0daa6f5c79ef3c41d1ba2d06687d639d08c610a60f4a5508924bb75fc3c6c2033f10bd
data/Gemfile CHANGED
@@ -1,13 +1,17 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'sys-proctable'
4
-
5
- # Add dependencies to develop your gem here.
6
- # Include everything needed to run rake, tests, features, etc.
7
- group :development, :test do
8
- gem "debugger"
9
- gem "rspec", "~> 2.14.0"
10
- gem "rdoc", "~> 3.12"
11
- gem "bundler", "~> 1.0"
12
- gem "jeweler", "~> 1.8.7"
13
- end
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in memory_tracker.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # jquery-rails is used by the dummy application
9
+ gem "jquery-rails"
10
+
11
+ # Declare any dependencies that are still in development here instead of in
12
+ # your gemspec. These might include edge Rails or gems from your path or
13
+ # Git. Remember to move these dependencies to your gemspec before releasing
14
+ # your gem to rubygems.org.
15
+
16
+ # To use debugger
17
+ # gem 'debugger'
data/Rakefile CHANGED
@@ -1,30 +1,29 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
1
+ #!/usr/bin/env rake
5
2
  begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
11
6
  end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "memory_tracker"
18
- gem.homepage = "http://github.com/plerohellec/memory_tracker"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Rails memory allocations tracker}
21
- gem.description = %Q{Collect and analyze memory usage data for each individual Rails action controller.}
22
- gem.email = "philippe@lerohellec.com"
23
- gem.authors = ["Philippe Le Rohellec"]
24
- # dependencies defined in Gemfile
25
- gem.add_dependency 'sys-proctable'
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
26
13
  end
27
- Jeweler::RubygemsDotOrgTasks.new
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'MemoryTracker'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+ load 'rails/tasks/engine.rake'
25
+
26
+ Bundler::GemHelper.install_tasks
28
27
 
29
28
  require 'rspec/core'
30
29
  require 'rspec/core/rake_task'
@@ -39,12 +38,3 @@ end
39
38
 
40
39
  task :default => :spec
41
40
 
42
- require 'rdoc/task'
43
- Rake::RDocTask.new do |rdoc|
44
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
-
46
- rdoc.rdoc_dir = 'rdoc'
47
- rdoc.title = "memory_tracker #{version}"
48
- rdoc.rdoc_files.include('README*')
49
- rdoc.rdoc_files.include('lib/**/*.rb')
50
- end
@@ -0,0 +1,4 @@
1
+ module MemoryTracker
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -1,5 +1,7 @@
1
+ require_dependency "memory_tracker/application_controller"
2
+
1
3
  module MemoryTracker
2
- class DashboardsController < ActionController::Base
4
+ class DashboardsController < ApplicationController
3
5
 
4
6
  layout 'memory_tracker'
5
7
 
data/config/routes.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  MemoryTracker::Engine.routes.draw do
2
- get '/' => 'memory_tracker/dashboards#index', :as => :dashboards
2
+ get '/' => 'dashboards#index', :as => :dashboards
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module MemoryTracker
2
- class Engine < Rails::Engine
2
+ class Engine < ::Rails::Engine
3
3
 
4
- # isolate_namespace MemoryTracker
4
+ isolate_namespace MemoryTracker
5
5
 
6
6
  engine_base_dir = File.expand_path("../../..", __FILE__)
7
7
  app_base_dir = File.expand_path("../../../app", __FILE__)
@@ -7,7 +7,7 @@ module MemoryTracker
7
7
  end
8
8
 
9
9
  def memory_tracker
10
- ::MemoryTracker::MemoryTracker.instance
10
+ MemoryTracker.instance
11
11
  end
12
12
 
13
13
  def call(env)
@@ -1,3 +1,5 @@
1
- require 'memory_tracker/memory_tracker'
2
1
  require 'memory_tracker/engine' if defined?(Rails)
2
+ require 'memory_tracker/memory_tracker'
3
3
 
4
+ module MemoryTracker
5
+ end
@@ -1,15 +1,17 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ $:.push File.expand_path("../lib", __FILE__)
5
2
 
3
+ # Maintain your gem's version:
4
+ require "memory_tracker/version"
5
+
6
+ # Describe your gem and declare its dependencies:
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "memory_tracker"
8
- s.version = "1.0.1"
9
+ s.version = MemoryTracker::VERSION
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Philippe Le Rohellec"]
12
13
  s.date = "2013-11-15"
14
+ s.summary = "Rails memory allocations tracker"
13
15
  s.description = "Collect and analyze memory usage data for each individual Rails action controller."
14
16
  s.email = "philippe@lerohellec.com"
15
17
  s.extra_rdoc_files = [
@@ -22,13 +24,12 @@ Gem::Specification.new do |s|
22
24
  "LICENSE.txt",
23
25
  "README.rdoc",
24
26
  "Rakefile",
25
- "VERSION",
27
+ "app/controllers/memory_tracker/application_controller.rb",
26
28
  "app/controllers/memory_tracker/dashboards_controller.rb",
27
29
  "app/helpers/memory_tracker/dashboards_helper.rb",
28
30
  "app/views/layouts/memory_tracker.html.erb",
29
31
  "app/views/memory_tracker/dashboards/index.html.erb",
30
32
  "config/routes.rb",
31
- "docs/design.rb",
32
33
  "lib/memory_tracker.rb",
33
34
  "lib/memory_tracker/engine.rb",
34
35
  "lib/memory_tracker/env.rb",
@@ -39,19 +40,12 @@ Gem::Specification.new do |s|
39
40
  "lib/memory_tracker/stores/gcstat_logfile_store.rb",
40
41
  "lib/memory_tracker/stores/in_memory_store.rb",
41
42
  "lib/memory_tracker/stores/url_logfile_store.rb",
42
- "memory_tracker.gemspec",
43
- "spec/lib/memory_tracker_spec.rb",
44
- "spec/lib/request_spec.rb",
45
- "spec/lib/stores/gcstat_logfile_store_spec.rb",
46
- "spec/lib/stores/in_memory_store_spec.rb",
47
- "spec/lib/stores/url_logfile_store_spec.rb",
48
- "spec/spec_helper.rb"
49
- ]
43
+ "memory_tracker.gemspec"]
44
+ s.test_files = Dir["spec/**/*"]
45
+
50
46
  s.homepage = "http://github.com/plerohellec/memory_tracker"
51
47
  s.licenses = ["MIT"]
52
- s.require_paths = ["lib"]
53
48
  s.rubygems_version = "2.0.3"
54
- s.summary = "Rails memory allocations tracker"
55
49
 
56
50
  if s.respond_to? :specification_version then
57
51
  s.specification_version = 4
@@ -62,16 +56,14 @@ Gem::Specification.new do |s|
62
56
  s.add_development_dependency(%q<rspec>, ["~> 2.14.0"])
63
57
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
64
58
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
65
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
66
- s.add_runtime_dependency(%q<sys-proctable>, [">= 0"])
59
+
67
60
  else
68
61
  s.add_dependency(%q<sys-proctable>, [">= 0"])
69
62
  s.add_dependency(%q<debugger>, [">= 0"])
70
63
  s.add_dependency(%q<rspec>, ["~> 2.14.0"])
71
64
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
72
65
  s.add_dependency(%q<bundler>, ["~> 1.0"])
73
- s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
74
- s.add_dependency(%q<sys-proctable>, [">= 0"])
66
+
75
67
  end
76
68
  else
77
69
  s.add_dependency(%q<sys-proctable>, [">= 0"])
@@ -79,8 +71,6 @@ Gem::Specification.new do |s|
79
71
  s.add_dependency(%q<rspec>, ["~> 2.14.0"])
80
72
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
81
73
  s.add_dependency(%q<bundler>, ["~> 1.0"])
82
- s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
83
- s.add_dependency(%q<sys-proctable>, [">= 0"])
84
74
  end
85
75
  end
86
76
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Le Rohellec
@@ -80,34 +80,6 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.0'
83
- - !ruby/object:Gem::Dependency
84
- name: jeweler
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: 1.8.7
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ~>
95
- - !ruby/object:Gem::Version
96
- version: 1.8.7
97
- - !ruby/object:Gem::Dependency
98
- name: sys-proctable
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '>='
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
83
  description: Collect and analyze memory usage data for each individual Rails action
112
84
  controller.
113
85
  email: philippe@lerohellec.com
@@ -122,13 +94,12 @@ files:
122
94
  - LICENSE.txt
123
95
  - README.rdoc
124
96
  - Rakefile
125
- - VERSION
97
+ - app/controllers/memory_tracker/application_controller.rb
126
98
  - app/controllers/memory_tracker/dashboards_controller.rb
127
99
  - app/helpers/memory_tracker/dashboards_helper.rb
128
100
  - app/views/layouts/memory_tracker.html.erb
129
101
  - app/views/memory_tracker/dashboards/index.html.erb
130
102
  - config/routes.rb
131
- - docs/design.rb
132
103
  - lib/memory_tracker.rb
133
104
  - lib/memory_tracker/engine.rb
134
105
  - lib/memory_tracker/env.rb
@@ -140,12 +111,12 @@ files:
140
111
  - lib/memory_tracker/stores/in_memory_store.rb
141
112
  - lib/memory_tracker/stores/url_logfile_store.rb
142
113
  - memory_tracker.gemspec
143
- - spec/lib/memory_tracker_spec.rb
144
- - spec/lib/request_spec.rb
114
+ - spec/spec_helper.rb
145
115
  - spec/lib/stores/gcstat_logfile_store_spec.rb
146
116
  - spec/lib/stores/in_memory_store_spec.rb
147
117
  - spec/lib/stores/url_logfile_store_spec.rb
148
- - spec/spec_helper.rb
118
+ - spec/lib/request_spec.rb
119
+ - spec/lib/memory_tracker_spec.rb
149
120
  homepage: http://github.com/plerohellec/memory_tracker
150
121
  licenses:
151
122
  - MIT
@@ -170,4 +141,10 @@ rubygems_version: 2.0.3
170
141
  signing_key:
171
142
  specification_version: 4
172
143
  summary: Rails memory allocations tracker
173
- test_files: []
144
+ test_files:
145
+ - spec/spec_helper.rb
146
+ - spec/lib/stores/gcstat_logfile_store_spec.rb
147
+ - spec/lib/stores/in_memory_store_spec.rb
148
+ - spec/lib/stores/url_logfile_store_spec.rb
149
+ - spec/lib/request_spec.rb
150
+ - spec/lib/memory_tracker_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.1
data/docs/design.rb DELETED
@@ -1,111 +0,0 @@
1
- module MemoryTracker
2
- class Middleware
3
- end
4
-
5
- class Engine
6
- def initialize_stores
7
- MemoryTracker.instance.add_store(InMemoryStore.new)
8
- MemoryTracker.instance.add_store(LogfileStore.new)
9
- end
10
- end
11
-
12
- class MemoryTracker
13
- GCSTAT_LOGFILE = "#{Rails.root}/log/gcstat.log"
14
-
15
- include Singleton
16
-
17
- def stores
18
- @stores ||= {}
19
- end
20
-
21
- def add_stores
22
- end
23
-
24
- def start_request(env)
25
- @request = Request.new(env)
26
- end
27
-
28
- def end_request(status)
29
- @request.close
30
- stores.each { |store| store.push(@request) }
31
- end
32
- end
33
-
34
- class Request
35
- attr_reader :controller, :action, :gcstat_delta
36
- def initialize(env)
37
- @start_gcstat = GcStat.new(rss, vsize)
38
- end
39
-
40
- def close
41
- @end_gcstat = GcStat.new(rss, vsize)
42
- @gcstat_delta = GcStatDelta.new(@start_gcstat, @end_gcstat)
43
- end
44
- end
45
-
46
- class GcStat
47
- attr_reader :stat
48
- def initialize(rss, vsize)
49
- @stat = GC.stat.merge({ :rss => rss, :vsize => vsize})
50
- end
51
- end
52
-
53
- class GcStatDelta
54
- def initialize(before, after)
55
- @stat = after.inject({}) do |h, (k, v)|
56
- h[k] = after[k] - before [k]
57
- h
58
- end
59
- end
60
- end
61
-
62
- module Stores
63
- class InMemoryStore::Manager
64
- def initialize(window_length)
65
- @window1 = StatInterval.new(Time.now - length/2)
66
- @window2 = StatInterval.new(Time.now)
67
- end
68
-
69
- def name
70
- :memory
71
- end
72
-
73
- def rotate_windows
74
- if @window1.start_time + length > Time.now
75
- @window1 = @window2
76
- @window2 = Window.new(Time.now)
77
- end
78
- end
79
-
80
- def push
81
- rotate_windows
82
- @window1.push(request)
83
- @window2.push(request)
84
- end
85
-
86
- def stats
87
- @window1.stats
88
- end
89
- end
90
-
91
- class InMemoryStore::StatInterval
92
- attr_reader :start_time, :duration, :size
93
- attr_accessor :data # {}
94
-
95
- def initialize
96
- @data = {}
97
- end
98
-
99
- def push(request)
100
- @size += 1
101
- delta = request.gcstat_delta
102
- delta.each do |key|
103
- increment_action_counter(request.controller, request.action, key, delta[key])
104
- end
105
- end
106
-
107
- def increment_action_counter(controller, action, key, value)
108
- end
109
- end
110
- end
111
- end