gc_stats 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTORS.md +2 -1
- data/README.md +14 -5
- data/lib/gc_stats.rb +3 -7
- data/lib/gc_stats/gc_logger.rb +15 -7
- data/lib/gc_stats/initializer.rb +10 -1
- data/lib/gc_stats/middleware.rb +11 -7
- data/lib/gc_stats/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c75eb722713e0615b6c77a1d9ec82951b46e01d3
|
4
|
+
data.tar.gz: fb63d4b8040d07029a89840785e3741c09cd859c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf86d22063fffdaecdfe2c6f3c076347b6491b008bd093bc14efb3508754e516a474bd5afd2e66f3cb8f7fc2d62f9a897e2019873b183c21ee2fbe9ba073ab41
|
7
|
+
data.tar.gz: c0fca4ecb664d90cb59d19ed976f987630b2cfabfa78f0c0ab963526edea753f74287efb5c1349a66ee3edbdcfbd124a4ca36094445799a1dec59e4326cca61a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
1.0.1
|
2
|
+
-----
|
3
|
+
* [Rename the the log message field name from 'Process.pid' to 'PID'](https://github.com/cerner/gc_stats/pull/1)
|
4
|
+
* [Cleanup of formatting, require statements and keeping lines to 80 characters](https://github.com/cerner/gc_stats/pull/2)
|
5
|
+
* [Rework GCStats::Middleware to simplify it and keep it thread safe](https://github.com/cerner/gc_stats/pull/4)
|
6
|
+
* [Add a depdendency on Rails 4.1+](https://github.com/cerner/gc_stats/pull/5)
|
7
|
+
|
1
8
|
1.0.0
|
2
9
|
-----
|
3
10
|
* Initial release
|
data/CONTRIBUTORS.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# gc_stats
|
2
2
|
|
3
|
+
[![Build Status](https://api.travis-ci.org/cerner/gc_stats.svg)][travis]
|
4
|
+
[![Gem Version](http://img.shields.io/gem/v/gc_stats.svg)][gem]
|
5
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/cerner/gc_stats.svg)][codeclimate]
|
6
|
+
[![Dependencies Status](http://img.shields.io/gemnasium/cerner/gc_stats.svg)][gemnasium]
|
7
|
+
|
8
|
+
[travis]: https://travis-ci.org/cerner/gc_stats
|
9
|
+
[gem]: https://rubygems.org/gems/gc_stats
|
10
|
+
[codeclimate]: https://codeclimate.com/github/cerner/gc_stats
|
11
|
+
[gemnasium]: https://gemnasium.com/cerner/gc_stats
|
12
|
+
|
3
13
|
gc_stats is a Ruby gem for Rails applications that collects and logs garbage collection statistics during each request. GC statistics are only logged if a GC event is detected. This allows you to track and analyze the GC characteristics of your Rails application.
|
4
14
|
|
5
15
|
## Installation
|
@@ -20,17 +30,17 @@ Once you have added a dependency to this gem and installed it, simply require th
|
|
20
30
|
|
21
31
|
## Usage
|
22
32
|
|
23
|
-
With gc_stats, all of your final controller log messages will now contain the
|
33
|
+
With gc_stats, all of your final controller log messages will now contain the PID of the Ruby process. For example:
|
24
34
|
|
25
|
-
Completed 200 OK in 5ms (
|
35
|
+
Completed 200 OK in 5ms (PID: 12875)
|
26
36
|
|
27
37
|
If a garbage collection event occurs during a request, you will see additional information in this same final controller log message that will contain the GC statistics. For example:
|
28
38
|
|
29
|
-
Completed 200 OK in 38ms (
|
39
|
+
Completed 200 OK in 38ms (PID: 12875 | GC: [total_gc_time: 22.574 ms | num_events: 1 | major/minor/count: 9/24/33])
|
30
40
|
|
31
41
|
An explanation of each field being logged follows:
|
32
42
|
|
33
|
-
*
|
43
|
+
* PID - The process id obtained from [Process.pid](http://ruby-doc.org/core-2.1.0/Process.html#method-c-pid)
|
34
44
|
* total_gc_time - The total time taken for garbage collection during this request, converted to milliseconds ([GC::Profiler.total_time](http://ruby-doc.org/core-2.1.0/GC/Profiler.html#method-c-total_time))
|
35
45
|
* num_events - The number of garbage collection events that occurred during the request
|
36
46
|
* major - The total number of GC runs that traversed the whole Ruby heap, including old, young and remembered objects over the life of this process
|
@@ -57,4 +67,3 @@ Copyright 2015 Cerner Innovation, Inc.
|
|
57
67
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
58
68
|
|
59
69
|
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
60
|
-
|
data/lib/gc_stats.rb
CHANGED
data/lib/gc_stats/gc_logger.rb
CHANGED
@@ -1,21 +1,29 @@
|
|
1
1
|
module GCStats
|
2
2
|
|
3
|
-
# ActionController hook to inject runtime info into the request notification
|
3
|
+
# ActionController hook to inject runtime info into the request notification
|
4
|
+
# event
|
4
5
|
module GCLogger
|
5
6
|
extend ActiveSupport::Concern
|
6
7
|
|
7
8
|
module ClassMethods
|
8
|
-
|
9
|
-
# to
|
9
|
+
|
10
|
+
# ActionController hook to add the process ID and GC info on to the info
|
11
|
+
# message to be logged as part of the request event.
|
10
12
|
# @param [Hash] payload hash containing additional info to be logged
|
11
13
|
def log_process_action(payload)
|
12
|
-
gc_time = GC::Profiler.total_time
|
13
14
|
messages = super
|
14
|
-
messages << "
|
15
|
-
|
15
|
+
messages << "PID: #{Process.pid}"
|
16
|
+
|
17
|
+
gc_time = GC::Profiler.total_time
|
18
|
+
if gc_time > 0
|
19
|
+
messages << "GC: [total_gc_time: #{gc_time*1000} ms |" \
|
20
|
+
" num_events: #{GC::Profiler.raw_data.count} | major/minor/count:" \
|
21
|
+
" #{GC.stat[:major_gc_count]}/#{GC.stat[:minor_gc_count]}/#{GC.count}]"
|
22
|
+
end
|
23
|
+
|
16
24
|
messages
|
17
25
|
end
|
18
26
|
|
19
27
|
end
|
20
28
|
end
|
21
|
-
end
|
29
|
+
end
|
data/lib/gc_stats/initializer.rb
CHANGED
@@ -1,14 +1,23 @@
|
|
1
|
+
require 'gc_stats/gc_logger'
|
2
|
+
require 'gc_stats/middleware'
|
3
|
+
|
1
4
|
module GCStats
|
5
|
+
|
2
6
|
class Initializer < Rails::Railtie
|
3
7
|
|
4
8
|
config.before_initialize do
|
9
|
+
# enable the GC Profiler
|
5
10
|
GC::Profiler.enable
|
11
|
+
|
12
|
+
# Add the GCStats::Middlware to the application's middleware
|
6
13
|
config.app_middleware.insert_before ::Rack::Runtime, GCStats::Middleware
|
7
14
|
|
15
|
+
# Include the GCStats::GCLogger mixin to base controller
|
8
16
|
ActiveSupport.on_load(:action_controller) do
|
9
17
|
include GCStats::GCLogger
|
10
18
|
end
|
11
19
|
end
|
12
20
|
|
13
21
|
end
|
14
|
-
|
22
|
+
|
23
|
+
end
|
data/lib/gc_stats/middleware.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
module GCStats
|
2
|
+
|
3
|
+
# Rack middleware that clears out GC::Profiler's data on each request.
|
2
4
|
class Middleware
|
5
|
+
|
3
6
|
def initialize(app)
|
4
7
|
@app = app
|
5
8
|
end
|
6
9
|
|
7
10
|
def call(env)
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def _call(env)
|
11
|
+
# clear out the profiler's data
|
12
12
|
GC::Profiler.clear
|
13
|
-
@status, @headers, @response = @app.call(env)
|
14
13
|
|
15
|
-
|
14
|
+
# pass the call onto the next link in the chain
|
15
|
+
status, headers, response = @app.call(env)
|
16
|
+
|
17
|
+
# pass the results back
|
18
|
+
[status, headers, response]
|
16
19
|
end
|
17
20
|
|
18
21
|
end
|
19
|
-
|
22
|
+
|
23
|
+
end
|
data/lib/gc_stats/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gc_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Faiz Ahmed Shaik
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
13
|
-
dependencies:
|
12
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.1'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.1'
|
14
28
|
description: |2
|
15
29
|
gc_stats is a Ruby gem for Rails applications that collects and logs garbage collection statistics
|
16
30
|
during each request. GC statistics are only logged if a GC event is detected. This allows you to
|