mil-rack_apm 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0faa9a9fe52be23a9a01132050e4609653bb5fff
4
- data.tar.gz: c8d7de8865912b75e0e80fc2f07246574665bb68
3
+ metadata.gz: 39b15c064aab5a1f176fd8de0bbd6b61635efb75
4
+ data.tar.gz: 16a1b680cc2413ad3d3f4a34708ed46fd087b293
5
5
  SHA512:
6
- metadata.gz: 45dd6cca43c623e89f34ae702a0129adb4d5a15d5e25b82ec6df4f69be95baaeb93b76e5fb5edced772778bf7ed9b61ff842fde1b719f78fdb780323f44ba9d6
7
- data.tar.gz: 96c5ab4b894b8120c6dd7d7ecfbb88c8420b963c8082306476dc78f8857c9ef5337e17acb58f463fd0988f006466e3c4f28d1c03e16da65410de4e9bdbe052dd
6
+ metadata.gz: bdb6a9a75183fc4af512b9961be9ed23f22cdbb5f823541aeec234d43c36ed225e3cc1f28000204f91dc0d89c058f59f96403c6cedba35e44e1fe174e147c0f4
7
+ data.tar.gz: 3dfe021f7c428596868316268a682014ba96f41c063b295d50ac95aa98b39c75e85602bc269a465faf71f91f428ac5cfab2377c1af0ea33f78f95b92c726f3e1
@@ -1,3 +1,4 @@
1
+ require 'eventmachine'
1
2
  module Mil
2
3
  module RackApm
3
4
  class Data
@@ -5,8 +6,11 @@ module Mil
5
6
 
6
7
  def initialize(app, skip_path = [])
7
8
  @app = app
9
+ @bs = []
8
10
  skip_path = [skip_path] if skip_path.class == String
9
11
  @skip_path = skip_path
12
+ em_run
13
+ at_exit { em_close }
10
14
  end
11
15
 
12
16
  def call(env)
@@ -16,11 +20,7 @@ module Mil
16
20
  request_time = (time_now - start_time) * 1000
17
21
  return status, header, body if skip_path? env['REQUEST_PATH']
18
22
  unless env['REQUEST_PATH'] =~ /.*?\.(png|css|jpg|js|ico|jpeg|gif|bmp)$/
19
- q_path = path_split_to env['REQUEST_PATH']
20
- i = "mili-#{env['REQUEST_METHOD']}-#{q_path}"
21
- t = "milt-#{env['REQUEST_METHOD']}-#{q_path}"
22
- redis.incr i
23
- redis.incrbyfloat t, ('%0.3f' % request_time)
23
+ @bs << [env['REQUEST_METHOD'], env['REQUEST_PATH'], request_time]
24
24
  end
25
25
  [status, header, body]
26
26
  rescue => e
@@ -79,6 +79,35 @@ module Mil
79
79
  m.join '/'
80
80
  end
81
81
 
82
+ def em_run
83
+ begin
84
+ Thread.start do
85
+ EM.run{
86
+ @loop = EM.add_periodic_timer(60) do
87
+ unless @bs.nil?
88
+ @bs.each do |method, path, time|
89
+ q_path = path_split_to path
90
+ i = "mili-#{method}-#{q_path}"
91
+ t = "milt-#{method}-#{q_path}"
92
+ redis.incr i
93
+ redis.incrbyfloat t, ('%0.3f' % time)
94
+ end
95
+ @bs = []
96
+ end
97
+
98
+ end
99
+ }
100
+ end
101
+ rescue => e
102
+ puts 'mil data error'
103
+ end
104
+ end
105
+
106
+ def em_close
107
+ EM.cancel_timer(@loop)
108
+ EM.stop
109
+ end
110
+
82
111
  end
83
112
  end
84
113
  end
@@ -5,11 +5,6 @@ var max_count = 0;
5
5
 
6
6
  $(document).ready(function(){
7
7
 
8
- // $("#table_data tr").bind('click', function(){
9
- // update_data();
10
- // })
11
-
12
-
13
8
  $('#path').keyup(function() {
14
9
  if(path != $(this).val()){
15
10
  path = $(this).val()
@@ -62,20 +57,6 @@ $(document).ready(function(){
62
57
  $('.delete_show').click(function(){
63
58
  if(confirm("Are you delete all show key?")){
64
59
  delete_all_show();
65
- // var url = window.location.href.split('?')[0];
66
- // var obj = $(this);
67
- // $.ajax({
68
- // method: "DELETE",
69
- // url: url +"/delete_key",
70
- // data: { key: obj.attr('key') },
71
- // success: function(message){
72
- // if('ok' == message){
73
- // obj.parents('tr').remove();
74
- // }else{
75
- // alert('delete error!');
76
- // }
77
- // }
78
- // })
79
60
  }
80
61
  })
81
62
 
@@ -141,9 +122,6 @@ var update_data = function(){
141
122
 
142
123
  show_controller($(this), is_show);
143
124
  }
144
- // if(objString.length>46){
145
- // objString=$(this).children("#Emailtd").text(objString.substring(0,46) + "...")
146
- // }
147
125
  });
148
126
  };
149
127
 
@@ -1,5 +1,5 @@
1
1
  module Mil
2
2
  module RackApm
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@
14
14
  <header>
15
15
  <div class="row">
16
16
  <div class="col-xs-offset-1 col-xs-2">
17
- <h5>MIL RACK APM v0.1.0</h5>
17
+ <h5>MIL RACK APM v0.3.0</h5>
18
18
  </div>
19
19
  </div>
20
20
  <br />
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mil-rack_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - millim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,4 +80,3 @@ signing_key:
80
80
  specification_version: 4
81
81
  summary: This is lite rack apm web
82
82
  test_files: []
83
- has_rdoc: