logs_visualizer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/logs_visualizer.rb +237 -0
- data/lib/logs_visualizer/version.rb +3 -0
- data/logs_visualizer.gemspec +26 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a9d5356fbd24e89d31d0da0b7d7e1e52f2681034
|
4
|
+
data.tar.gz: 9cfe0723d53bffeda1dba5d276def131537ba974
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8adbed0f74d39f72bcc2eaa1e4148a9a88fde9a3ec112cd576f0f71922fb5a86ce17d3fc4f8d78a83ab864ee9dc9769ffb31bd846eb205d1ee334d9038090c9
|
7
|
+
data.tar.gz: e6926cfcd1c377c123fc96c96e8508fbbc9ceb06e55fcae51e779e6d918683153625374b88bbbcdbcc2d80d22f0d098828361f2df4bca9fb1ef5c70a4026bc26
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
logs_visualizer
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.3
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Vasilis Kalligas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# LogsVisualizer
|
2
|
+
|
3
|
+
This gem allows users to convert the logs produced by a rails app into useful visualization graphs.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'logs_visualizer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install logs_visualizer
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
LogVisualizer.produce_graph
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/arcanoid/logs_visualizer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
34
|
+
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
39
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "logs_visualizer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
require 'logs_visualizer/version'
|
2
|
+
|
3
|
+
module LogsVisualizer
|
4
|
+
def self.produce_graph(string_input, graph_name = nil, options = {})
|
5
|
+
if string_input.present?
|
6
|
+
g = GraphViz::new( :G, :type => :digraph )
|
7
|
+
g[:rankdir] ='LR'
|
8
|
+
|
9
|
+
data = populate_data string_input, options
|
10
|
+
populate_graph g, data, graph_name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
#########
|
15
|
+
protected
|
16
|
+
#########
|
17
|
+
|
18
|
+
def self.populate_data(logs_text, options = {})
|
19
|
+
data = { :nodes => [] }
|
20
|
+
|
21
|
+
logs_text.split('Started ').each do |action|
|
22
|
+
if action.present? && action != ""
|
23
|
+
action_parsed = /(?<action>.*) for/.match(action)[:action]
|
24
|
+
rendered_partials = []
|
25
|
+
service_requests = []
|
26
|
+
service_times = []
|
27
|
+
compiled_assets = []
|
28
|
+
sql_insertions = []
|
29
|
+
sql_selections = []
|
30
|
+
sql_updates = []
|
31
|
+
serializers = []
|
32
|
+
|
33
|
+
unless /.*\"\/assets.*/.match(action_parsed)
|
34
|
+
action.split("\r\n").each do |log_line|
|
35
|
+
partial_in_line = /Rendered (?<partial>(\S)*).*\((?<time>(\S)*)ms/.match(log_line)
|
36
|
+
service_request_in_line = /\[httplog\] Sending: (?<service>.*)/.match(log_line)
|
37
|
+
service_time_in_line = /\[httplog\] Benchmark: (?<time>\S*)/.match(log_line)
|
38
|
+
compiled_asset_in_line = /Compiled (?<asset>(\S)*).*\((?<time>\S*)ms\)/.match(log_line)
|
39
|
+
sql_insertion_in_line = /SQL.*\((?<time>\S*)ms\).*INSERT INTO (?<table>(\S)*)/.match(log_line)
|
40
|
+
sql_select_in_line = /\((?<time>\S*)ms\).*SELECT .* FROM (?<table>(\S)*)/.match(log_line)
|
41
|
+
sql_update_in_line = /\((?<time>\S*)ms\).*UPDATE (?<table>(\S)*)/.match(log_line)
|
42
|
+
serializer_in_line = /\[active_model_serializers\] Rendered (?<serializer>\S*) with .* \((?<time>\S*)ms\)/.match(log_line)
|
43
|
+
|
44
|
+
if partial_in_line.present? && (options[:rendered_partials] == true || options[:all] == true)
|
45
|
+
rendered_partials << { :partial => partial_in_line[:partial], :time => partial_in_line[:time].to_f }
|
46
|
+
end
|
47
|
+
|
48
|
+
if service_time_in_line.present? && (options[:service_requests] == true || options[:all] == true)
|
49
|
+
service_times << service_time_in_line[:time].to_f
|
50
|
+
end
|
51
|
+
|
52
|
+
if service_request_in_line.present? && (options[:service_requests] == true || options[:all] == true)
|
53
|
+
service_requests << service_request_in_line[:service]
|
54
|
+
end
|
55
|
+
|
56
|
+
if compiled_asset_in_line.present? && (options[:compiled_assets] == true || options[:all] == true)
|
57
|
+
compiled_assets << { :asset => compiled_asset_in_line[:asset], :time => compiled_asset_in_line[:time].to_f }
|
58
|
+
end
|
59
|
+
|
60
|
+
if sql_insertion_in_line.present? && (options[:sql_visualization] == true || options[:all] == true)
|
61
|
+
sql_insertions << { :table => sql_insertion_in_line[:table], :time => sql_insertion_in_line[:time].to_f }
|
62
|
+
end
|
63
|
+
|
64
|
+
if sql_select_in_line.present? && (options[:sql_visualization] == true || options[:all] == true)
|
65
|
+
sql_selections << { :table => sql_select_in_line[:table], :time => sql_select_in_line[:time].to_f }
|
66
|
+
end
|
67
|
+
|
68
|
+
if sql_update_in_line.present? && (options[:sql_visualization] == true || options[:all] == true)
|
69
|
+
sql_updates << { :table => sql_update_in_line[:table], :time => sql_update_in_line[:time].to_f }
|
70
|
+
end
|
71
|
+
|
72
|
+
if serializer_in_line.present? && (options[:serializers] == true || options[:all] == true)
|
73
|
+
serializers << { :serializer => serializer_in_line[:serializer], :time => serializer_in_line[:time].to_f }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
controller_processing_request = /Processing by (?<controller>.*) as/.match(action)[:controller]
|
78
|
+
redirect_to_url = /Redirected to (?<redirect_url>(\S)*)/.match(action)
|
79
|
+
|
80
|
+
if data[:nodes].size > 0 && (data[:nodes].map { |node| node[:label] }.include? action_parsed)
|
81
|
+
data[:nodes].map { |node| node[:size] += 1 if node[:label] == action_parsed }
|
82
|
+
else
|
83
|
+
services = []
|
84
|
+
|
85
|
+
service_requests.each_with_index do |service, index|
|
86
|
+
services << { :service => service, :time => service_times[index] }
|
87
|
+
end
|
88
|
+
|
89
|
+
data[:nodes] << {
|
90
|
+
:size => 1,
|
91
|
+
:label => action_parsed,
|
92
|
+
:controller => controller_processing_request,
|
93
|
+
:redirect => (URI(redirect_to_url[:redirect_url]) if redirect_to_url.present? ),
|
94
|
+
:rendered_partials => rendered_partials.group_by { |x| x[:partial] },
|
95
|
+
:service_requests => services,
|
96
|
+
:compiled_assets => compiled_assets.group_by { |x| x[:asset] },
|
97
|
+
:sql_insertions => sql_insertions.group_by { |x| x[:table] },
|
98
|
+
:sql_selections => sql_selections.group_by { |x| x[:table] },
|
99
|
+
:sql_updates => sql_updates.group_by { |x| x[:table] },
|
100
|
+
:serializers => serializers.group_by { |x| x[:serializer] },
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
data
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.populate_graph(graph, data, graph_name = nil)
|
111
|
+
if data[:nodes].present?
|
112
|
+
data[:nodes].each do |node|
|
113
|
+
node[:graph_node] = graph.add_nodes(node[:label], :label => "<<b>#{node[:label].gsub('&', '%26')}</b><br/><i>#{node[:controller]}</i>>")
|
114
|
+
|
115
|
+
maximum_rendered_time = node[:rendered_partials].map { |partial, partials_array| partials_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.max
|
116
|
+
maximum_sql_insertion_time = node[:sql_insertions].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.max
|
117
|
+
maximum_asset_compilation_time = node[:compiled_assets].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.max
|
118
|
+
maximum_sql_selection_time = node[:sql_selections].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.max
|
119
|
+
maximum_sql_update_time = node[:sql_updates].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.max
|
120
|
+
maximum_service_time = node[:service_requests].group_by { |x| x[:service] }.map { |service, services_array| (services_array.inject(0){|sum,x| sum + x[:time] } * 1000).round(2) }.max
|
121
|
+
maximum_serializer_time = node[:serializers].map { |array_name, names_array| (names_array.inject(0){|sum,x| sum + x[:time] }).round(2) }.max
|
122
|
+
|
123
|
+
minimum_rendered_time = node[:rendered_partials].map { |partial, partials_array| partials_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.min
|
124
|
+
minimum_sql_insertion_time = node[:sql_insertions].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.min
|
125
|
+
minimum_asset_compilation_time = node[:compiled_assets].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.min
|
126
|
+
minimum_sql_selection_time = node[:sql_selections].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.min
|
127
|
+
minimum_sql_update_time = node[:sql_updates].map { |array_name, names_array| names_array.inject(0){|sum,x| sum + x[:time] }.round(2) }.min
|
128
|
+
minimum_service_time = node[:service_requests].group_by { |x| x[:service] }.map { |service, services_array| (services_array.inject(0){|sum,x| sum + x[:time] } * 1000).round(2) }.min
|
129
|
+
minimum_serializer_time = node[:serializers].map { |service, services_array| (services_array.inject(0){|sum,x| sum + x[:time] }).round(2) }.min
|
130
|
+
|
131
|
+
node[:rendered_partials].each do |partial, partials_array|
|
132
|
+
partial_node = graph.add_nodes(partial, :shape => :component)
|
133
|
+
total_time = partials_array.inject(0){|sum,x| sum + x[:time] }.round(2)
|
134
|
+
if maximum_rendered_time == total_time
|
135
|
+
graph.add_edges( node[:graph_node], partial_node, :label => "<<i>Renders<br/>(#{partials_array.size} times)<br/>in <b>#{partials_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'red', :fontcolor => 'red')
|
136
|
+
elsif minimum_rendered_time == total_time
|
137
|
+
graph.add_edges( node[:graph_node], partial_node, :label => "<<i>Renders<br/>(#{partials_array.size} times)<br/>in <b>#{partials_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'darkgreen', :fontcolor => 'darkgreen')
|
138
|
+
else
|
139
|
+
graph.add_edges( node[:graph_node], partial_node, :label => "<<i>Renders<br/>(#{partials_array.size} times)<br/>in #{partials_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</i>>")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
if node[:redirect].present?
|
144
|
+
graph.add_edges( node[:graph_node], "GET \"#{node[:redirect].path}\"", :label => "<<i>Redirects to</i>>")
|
145
|
+
end
|
146
|
+
|
147
|
+
node[:compiled_assets].each do |asset, assets_array|
|
148
|
+
asset_node = graph.add_nodes(asset, :shape => :folder)
|
149
|
+
total_time = assets_array.inject(0){|sum,x| sum + x[:time] }.round(2)
|
150
|
+
if maximum_asset_compilation_time == total_time
|
151
|
+
graph.add_edges( node[:graph_node], asset_node, :label => "<<i>Compiles asset<br/>(#{assets_array.size} times)<br/>in <b>#{assets_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'red', :fontcolor => 'red')
|
152
|
+
elsif minimum_asset_compilation_time == total_time
|
153
|
+
graph.add_edges( node[:graph_node], asset_node, :label => "<<i>Compiles asset<br/>(#{assets_array.size} times)<br/>in <b>#{assets_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'darkgreen', :fontcolor => 'darkgreen')
|
154
|
+
else
|
155
|
+
graph.add_edges( node[:graph_node], asset_node, :label => "<<i>Compiles asset<br/>(#{assets_array.size} times)<br/>in #{assets_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</i>>")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
node[:serializers].each do |name, serializers_array|
|
160
|
+
graph_node = graph.add_nodes(name, :shape => :msquare)
|
161
|
+
total_time = serializers_array.inject(0){|sum,x| sum + x[:time] }.round(2)
|
162
|
+
|
163
|
+
if maximum_serializer_time == total_time
|
164
|
+
graph.add_edges( node[:graph_node], graph_node, :label => "<<i>Serializes through<br/>(#{serializers_array.size} times)<br/>in <b>#{serializers_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'red', :fontcolor => 'red')
|
165
|
+
elsif minimum_serializer_time == total_time
|
166
|
+
graph.add_edges( node[:graph_node], graph_node, :label => "<<i>Serializes through<br/>(#{serializers_array.size} times)<br/>in <b>#{serializers_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'darkgreen', :fontcolor => 'darkgreen')
|
167
|
+
else
|
168
|
+
graph.add_edges( node[:graph_node], graph_node, :label => "<<i>Serializes through<br/>(#{serializers_array.size} times)<br/>in #{serializers_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</i>>")
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
node[:sql_insertions].each do |array_name, names_array|
|
173
|
+
array_node = graph.add_nodes(array_name, :shape => :box3d)
|
174
|
+
total_time = names_array.inject(0){|sum,x| sum + x[:time] }.round(2)
|
175
|
+
if maximum_sql_insertion_time == total_time
|
176
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Inserts into<br/>(#{names_array.size} times)<br/>in <b>#{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'red', :fontcolor => 'red')
|
177
|
+
elsif minimum_sql_insertion_time == total_time
|
178
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Inserts into<br/>(#{names_array.size} times)<br/>in <b>#{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'darkgreen', :fontcolor => 'darkgreen')
|
179
|
+
else
|
180
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Inserts into<br/>(#{names_array.size} times)<br/>in #{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</i>>")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
node[:sql_selections].each do |array_name, names_array|
|
185
|
+
array_node = graph.add_nodes(array_name, :shape => :box3d)
|
186
|
+
total_time = names_array.inject(0){|sum,x| sum + x[:time] }.round(2)
|
187
|
+
if maximum_sql_selection_time == total_time
|
188
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Selects from<br/>(#{names_array.size} times)<br/>in <b>#{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'red', :fontcolor => 'red')
|
189
|
+
elsif minimum_sql_selection_time == total_time
|
190
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Selects from<br/>(#{names_array.size} times)<br/>in <b>#{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'darkgreen', :fontcolor => 'darkgreen')
|
191
|
+
else
|
192
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Selects from<br/>(#{names_array.size} times)<br/>in #{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</i>>")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
node[:sql_updates].each do |array_name, names_array|
|
197
|
+
array_node = graph.add_nodes(array_name, :shape => :box3d)
|
198
|
+
total_time = names_array.inject(0){|sum,x| sum + x[:time] }.round(2)
|
199
|
+
if maximum_sql_update_time == total_time
|
200
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Updates<br/>(#{names_array.size} times)<br/>in <b>#{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'red', :fontcolor => 'red')
|
201
|
+
elsif minimum_sql_update_time == total_time
|
202
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Updates<br/>(#{names_array.size} times)<br/>in <b>#{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</b></i>>", :color => 'darkgreen', :fontcolor => 'darkgreen')
|
203
|
+
else
|
204
|
+
graph.add_edges( node[:graph_node], array_node, :label => "<<i>Updates<br/>(#{names_array.size} times)<br/>in #{names_array.inject(0){|sum,x| sum + x[:time] }.round(2)}ms</i>>")
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
node[:service_requests].
|
209
|
+
map { |service| {:service => URI(service[:service].split(' ')[1]).host, :time => service[:time]} }.
|
210
|
+
group_by { |x| x[:service] }.
|
211
|
+
each do |service, services_array|
|
212
|
+
|
213
|
+
service_node = graph.add_nodes(service, :shape => :note)
|
214
|
+
graph.add_edges( node[:graph_node], service_node, :label => "<<i>Requests<br/>(#{services_array.size} times)<br/>in #{(services_array.inject(0){|sum,x| sum + x[:time] } * 1000).round(2)}ms</i>>")
|
215
|
+
end
|
216
|
+
|
217
|
+
node[:service_requests].group_by { |x| x[:service] }.each do |service, services_array|
|
218
|
+
service_split = service.split(' ')
|
219
|
+
full_service_node = graph.add_nodes("#{service_split[0]} #{[URI(service.split(' ')[1]).path, URI(service.split(' ')[1]).query.presence].reject { |x| x.blank? }.join('?')}", :shape => :note)
|
220
|
+
total_time = (services_array.inject(0){|sum,x| sum + x[:time] } * 1000).round(2)
|
221
|
+
|
222
|
+
if total_time == maximum_service_time
|
223
|
+
graph.add_edges( URI(service.split(' ')[1]).host, full_service_node, :label => "<<i>Includes requests to<br/>(#{services_array.size} times)<br/>in <b>#{(services_array.inject(0){|sum,x| sum + x[:time] } * 1000).round(2)}ms</b></i>>", :color => 'red', :fontcolor => 'red')
|
224
|
+
elsif total_time == minimum_service_time
|
225
|
+
graph.add_edges( URI(service.split(' ')[1]).host, full_service_node, :label => "<<i>Includes requests to<br/>(#{services_array.size} times)<br/>in <b>#{(services_array.inject(0){|sum,x| sum + x[:time] } * 1000).round(2)}ms</b></i>>", :color => 'darkgreen', :fontcolor => 'darkgreen')
|
226
|
+
else
|
227
|
+
graph.add_edges( URI(service.split(' ')[1]).host, full_service_node, :label => "<<i>Includes requests to<br/>(#{services_array.size} times)<br/>in #{(services_array.inject(0){|sum,x| sum + x[:time] } * 1000).round(2)}ms</i>>")
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
directory_name = 'graphs'
|
233
|
+
FileUtils.mkdir_p(directory_name) unless File.directory?(directory_name)
|
234
|
+
graph.output(:png => "#{directory_name}/#{graph_name.present? ? graph_name : "graph_#{DateTime.now.strftime('%H%M%S%L')}" }.png" )
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'logs_visualizer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "logs_visualizer"
|
8
|
+
spec.version = LogsVisualizer::VERSION
|
9
|
+
spec.authors = ["Vasilis Kalligas"]
|
10
|
+
spec.email = ["billkall@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A gem that converts the input of logs of text into graphs}
|
13
|
+
spec.description = %q{This gem takes as input a string of logs and converts them to an image graph of times and dependencies.}
|
14
|
+
spec.homepage = "https://github.com/arcanoid/logs_visualizer"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', "~> 1.10"
|
23
|
+
spec.add_development_dependency 'rake', "~> 10.0"
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'ruby-graphviz'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logs_visualizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vasilis Kalligas
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-graphviz
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: This gem takes as input a string of logs and converts them to an image
|
70
|
+
graph of times and dependencies.
|
71
|
+
email:
|
72
|
+
- billkall@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".ruby-gemset"
|
79
|
+
- ".ruby-version"
|
80
|
+
- ".travis.yml"
|
81
|
+
- CHANGELOG.md
|
82
|
+
- CODE_OF_CONDUCT.md
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- bin/console
|
88
|
+
- bin/setup
|
89
|
+
- lib/logs_visualizer.rb
|
90
|
+
- lib/logs_visualizer/version.rb
|
91
|
+
- logs_visualizer.gemspec
|
92
|
+
homepage: https://github.com/arcanoid/logs_visualizer
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.4.8
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: A gem that converts the input of logs of text into graphs
|
116
|
+
test_files: []
|