fozzie 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,79 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
- <title>hash.rb</title>
6
- <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
- </head>
8
- <body>
9
- <div id='container'>
10
- <div id="background"></div>
11
- <div id="jump_to">
12
- Jump To &hellip;
13
- <div id="jump_wrapper">
14
- <div id="jump_page">
15
- <a class="source" href="hash.html">hash.rb</a>
16
- <a class="source" href="../fozzie.html">fozzie.rb</a>
17
- <a class="source" href="../fozzie/configuration.html">configuration.rb</a>
18
- <a class="source" href="../fozzie/interface.html">interface.rb</a>
19
- <a class="source" href="../fozzie/rack/middleware.html">middleware.rb</a>
20
- <a class="source" href="../fozzie/rails/middleware.html">middleware.rb</a>
21
- <a class="source" href="../fozzie/socket.html">socket.rb</a>
22
- <a class="source" href="../fozzie/version.html">version.rb</a>
23
- </div>
24
- </div>
25
- </div>
26
- <table cellspacing=0 cellpadding=0>
27
- <thead>
28
- <tr>
29
- <th class=docs><h1>hash.rb</h1></th>
30
- <th class=code></th>
31
- </tr>
32
- </thead>
33
- <tbody>
34
- <tr id='section-1'>
35
- <td class=docs>
36
- <div class="pilwrap">
37
- <a class="pilcrow" href="#section-1">&#182;</a>
38
- </div>
39
-
40
- </td>
41
- <td class=code>
42
- <div class='highlight'><pre><span class="k">class</span> <span class="nc">Hash</span></pre></div>
43
- </td>
44
- </tr>
45
- <tr id='section-2'>
46
- <td class=docs>
47
- <div class="pilwrap">
48
- <a class="pilcrow" href="#section-2">&#182;</a>
49
- </div>
50
- <p>Return self as symbolized keys hash</p>
51
- </td>
52
- <td class=code>
53
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">symbolize_keys</span>
54
- <span class="nb">self</span><span class="o">.</span><span class="n">dup</span><span class="o">.</span><span class="n">inject</span><span class="p">({})</span> <span class="k">do</span> <span class="o">|</span><span class="n">hsh</span><span class="p">,</span> <span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v</span><span class="p">)</span><span class="o">|</span>
55
- <span class="n">hsh</span><span class="o">[</span><span class="n">k</span><span class="o">.</span><span class="n">to_s</span><span class="o">.</span><span class="n">to_sym</span><span class="o">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">v</span><span class="o">.</span><span class="n">respond_to?</span><span class="p">(</span><span class="ss">:symbolize_keys</span><span class="p">)</span> <span class="p">?</span> <span class="n">v</span><span class="o">.</span><span class="n">symbolize_keys</span> <span class="p">:</span> <span class="n">v</span><span class="p">)</span>
56
- <span class="n">hsh</span>
57
- <span class="k">end</span>
58
- <span class="k">end</span></pre></div>
59
- </td>
60
- </tr>
61
- <tr id='section-3'>
62
- <td class=docs>
63
- <div class="pilwrap">
64
- <a class="pilcrow" href="#section-3">&#182;</a>
65
- </div>
66
- <p>Replace self with symbolized keys hash</p>
67
-
68
- </td>
69
- <td class=code>
70
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">symbolize_keys!</span>
71
- <span class="nb">self</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="nb">self</span><span class="o">.</span><span class="n">symbolize_keys</span><span class="p">)</span>
72
- <span class="k">end</span>
73
-
74
- <span class="k">end</span></pre></div>
75
- </td>
76
- </tr>
77
- </table>
78
- </div>
79
- </body>
data/doc/lib/fozzie.html DELETED
@@ -1,152 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
- <title>fozzie.rb</title>
6
- <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
- </head>
8
- <body>
9
- <div id='container'>
10
- <div id="background"></div>
11
- <div id="jump_to">
12
- Jump To &hellip;
13
- <div id="jump_wrapper">
14
- <div id="jump_page">
15
- <a class="source" href="core_ext/hash.html">hash.rb</a>
16
- <a class="source" href="fozzie.html">fozzie.rb</a>
17
- <a class="source" href="fozzie/configuration.html">configuration.rb</a>
18
- <a class="source" href="fozzie/interface.html">interface.rb</a>
19
- <a class="source" href="fozzie/rack/middleware.html">middleware.rb</a>
20
- <a class="source" href="fozzie/rails/middleware.html">middleware.rb</a>
21
- <a class="source" href="fozzie/socket.html">socket.rb</a>
22
- <a class="source" href="fozzie/version.html">version.rb</a>
23
- </div>
24
- </div>
25
- </div>
26
- <table cellspacing=0 cellpadding=0>
27
- <thead>
28
- <tr>
29
- <th class=docs><h1>fozzie.rb</h1></th>
30
- <th class=code></th>
31
- </tr>
32
- </thead>
33
- <tbody>
34
- <tr id='section-1'>
35
- <td class=docs>
36
- <div class="pilwrap">
37
- <a class="pilcrow" href="#section-1">&#182;</a>
38
- </div>
39
- <p>Fozzie is an implementation of the Statsd statistics gathering tool,
40
- designed to make gathering stastistics from applications easy, fast, and effective.</p>
41
-
42
- <p>Configuration can be applied through a block and/or configuration file (&lsquo;config/fozzie.yml&rsquo;)</p>
43
-
44
- <p>Fozzie provides automatic namespacing for the current environment, and host.</p>
45
-
46
- <p>Rack and Rails middleware is avaliable to gather statistics on the processing time of Controller actions.</p>
47
- </td>
48
- <td class=code>
49
- <div class='highlight'><pre><span class="k">module</span> <span class="nn">Fozzie</span>
50
-
51
- <span class="nb">require</span> <span class="s1">&#39;fozzie/configuration&#39;</span>
52
- <span class="nb">require</span> <span class="s2">&quot;fozzie/interface&quot;</span>
53
- <span class="nb">require</span> <span class="s2">&quot;fozzie/version&quot;</span>
54
-
55
- <span class="nb">require</span> <span class="s2">&quot;fozzie/rack/middleware&quot;</span>
56
- <span class="nb">require</span> <span class="s2">&quot;fozzie/rails/middleware&quot;</span>
57
-
58
- <span class="k">class</span> <span class="o">&lt;&lt;</span> <span class="nb">self</span></pre></div>
59
- </td>
60
- </tr>
61
- <tr id='section-2'>
62
- <td class=docs>
63
- <div class="pilwrap">
64
- <a class="pilcrow" href="#section-2">&#182;</a>
65
- </div>
66
- <p>Shortcut for <code>Fozzie.config</code></p>
67
- </td>
68
- <td class=code>
69
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">c</span>
70
- <span class="n">config</span>
71
- <span class="k">end</span></pre></div>
72
- </td>
73
- </tr>
74
- <tr id='section-3'>
75
- <td class=docs>
76
- <div class="pilwrap">
77
- <a class="pilcrow" href="#section-3">&#182;</a>
78
- </div>
79
- <p>Returns the current configuration. Creates configuration on first-time request</p>
80
- </td>
81
- <td class=code>
82
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">config</span>
83
- <span class="vi">@config</span> <span class="o">||=</span> <span class="no">Configuration</span><span class="o">.</span><span class="n">new</span>
84
- <span class="k">end</span></pre></div>
85
- </td>
86
- </tr>
87
- <tr id='section-4'>
88
- <td class=docs>
89
- <div class="pilwrap">
90
- <a class="pilcrow" href="#section-4">&#182;</a>
91
- </div>
92
- <p>Allows the setting on valudes against the configuration</p>
93
-
94
- <p><code>Fozzie.configure {|config| config.wat = :random }</code></p>
95
- </td>
96
- <td class=code>
97
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">configure</span>
98
- <span class="k">yield</span> <span class="n">c</span> <span class="k">if</span> <span class="nb">block_given?</span>
99
- <span class="k">end</span></pre></div>
100
- </td>
101
- </tr>
102
- <tr id='section-5'>
103
- <td class=docs>
104
- <div class="pilwrap">
105
- <a class="pilcrow" href="#section-5">&#182;</a>
106
- </div>
107
- <p>Set a logger</p>
108
-
109
- <p><code>Fozzie.logger = Logger.new(STDOUT)</code></p>
110
- </td>
111
- <td class=code>
112
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">logger</span><span class="o">=</span><span class="p">(</span><span class="n">logger</span><span class="p">)</span>
113
- <span class="vi">@logger</span> <span class="o">=</span> <span class="n">logger</span>
114
- <span class="k">end</span></pre></div>
115
- </td>
116
- </tr>
117
- <tr id='section-6'>
118
- <td class=docs>
119
- <div class="pilwrap">
120
- <a class="pilcrow" href="#section-6">&#182;</a>
121
- </div>
122
- <p>Accessor for logger</p>
123
-
124
- <p><code>Fozzie.logger.warn &lsquo;foo&rsquo;</code></p>
125
- </td>
126
- <td class=code>
127
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">logger</span>
128
- <span class="vi">@logger</span>
129
- <span class="k">end</span>
130
-
131
- <span class="k">end</span></pre></div>
132
- </td>
133
- </tr>
134
- <tr id='section-7'>
135
- <td class=docs>
136
- <div class="pilwrap">
137
- <a class="pilcrow" href="#section-7">&#182;</a>
138
- </div>
139
- <p>Loads each namespace for registering statistics</p>
140
-
141
- </td>
142
- <td class=code>
143
- <div class='highlight'><pre> <span class="nb">self</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">namespaces</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">klas</span><span class="o">|</span>
144
- <span class="no">Kernel</span><span class="o">.</span><span class="n">const_set</span><span class="p">(</span><span class="n">klas</span><span class="p">,</span> <span class="no">Interface</span><span class="o">.</span><span class="n">instance</span><span class="p">)</span> <span class="k">unless</span> <span class="nb">const_defined?</span><span class="p">(</span><span class="n">klas</span><span class="p">)</span>
145
- <span class="k">end</span>
146
-
147
- <span class="k">end</span></pre></div>
148
- </td>
149
- </tr>
150
- </table>
151
- </div>
152
- </body>
@@ -1,175 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
- <title>configuration.rb</title>
6
- <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
- </head>
8
- <body>
9
- <div id='container'>
10
- <div id="background"></div>
11
- <div id="jump_to">
12
- Jump To &hellip;
13
- <div id="jump_wrapper">
14
- <div id="jump_page">
15
- <a class="source" href="../core_ext/hash.html">hash.rb</a>
16
- <a class="source" href="../fozzie.html">fozzie.rb</a>
17
- <a class="source" href="configuration.html">configuration.rb</a>
18
- <a class="source" href="interface.html">interface.rb</a>
19
- <a class="source" href="rack/middleware.html">middleware.rb</a>
20
- <a class="source" href="rails/middleware.html">middleware.rb</a>
21
- <a class="source" href="socket.html">socket.rb</a>
22
- <a class="source" href="version.html">version.rb</a>
23
- </div>
24
- </div>
25
- </div>
26
- <table cellspacing=0 cellpadding=0>
27
- <thead>
28
- <tr>
29
- <th class=docs><h1>configuration.rb</h1></th>
30
- <th class=code></th>
31
- </tr>
32
- </thead>
33
- <tbody>
34
- <tr id='section-1'>
35
- <td class=docs>
36
- <div class="pilwrap">
37
- <a class="pilcrow" href="#section-1">&#182;</a>
38
- </div>
39
-
40
- </td>
41
- <td class=code>
42
- <div class='highlight'><pre><span class="nb">require</span> <span class="s1">&#39;yaml&#39;</span>
43
- <span class="nb">require</span> <span class="s1">&#39;core_ext/hash&#39;</span>
44
- <span class="nb">require</span> <span class="s1">&#39;sys/uname&#39;</span>
45
- <span class="nb">require</span> <span class="s1">&#39;timeout&#39;</span>
46
-
47
- <span class="k">module</span> <span class="nn">Fozzie</span></pre></div>
48
- </td>
49
- </tr>
50
- <tr id='section-2'>
51
- <td class=docs>
52
- <div class="pilwrap">
53
- <a class="pilcrow" href="#section-2">&#182;</a>
54
- </div>
55
- <p>Fozzie configuration allows assignment of global properties
56
- that will be used within the Fozzie codebase.</p>
57
- </td>
58
- <td class=code>
59
- <div class='highlight'><pre> <span class="k">class</span> <span class="nc">Configuration</span>
60
- <span class="kp">include</span> <span class="no">Sys</span>
61
-
62
- <span class="kp">attr_accessor</span> <span class="ss">:env</span><span class="p">,</span> <span class="ss">:config_path</span><span class="p">,</span> <span class="ss">:host</span><span class="p">,</span> <span class="ss">:port</span><span class="p">,</span> <span class="ss">:appname</span><span class="p">,</span> <span class="ss">:namespaces</span><span class="p">,</span> <span class="ss">:timeout</span>
63
-
64
- <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">args</span> <span class="o">=</span> <span class="p">{})</span>
65
- <span class="n">merge_and_assign_config</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
66
- <span class="nb">self</span><span class="o">.</span><span class="n">origin_name</span>
67
- <span class="k">end</span></pre></div>
68
- </td>
69
- </tr>
70
- <tr id='section-3'>
71
- <td class=docs>
72
- <div class="pilwrap">
73
- <a class="pilcrow" href="#section-3">&#182;</a>
74
- </div>
75
- <p>Returns the prefix for any stat requested to be registered</p>
76
- </td>
77
- <td class=code>
78
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">data_prefix</span>
79
- <span class="n">s</span> <span class="o">=</span> <span class="o">[</span><span class="n">appname</span><span class="p">,</span> <span class="n">origin_name</span><span class="p">,</span> <span class="n">env</span><span class="o">].</span><span class="n">collect</span> <span class="k">do</span> <span class="o">|</span><span class="n">s</span><span class="o">|</span>
80
- <span class="n">s</span><span class="o">.</span><span class="n">empty?</span> <span class="p">?</span> <span class="kp">nil</span> <span class="p">:</span> <span class="n">s</span><span class="o">.</span><span class="n">gsub</span><span class="p">(</span><span class="s1">&#39;.&#39;</span><span class="p">,</span> <span class="s1">&#39;-&#39;</span><span class="p">)</span>
81
- <span class="k">end</span><span class="o">.</span><span class="n">compact</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span>
82
- <span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">empty?</span> <span class="p">?</span> <span class="kp">nil</span> <span class="p">:</span> <span class="n">s</span><span class="p">)</span>
83
- <span class="k">end</span></pre></div>
84
- </td>
85
- </tr>
86
- <tr id='section-4'>
87
- <td class=docs>
88
- <div class="pilwrap">
89
- <a class="pilcrow" href="#section-4">&#182;</a>
90
- </div>
91
- <p>Returns the origin name of the current machine to register the stat against</p>
92
- </td>
93
- <td class=code>
94
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">origin_name</span>
95
- <span class="vi">@origin_name</span> <span class="o">||=</span> <span class="no">Uname</span><span class="o">.</span><span class="n">uname</span><span class="o">.</span><span class="n">nodename</span>
96
- <span class="k">end</span>
97
-
98
- <span class="kp">private</span></pre></div>
99
- </td>
100
- </tr>
101
- <tr id='section-5'>
102
- <td class=docs>
103
- <div class="pilwrap">
104
- <a class="pilcrow" href="#section-5">&#182;</a>
105
- </div>
106
- <p>Handle the merging of the given configuaration, and the default config.</p>
107
- </td>
108
- <td class=code>
109
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">merge_and_assign_config</span><span class="p">(</span><span class="n">args</span> <span class="o">=</span> <span class="p">{})</span>
110
- <span class="n">arg</span> <span class="o">=</span> <span class="nb">self</span><span class="o">.</span><span class="n">class</span><span class="o">.</span><span class="n">default_configuration</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">symbolize_keys</span><span class="p">)</span>
111
- <span class="n">arg</span><span class="o">.</span><span class="n">merge!</span><span class="p">(</span><span class="n">config_from_yaml</span><span class="p">(</span><span class="n">arg</span><span class="p">))</span>
112
- <span class="n">arg</span><span class="o">.</span><span class="n">each</span> <span class="p">{</span><span class="o">|</span><span class="n">a</span><span class="p">,</span><span class="n">v</span><span class="o">|</span> <span class="nb">self</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">#{</span><span class="n">a</span><span class="si">}</span><span class="s2">=&quot;</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="k">if</span> <span class="nb">self</span><span class="o">.</span><span class="n">respond_to?</span><span class="p">(</span><span class="n">a</span><span class="o">.</span><span class="n">to_sym</span><span class="p">)</span> <span class="p">}</span>
113
-
114
- <span class="n">arg</span>
115
- <span class="k">end</span></pre></div>
116
- </td>
117
- </tr>
118
- <tr id='section-6'>
119
- <td class=docs>
120
- <div class="pilwrap">
121
- <a class="pilcrow" href="#section-6">&#182;</a>
122
- </div>
123
- <p>Default configuration settings</p>
124
- </td>
125
- <td class=code>
126
- <div class='highlight'><pre> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">default_configuration</span>
127
- <span class="p">{</span>
128
- <span class="ss">:host</span> <span class="o">=&gt;</span> <span class="s1">&#39;127.0.0.1&#39;</span><span class="p">,</span>
129
- <span class="ss">:port</span> <span class="o">=&gt;</span> <span class="mi">8125</span><span class="p">,</span>
130
- <span class="ss">:config_path</span> <span class="o">=&gt;</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
131
- <span class="ss">:env</span> <span class="o">=&gt;</span> <span class="p">(</span><span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;RACK_ENV&#39;</span><span class="o">]</span> <span class="o">||</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;RAILS_ENV&#39;</span><span class="o">]</span> <span class="o">||</span> <span class="s1">&#39;development&#39;</span><span class="p">),</span>
132
- <span class="ss">:appname</span> <span class="o">=&gt;</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
133
- <span class="ss">:namespaces</span> <span class="o">=&gt;</span> <span class="sx">%w{Stats S Statistics Warehouse}</span><span class="p">,</span>
134
- <span class="ss">:timeout</span> <span class="o">=&gt;</span> <span class="mi">0</span><span class="o">.</span><span class="mi">5</span>
135
- <span class="p">}</span><span class="o">.</span><span class="n">dup</span>
136
- <span class="k">end</span></pre></div>
137
- </td>
138
- </tr>
139
- <tr id='section-7'>
140
- <td class=docs>
141
- <div class="pilwrap">
142
- <a class="pilcrow" href="#section-7">&#182;</a>
143
- </div>
144
- <p>Loads the configuration from YAML, if possible</p>
145
- </td>
146
- <td class=code>
147
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">config_from_yaml</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
148
- <span class="n">fp</span> <span class="o">=</span> <span class="n">full_config_path</span><span class="p">(</span><span class="n">args</span><span class="o">[</span><span class="ss">:config_path</span><span class="o">]</span><span class="p">)</span>
149
- <span class="k">return</span> <span class="p">{}</span> <span class="k">unless</span> <span class="no">File</span><span class="o">.</span><span class="n">exists?</span><span class="p">(</span><span class="n">fp</span><span class="p">)</span>
150
- <span class="n">cnf</span> <span class="o">=</span> <span class="no">YAML</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span><span class="o">[</span><span class="n">args</span><span class="o">[</span><span class="ss">:env</span><span class="o">]]</span>
151
- <span class="p">(</span><span class="n">cnf</span><span class="o">.</span><span class="n">kind_of?</span><span class="p">(</span><span class="no">Hash</span><span class="p">))</span> <span class="p">?</span> <span class="n">cnf</span><span class="o">.</span><span class="n">symbolize_keys</span> <span class="p">:</span> <span class="p">{}</span>
152
- <span class="k">end</span></pre></div>
153
- </td>
154
- </tr>
155
- <tr id='section-8'>
156
- <td class=docs>
157
- <div class="pilwrap">
158
- <a class="pilcrow" href="#section-8">&#182;</a>
159
- </div>
160
- <p>Returns the absolute file path for the Fozzie configuration, relative to the given path</p>
161
-
162
- </td>
163
- <td class=code>
164
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">full_config_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
165
- <span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="s1">&#39;config/fozzie.yml&#39;</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
166
- <span class="k">end</span>
167
-
168
- <span class="k">end</span>
169
-
170
- <span class="k">end</span></pre></div>
171
- </td>
172
- </tr>
173
- </table>
174
- </div>
175
- </body>
@@ -1,286 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
- <title>interface.rb</title>
6
- <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
- </head>
8
- <body>
9
- <div id='container'>
10
- <div id="background"></div>
11
- <div id="jump_to">
12
- Jump To &hellip;
13
- <div id="jump_wrapper">
14
- <div id="jump_page">
15
- <a class="source" href="../core_ext/hash.html">hash.rb</a>
16
- <a class="source" href="../fozzie.html">fozzie.rb</a>
17
- <a class="source" href="configuration.html">configuration.rb</a>
18
- <a class="source" href="interface.html">interface.rb</a>
19
- <a class="source" href="rack/middleware.html">middleware.rb</a>
20
- <a class="source" href="rails/middleware.html">middleware.rb</a>
21
- <a class="source" href="socket.html">socket.rb</a>
22
- <a class="source" href="version.html">version.rb</a>
23
- </div>
24
- </div>
25
- </div>
26
- <table cellspacing=0 cellpadding=0>
27
- <thead>
28
- <tr>
29
- <th class=docs><h1>interface.rb</h1></th>
30
- <th class=code></th>
31
- </tr>
32
- </thead>
33
- <tbody>
34
- <tr id='section-1'>
35
- <td class=docs>
36
- <div class="pilwrap">
37
- <a class="pilcrow" href="#section-1">&#182;</a>
38
- </div>
39
-
40
- </td>
41
- <td class=code>
42
- <div class='highlight'><pre><span class="nb">require</span> <span class="s1">&#39;singleton&#39;</span>
43
- <span class="nb">require</span> <span class="s1">&#39;fozzie/socket&#39;</span>
44
-
45
- <span class="k">module</span> <span class="nn">Fozzie</span>
46
- <span class="k">class</span> <span class="nc">Interface</span>
47
- <span class="kp">include</span> <span class="no">Fozzie</span><span class="o">::</span><span class="no">Socket</span><span class="p">,</span> <span class="no">Singleton</span></pre></div>
48
- </td>
49
- </tr>
50
- <tr id='section-2'>
51
- <td class=docs>
52
- <div class="pilwrap">
53
- <a class="pilcrow" href="#section-2">&#182;</a>
54
- </div>
55
- <p>Increments the given stat by one, with an optional sample rate</p>
56
-
57
- <p><code>Stats.increment &lsquo;wat&rsquo;</code></p>
58
- </td>
59
- <td class=code>
60
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">increment</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
61
- <span class="n">count</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
62
- <span class="k">end</span></pre></div>
63
- </td>
64
- </tr>
65
- <tr id='section-3'>
66
- <td class=docs>
67
- <div class="pilwrap">
68
- <a class="pilcrow" href="#section-3">&#182;</a>
69
- </div>
70
- <p>Decrements the given stat by one, with an optional sample rate</p>
71
-
72
- <p><code>Stats.decrement &lsquo;wat&rsquo;</code></p>
73
- </td>
74
- <td class=code>
75
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">decrement</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
76
- <span class="n">count</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
77
- <span class="k">end</span></pre></div>
78
- </td>
79
- </tr>
80
- <tr id='section-4'>
81
- <td class=docs>
82
- <div class="pilwrap">
83
- <a class="pilcrow" href="#section-4">&#182;</a>
84
- </div>
85
- <p>Registers a count for the given stat, with an optional sample rate</p>
86
-
87
- <p><code>Stats.count &lsquo;wat&rsquo;, 500</code></p>
88
- </td>
89
- <td class=code>
90
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">count</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
91
- <span class="nb">send</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
92
- <span class="k">end</span></pre></div>
93
- </td>
94
- </tr>
95
- <tr id='section-5'>
96
- <td class=docs>
97
- <div class="pilwrap">
98
- <a class="pilcrow" href="#section-5">&#182;</a>
99
- </div>
100
- <p>Registers a timing (in ms) for the given stat, with an optional sample rate</p>
101
-
102
- <p><code>Stats.timing &lsquo;wat&rsquo;, 500</code></p>
103
- </td>
104
- <td class=code>
105
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">timing</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">ms</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
106
- <span class="nb">send</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">ms</span><span class="p">,</span> <span class="s1">&#39;ms&#39;</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
107
- <span class="k">end</span></pre></div>
108
- </td>
109
- </tr>
110
- <tr id='section-6'>
111
- <td class=docs>
112
- <div class="pilwrap">
113
- <a class="pilcrow" href="#section-6">&#182;</a>
114
- </div>
115
- <p>Registers the time taken to complete a given block (in ms), with an optional sample rate</p>
116
-
117
- <p><code>Stats.time &lsquo;wat&rsquo; { # Do something&hellip; }</code></p>
118
- </td>
119
- <td class=code>
120
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">time</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
121
- <span class="n">start</span> <span class="o">=</span> <span class="no">Time</span><span class="o">.</span><span class="n">now</span>
122
- <span class="n">result</span> <span class="o">=</span> <span class="k">yield</span>
123
- <span class="n">timing</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="p">((</span><span class="no">Time</span><span class="o">.</span><span class="n">now</span> <span class="o">-</span> <span class="n">start</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1000</span><span class="p">)</span><span class="o">.</span><span class="n">round</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
124
- <span class="n">result</span>
125
- <span class="k">end</span></pre></div>
126
- </td>
127
- </tr>
128
- <tr id='section-7'>
129
- <td class=docs>
130
- <div class="pilwrap">
131
- <a class="pilcrow" href="#section-7">&#182;</a>
132
- </div>
133
- <p>Registers the time taken to complete a given block (in ms), with an optional sample rate</p>
134
-
135
- <p><code>Stats.time_to_do &lsquo;wat&rsquo; { # Do something, again&hellip; }</code></p>
136
- </td>
137
- <td class=code>
138
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">time_to_do</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
139
- <span class="n">time_for</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
140
- <span class="k">end</span></pre></div>
141
- </td>
142
- </tr>
143
- <tr id='section-8'>
144
- <td class=docs>
145
- <div class="pilwrap">
146
- <a class="pilcrow" href="#section-8">&#182;</a>
147
- </div>
148
- <p>Registers the time taken to complete a given block (in ms), with an optional sample rate</p>
149
-
150
- <p><code>Stats.time_for &lsquo;wat&rsquo; { # Do something, grrr&hellip; }</code></p>
151
- </td>
152
- <td class=code>
153
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">time_for</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
154
- <span class="n">time</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
155
- <span class="k">end</span></pre></div>
156
- </td>
157
- </tr>
158
- <tr id='section-9'>
159
- <td class=docs>
160
- <div class="pilwrap">
161
- <a class="pilcrow" href="#section-9">&#182;</a>
162
- </div>
163
- <p>Registers a commit</p>
164
-
165
- <p><code>Stats.commit</code></p>
166
- </td>
167
- <td class=code>
168
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">commit</span>
169
- <span class="n">event</span> <span class="ss">:commit</span>
170
- <span class="k">end</span></pre></div>
171
- </td>
172
- </tr>
173
- <tr id='section-10'>
174
- <td class=docs>
175
- <div class="pilwrap">
176
- <a class="pilcrow" href="#section-10">&#182;</a>
177
- </div>
178
- <p>Registers a commit</p>
179
-
180
- <p><code>Stats.commit</code></p>
181
- </td>
182
- <td class=code>
183
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">committed</span>
184
- <span class="n">commit</span>
185
- <span class="k">end</span></pre></div>
186
- </td>
187
- </tr>
188
- <tr id='section-11'>
189
- <td class=docs>
190
- <div class="pilwrap">
191
- <a class="pilcrow" href="#section-11">&#182;</a>
192
- </div>
193
- <p>Registers that the app has been built</p>
194
-
195
- <p><code>Stats.built</code></p>
196
- </td>
197
- <td class=code>
198
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">built</span>
199
- <span class="n">event</span> <span class="ss">:build</span>
200
- <span class="k">end</span></pre></div>
201
- </td>
202
- </tr>
203
- <tr id='section-12'>
204
- <td class=docs>
205
- <div class="pilwrap">
206
- <a class="pilcrow" href="#section-12">&#182;</a>
207
- </div>
208
- <p>Registers a build for the app</p>
209
-
210
- <p><code>Stats.build</code></p>
211
- </td>
212
- <td class=code>
213
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">build</span>
214
- <span class="n">built</span>
215
- <span class="k">end</span></pre></div>
216
- </td>
217
- </tr>
218
- <tr id='section-13'>
219
- <td class=docs>
220
- <div class="pilwrap">
221
- <a class="pilcrow" href="#section-13">&#182;</a>
222
- </div>
223
- <p>Registers a deployed status for the given app</p>
224
-
225
- <p><code>Stats.deployed &lsquo;watapp&rsquo;</code></p>
226
- </td>
227
- <td class=code>
228
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">deployed</span><span class="p">(</span><span class="n">app</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">)</span>
229
- <span class="n">event</span> <span class="ss">:deploy</span><span class="p">,</span> <span class="n">app</span>
230
- <span class="k">end</span></pre></div>
231
- </td>
232
- </tr>
233
- <tr id='section-14'>
234
- <td class=docs>
235
- <div class="pilwrap">
236
- <a class="pilcrow" href="#section-14">&#182;</a>
237
- </div>
238
- <p>Registers a deployment for the given app</p>
239
-
240
- <p><code>Stats.deploy &lsquo;watapp&rsquo;</code></p>
241
- </td>
242
- <td class=code>
243
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">deploy</span><span class="p">(</span><span class="n">app</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">)</span>
244
- <span class="n">deployed</span><span class="p">(</span><span class="n">app</span><span class="p">)</span>
245
- <span class="k">end</span></pre></div>
246
- </td>
247
- </tr>
248
- <tr id='section-15'>
249
- <td class=docs>
250
- <div class="pilwrap">
251
- <a class="pilcrow" href="#section-15">&#182;</a>
252
- </div>
253
- <p>Registers an increment on the result of the given boolean</p>
254
-
255
- <p><code>Stats.increment_on &lsquo;wat&rsquo;, wat.random?</code></p>
256
- </td>
257
- <td class=code>
258
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">increment_on</span><span class="p">(</span><span class="n">stat</span><span class="p">,</span> <span class="n">perf</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
259
- <span class="n">key</span> <span class="o">=</span> <span class="o">[</span><span class="n">stat</span><span class="p">,</span> <span class="p">(</span><span class="n">perf</span> <span class="p">?</span> <span class="s2">&quot;success&quot;</span> <span class="p">:</span> <span class="s2">&quot;fail&quot;</span><span class="p">)</span><span class="o">]</span>
260
- <span class="n">increment</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
261
- <span class="n">perf</span>
262
- <span class="k">end</span></pre></div>
263
- </td>
264
- </tr>
265
- <tr id='section-16'>
266
- <td class=docs>
267
- <div class="pilwrap">
268
- <a class="pilcrow" href="#section-16">&#182;</a>
269
- </div>
270
- <p>Register an event of any type</p>
271
-
272
- <p><code>Stats.event &lsquo;wat&rsquo;, &lsquo;app&rsquo;</code></p>
273
-
274
- </td>
275
- <td class=code>
276
- <div class='highlight'><pre> <span class="k">def</span> <span class="nf">event</span><span class="p">(</span><span class="n">type</span><span class="p">,</span> <span class="n">app</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">)</span>
277
- <span class="n">timing</span> <span class="o">[</span><span class="s2">&quot;event&quot;</span><span class="p">,</span> <span class="n">type</span><span class="o">.</span><span class="n">to_s</span><span class="p">,</span> <span class="n">app</span><span class="o">]</span><span class="p">,</span> <span class="no">Time</span><span class="o">.</span><span class="n">now</span><span class="o">.</span><span class="n">usec</span>
278
- <span class="k">end</span>
279
-
280
- <span class="k">end</span>
281
- <span class="k">end</span></pre></div>
282
- </td>
283
- </tr>
284
- </table>
285
- </div>
286
- </body>