forked from ironmtntech/xrono
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_stats_app.rb
74 lines (60 loc) · 1.68 KB
/
my_stats_app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require "fnordmetric"
FnordMetric.namespace :myapp do
# numeric (delta) gauge, 1-hour tick
gauge :git_push_per_hour,
:tick => 1.hour.to_i,
:title => "Git Push Per Hour"
gauge :git_push_per_repo_daily,
:tick => 1.day.to_i,
:three_dimensional => true,
:title => "git pushes per repo daily"
gauge :git_push_per_branch_daily,
:tick => 1.day.to_i,
:three_dimensional => true,
:title => "git pushes per branch daily"
gauge :dashboard_views_per_minute,
:tick => 1.minute.to_i,
:title => "Dashboard Views per minute"
gauge :dashboard_views_per_second,
:tick => 1.second.to_i,
:title => "Dashboard Views per second"
# on every event like { _type: 'unicorn_seen' }
event(:dashboard_view) do
# increment the unicorns_seen_per_hour gauge by 1
incr :dashboard_views_per_minute
incr :dashboard_views_per_second
end
event(:git_push) do
incr :git_push_per_hour
incr_field :git_push_per_repo_daily, data[:repo]
incr_field :git_push_per_branch_daily, data[:branch]
end
# draw a timeline showing the gauges value, auto-refresh every 2s
widget 'Overview', {
:title => "Dashboard Views per minute",
:type => :timeline,
:gauges => :dashboard_views_per_minute,
:include_current => true,
:autoupdate => 2
}
widget 'Overview', {
:title => "Git Pushes per Hour",
:type => :timeline,
:gauges => :git_push_per_hour,
:include_current => true,
:autoupdate => 5
}
widget 'Overview', {
:title => "Most active repositories",
:type => :toplist,
:autoupdate => 20,
:gauges => [ :git_push_per_repo_daily ]
}
widget 'Overview', {
:title => "Most active branches",
:type => :toplist,
:autoupdate => 20,
:gauges => [ :git_push_per_branch_daily ]
}
end
FnordMetric.standalone