simple_apm 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
  SHA256:
3
- metadata.gz: fd4fe5594ac36d455b7fdf4ca4a4fc651ad14548b90ff012ee6d751a6c2beb7f
4
- data.tar.gz: 8df2b6f4ee913baa062951348eb3cdf6cc857f7e0c94908d643ddb975c947105
3
+ metadata.gz: fef3d86f5fe835b90243b01bc335aabbc20bbfd1d581eab08e71b851790be92a
4
+ data.tar.gz: 353ee2dab5eba98f1e3bbbb4bcc5c01f17bd0a049484c5dcc9c5aece426c83dc
5
5
  SHA512:
6
- metadata.gz: c21c50c8ba0febe13256b1ff7df86429f9524ca9c9c66edf0c8fa421ab51f049e393350dad832588ddbe671e3d0565f4c785df4e8121a44443b440ea7da3cf88
7
- data.tar.gz: 6757487076b662d638be97459e8784fd5759a56e4200ad321bc292c3e15d15b3801894ca44b90ee78c18b531337820747326df20f11ca7ebedf1dc339fb3f8ea
6
+ metadata.gz: 3a5110cfae48bf65c15cbe89ed8906c67d6ca3452f1a97ebf567b72087555626dac2d8c4d643fcdb4be4c22e44ad63e357378258f9efe98a1ed1f6c4931ada36
7
+ data.tar.gz: 8b6b5ac0420c57abb6e557dd1fb02690e4f4f947445fe76ad9e903df6da0b0694e09e9547e4594a8b8c0010372ec8eea84c0043f71710cda3dd54b73f0470fa1
@@ -65,6 +65,12 @@ module SimpleApm
65
65
  elsif params[:type]=='week'
66
66
  del_count = SimpleApm::Redis.clear_data_before_time(Time.now.at_beginning_of_day - 1.week)
67
67
  flash[:notice] = "成功删除#{del_count}条数据"
68
+ elsif params[:type]=='stop_data'
69
+ SimpleApm::Redis.stop!
70
+ flash[:notice] = '设置成功!'
71
+ elsif params[:type]=='rerun_data'
72
+ SimpleApm::Redis.rerun!
73
+ flash[:notice] = '设置成功!'
68
74
  else
69
75
  flash[:notice] = '未知操作!'
70
76
  # r = params[:date].map{|d|SimpleApm::Redis.clear_data(d)}
@@ -113,6 +113,13 @@
113
113
  <% SimpleApm::Redis.simple_info.each do |k, v| %>
114
114
  <label><%= k %>:</label><span><%= v %></span>
115
115
  <% end %>
116
+ <p>
117
+ <% if SimpleApm::Redis.running? %>
118
+ <span style="color: greenyellow">数据收集中……</span>
119
+ <% else %>
120
+ <span style="color: red">已暂停</span>
121
+ <% end %>
122
+ </p>
116
123
  </footer>
117
124
  <div id="sql-modal" class="modal" aria-hidden="true" role="dialog" style="display: none;" tabindex="-1">
118
125
  <div class="modal-dialog modal-lg modal-dialog-popout">
@@ -1,7 +1,13 @@
1
+ <% if SimpleApm::Redis.running? %>
2
+ <%= link_to '暂停收集数据', data_delete_path(type: 'stop_data'), class: 'btn btn-warning btn-sm', 'data-confirm'=>'确定暂停吗?' %>
3
+ <% else %>
4
+ <%= link_to '继续收集数据', data_delete_path(type: 'rerun_data'), class: 'btn btn-primary btn-sm' %>
5
+ <% end %>
6
+ <%= link_to '', data_delete_path(type: ''), class: 'btn' %>
1
7
  <p class="pull-right">
2
8
  <span class="text-danger">删除数据:</span>
3
- <%= link_to '保留进一周数据', data_delete_path(type: 'week'), class: 'btn btn-danger', 'data-confirm'=> '确定删除所有一周以前的数据?'%>
4
- <%= link_to '保留进一个月数据', data_delete_path(type: 'month'), class: 'btn btn-danger', 'data-confirm'=> '确定删除所有一个月以前的数据?' %>
9
+ <%= link_to '保留进一周数据', data_delete_path(type: 'week'), class: 'btn btn-danger', 'data-confirm' => '确定删除所有一周以前的数据?' %>
10
+ <%= link_to '保留进一个月数据', data_delete_path(type: 'month'), class: 'btn btn-danger', 'data-confirm' => '确定删除所有一个月以前的数据?' %>
5
11
  </p>
6
12
 
7
13
  <table class="table table-bordered">
@@ -17,10 +23,10 @@
17
23
  <!-- {day: date_str, hits: hits, time: time, avg_time: avg_time}-->
18
24
  <% @data.each do |d| %>
19
25
  <tr>
20
- <td><%= d[:day]%></td>
21
- <td><%= d[:hits]%></td>
22
- <td><%= sec_str d[:avg_time]%></td>
23
- <td><%= link_to '删除', data_delete_path(date: d[:day]), 'data-confirm'=> '确定删除?' %></td>
26
+ <td><%= d[:day] %></td>
27
+ <td><%= d[:hits] %></td>
28
+ <td><%= sec_str d[:avg_time] %></td>
29
+ <td><%= link_to '删除', data_delete_path(date: d[:day]), 'data-confirm' => '确定删除?' %></td>
24
30
  </tr>
25
31
  <% end %>
26
32
  </tbody>
@@ -7,6 +7,7 @@ module SimpleApm
7
7
  begin
8
8
  request_id = Thread.current['action_dispatch.request_id']
9
9
  need_skip = payload[:controller] == 'SimpleApm::ApmController'
10
+ need_skip = true if payload[:status].to_s=='302' && payload[:path].to_s=~/login/ && payload[:method].to_s.downcase=='get'
10
11
  if request_id.present?
11
12
  if need_skip
12
13
  SimpleApm::Sql.delete_by_request_id(request_id)
@@ -5,7 +5,9 @@ module SimpleApm
5
5
  end
6
6
 
7
7
  def call(env)
8
- Thread.current['action_dispatch.request_id'] = env['action_dispatch.request_id']
8
+ if SimpleApm::Redis.running?
9
+ Thread.current['action_dispatch.request_id'] = env['action_dispatch.request_id']
10
+ end
9
11
  @app.call(env)
10
12
  end
11
13
  end
@@ -55,6 +55,19 @@ module SimpleApm
55
55
  {success: true, msg: SimpleApm::Redis.del(keys)}
56
56
  end
57
57
 
58
+ def running?
59
+ hget('status','running').to_s != 'false'
60
+ end
61
+
62
+ def rerun!
63
+ hset('status', 'running', true)
64
+ end
65
+
66
+ # 停止收集数据
67
+ def stop!
68
+ hset('status', 'running', false)
69
+ end
70
+
58
71
  def method_missing(method, *args)
59
72
  instance.send(method, *args)
60
73
  rescue NoMethodError
@@ -1,3 +1,3 @@
1
1
  module SimpleApm
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_apm
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
  - yuanyin.xia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,28 +28,28 @@ dependencies:
28
28
  name: redis-namespace
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: callsite
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.0'
55
55
  description: 'xyy: Simple Apm View for rails using redis.'