leafy-rack 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +34 -4
- data/.travis.yml +19 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -8
- data/README.md +10 -148
- data/examples/datadog/.gitignore +2 -0
- data/examples/datadog/Gemfile +12 -0
- data/examples/datadog/Mavenfile +22 -0
- data/examples/datadog/README.md +16 -0
- data/examples/datadog/lib/java_gauge.rb +20 -0
- data/examples/datadog/lib/metrics.rb +18 -0
- data/examples/datadog/lib/ruby_gauge.rb +19 -0
- data/examples/hellowarld/.gitignore +3 -0
- data/examples/hellowarld/Gemfile +15 -0
- data/examples/hellowarld/Mavenfile +162 -0
- data/examples/hellowarld/README.md +44 -0
- data/examples/hellowarld/Rakefile +13 -0
- data/examples/hellowarld/WEB-INF/web.xml +31 -0
- data/examples/hellowarld/app/hellowarld.rb +55 -0
- data/examples/hellowarld/app/views/person.erb +52 -0
- data/examples/hellowarld/config.ru +12 -0
- data/leafy-complete.gemspec +22 -0
- data/leafy-health/.gitignore +4 -0
- data/leafy-health/Gemfile +7 -0
- data/leafy-health/LICENSE +22 -0
- data/leafy-health/README.md +123 -0
- data/leafy-health/Rakefile +14 -0
- data/leafy-health/leafy-health.gemspec +27 -0
- data/leafy-health/lib/leafy-health.rb +2 -0
- data/leafy-health/lib/leafy-health_jars.rb +7 -0
- data/leafy-health/lib/leafy/health.rb +2 -0
- data/leafy-health/lib/leafy/health/health_check.rb +72 -0
- data/leafy-health/lib/leafy/health/registry.rb +55 -0
- data/leafy-health/lib/leafy/health/version.rb +6 -0
- data/leafy-health/spec/registry_spec.rb +164 -0
- data/leafy-health/spec/setup.rb +1 -0
- data/leafy-logger/.gitignore +5 -0
- data/leafy-logger/Gemfile +9 -0
- data/leafy-logger/LICENSE +22 -0
- data/leafy-logger/README.md +174 -0
- data/{Rakefile → leafy-logger/Rakefile} +0 -0
- data/leafy-logger/leafy-logger.gemspec +32 -0
- data/leafy-logger/lib/leafy-logger.rb +1 -0
- data/leafy-logger/lib/leafy-logger_jars.rb +33 -0
- data/leafy-logger/lib/leafy/logger.rb +1 -0
- data/leafy-logger/lib/leafy/logger/appender_factories.rb +89 -0
- data/leafy-logger/lib/leafy/logger/factory.rb +141 -0
- data/leafy-logger/lib/leafy/logger/version.rb +6 -0
- data/leafy-logger/spec/appender_factories_spec.rb +147 -0
- data/leafy-logger/spec/factory_spec.rb +176 -0
- data/leafy-logger/spec/logging.yml +16 -0
- data/leafy-logger/spec/setup.rb +2 -0
- data/leafy-metrics/.gitignore +5 -0
- data/leafy-metrics/Gemfile +7 -0
- data/leafy-metrics/LICENSE +22 -0
- data/leafy-metrics/README.md +221 -0
- data/leafy-metrics/Rakefile +14 -0
- data/leafy-metrics/leafy-metrics.gemspec +29 -0
- data/leafy-metrics/lib/leafy-metrics.rb +2 -0
- data/leafy-metrics/lib/leafy-metrics_jars.rb +5 -0
- data/leafy-metrics/lib/leafy/metrics.rb +2 -0
- data/leafy-metrics/lib/leafy/metrics/console_reporter.rb +32 -0
- data/leafy-metrics/lib/leafy/metrics/csv_reporter.rb +26 -0
- data/leafy-metrics/lib/leafy/metrics/graphite/graphite.rb +28 -0
- data/leafy-metrics/lib/leafy/metrics/graphite/graphite_reporter.rb +43 -0
- data/leafy-metrics/lib/leafy/metrics/registry.rb +108 -0
- data/leafy-metrics/lib/leafy/metrics/reporter.rb +51 -0
- data/leafy-metrics/lib/leafy/metrics/version.rb +6 -0
- data/leafy-metrics/spec/console_reporter_spec.rb +72 -0
- data/leafy-metrics/spec/csv_reporter_spec.rb +75 -0
- data/leafy-metrics/spec/graphite_reporter_spec.rb +72 -0
- data/leafy-metrics/spec/graphite_spec.rb +23 -0
- data/leafy-metrics/spec/registry_spec.rb +106 -0
- data/leafy-metrics/spec/setup.rb +10 -0
- data/leafy-rack/.gitignore +4 -0
- data/leafy-rack/Gemfile +10 -0
- data/leafy-rack/LICENSE +22 -0
- data/leafy-rack/README.md +155 -0
- data/leafy-rack/Rakefile +14 -0
- data/{leafy-rack.gemspec → leafy-rack/leafy-rack.gemspec} +2 -2
- data/{lib → leafy-rack/lib}/leafy-rack.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy-rack_jars.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/instrumented/basic_instrumented.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/instrumented/instrumented.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/json/health_writer.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/json/json_writer.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/json/metrics_writer.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/admin.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/health.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/instrumented.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/metrics.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/ping.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/thread_dump.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/version.rb +1 -1
- data/{spec → leafy-rack/spec}/admin_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/basic_instrumented_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/health_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/health_writer_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/instrumented_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/instrumented_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/metrics_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/metrics_writer_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/ping_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/setup.rb +0 -0
- data/{spec → leafy-rack/spec}/thread_dump_spec.rb +0 -0
- metadata +110 -34
@@ -0,0 +1,176 @@
|
|
1
|
+
require_relative 'setup'
|
2
|
+
require 'leafy/metrics/registry'
|
3
|
+
require 'leafy/logger/factory'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
describe Leafy::Logger::Factory do
|
7
|
+
|
8
|
+
subject do
|
9
|
+
f = Leafy::Logger::Factory.new
|
10
|
+
f.appenders( Leafy::Logger::FileAppenderFactory.new( log ) )
|
11
|
+
f.configure( Leafy::Metrics::Registry.new, 'tester' )
|
12
|
+
f
|
13
|
+
end
|
14
|
+
|
15
|
+
let( :log ) { File.join( File.dirname( __FILE__ ), 'test.log' ) }
|
16
|
+
let( :yaml ) { File.join( File.dirname( __FILE__ ), 'logging.yml' ) }
|
17
|
+
let( :logger1 ) { Leafy::Logger::Factory.get_logger 'my.app' }
|
18
|
+
let( :logger2 ) { Leafy::Logger::Factory.get_logger 'my.db' }
|
19
|
+
|
20
|
+
let( :factory_yaml ) { Leafy::Logger::Factory.new_from_yaml( yaml ) }
|
21
|
+
let( :reconfigured_yaml ) do
|
22
|
+
subject.reconfigure_from_yaml( yaml )
|
23
|
+
subject
|
24
|
+
end
|
25
|
+
|
26
|
+
let( :options ) { YAML.load( File.read( yaml ) ) }
|
27
|
+
let( :factory_options ) { Leafy::Logger::Factory.new_from_options( options ) }
|
28
|
+
let( :reconfigured_options ) do
|
29
|
+
subject.reconfigure_from_options( options )
|
30
|
+
subject
|
31
|
+
end
|
32
|
+
|
33
|
+
before { FileUtils.rm_f log }
|
34
|
+
after { FileUtils.rm_f log }
|
35
|
+
|
36
|
+
it 'can set appenders' do
|
37
|
+
expect( subject.appenders.size ).to eq 1
|
38
|
+
|
39
|
+
subject.appenders Leafy::Logger::ConsoleAppenderFactory.new
|
40
|
+
expect( subject.appenders.size ).to eq 1
|
41
|
+
|
42
|
+
subject.appenders( Leafy::Logger::ConsoleAppenderFactory.new,
|
43
|
+
Leafy::Logger::FileAppenderFactory.new( log ) )
|
44
|
+
expect( subject.appenders.size ).to eq 2
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'sets the default level' do
|
48
|
+
subject.level = 'INFO'
|
49
|
+
expect( subject.level ).to eq 'INFO'
|
50
|
+
|
51
|
+
subject.level 'DEBUG'
|
52
|
+
expect( subject.level ).to eq 'DEBUG'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'can set the default log level' do
|
56
|
+
subject.level = 'INFO'
|
57
|
+
|
58
|
+
logger1.debug 'debug1'
|
59
|
+
logger1.info 'good'
|
60
|
+
logger1.warn 'good'
|
61
|
+
logger2.debug 'debug2'
|
62
|
+
logger2.info 'good'
|
63
|
+
logger2.warn 'good'
|
64
|
+
|
65
|
+
subject.stop
|
66
|
+
|
67
|
+
lines = File.read( log ).split( /\n/ )
|
68
|
+
|
69
|
+
expect( lines.size ).to eq 4
|
70
|
+
lines.each do |line|
|
71
|
+
expect( line ).to match /INFO|WARN/
|
72
|
+
expect( line ).to match /good/
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'can set a specific log level' do
|
77
|
+
expect( subject.loggers ).to eq Hash[]
|
78
|
+
|
79
|
+
subject[ 'my.app' ] = 'WARN'
|
80
|
+
|
81
|
+
expect( subject.loggers ).to eq Hash[ 'my.app' => 'WARN' ]
|
82
|
+
|
83
|
+
logger1.debug 'debug1'
|
84
|
+
logger1.info 'info1'
|
85
|
+
logger1.warn 'good'
|
86
|
+
logger2.debug 'debug2'
|
87
|
+
logger2.info 'good'
|
88
|
+
logger2.warn 'good'
|
89
|
+
|
90
|
+
subject.stop
|
91
|
+
|
92
|
+
lines = File.read( log ).split( /\n/ )
|
93
|
+
|
94
|
+
expect( lines.size ).to eq 3
|
95
|
+
lines.each do |line|
|
96
|
+
expect( line ).to match /INFO|WARN/
|
97
|
+
expect( line ).to match /good/
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'can set a specific log level' do
|
102
|
+
expect( subject.loggers ).to eq Hash[]
|
103
|
+
|
104
|
+
subject.loggers( 'my' => 'WARN' )
|
105
|
+
|
106
|
+
expect( subject.loggers ).to eq Hash[ 'my' => 'WARN' ]
|
107
|
+
|
108
|
+
logger1.debug 'debug1'
|
109
|
+
logger1.info 'info1'
|
110
|
+
logger1.warn 'good'
|
111
|
+
logger2.debug 'debug2'
|
112
|
+
logger2.info 'info2'
|
113
|
+
logger2.warn 'good'
|
114
|
+
|
115
|
+
subject.stop
|
116
|
+
|
117
|
+
lines = File.read( log ).split( /\n/ )
|
118
|
+
|
119
|
+
expect( lines.size ).to eq 2
|
120
|
+
lines.each do |line|
|
121
|
+
expect( line ).to match /WARN/
|
122
|
+
expect( line ).to match /good/
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'fails on missing yaml configuration' do
|
128
|
+
expect {Leafy::Logger::Factory.new_from_yaml( yaml + '.gone' ) }.to raise_error( Exception )
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'fails reconfigure on missing yaml configuration' do
|
132
|
+
expect {subject.reconfigure_from_yaml( yaml + '.gone' ) }.to raise_error( Exception )
|
133
|
+
end
|
134
|
+
|
135
|
+
[ :factory_yaml, :reconfigured_yaml ].each do |method|
|
136
|
+
it "can use a yaml configuration - #{method}" do
|
137
|
+
f = send( method )
|
138
|
+
expect( f.level ).to eq 'ERROR'
|
139
|
+
expect( f.loggers ).to eq 'com.example.app' => 'DEBUG'
|
140
|
+
expect( f.appenders.size ).to eq 3
|
141
|
+
# console
|
142
|
+
expect( f.appenders[0].threshold ).to eq 'DEBUG'
|
143
|
+
expect( f.appenders[0].target ).to eq 'STDERR'
|
144
|
+
# file
|
145
|
+
expect( f.appenders[1].threshold ).to eq 'INFO'
|
146
|
+
expect( f.appenders[1].current_log_filename ).to eq './logs/example.log'
|
147
|
+
expect( f.appenders[1].archived_log_filename_pattern ).to eq './logs/example-%d.log.gz'
|
148
|
+
expect( f.appenders[1].archived_file_count ).to eq 12
|
149
|
+
# syslog
|
150
|
+
expect( f.appenders[2].host ).to eq '127.0.0.1'
|
151
|
+
expect( f.appenders[2].port ).to eq 123
|
152
|
+
expect( f.appenders[2].facility ).to eq 'KERN'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
[ :factory_options, :reconfigured_options ].each do |method|
|
157
|
+
it 'can use a hash configuration' do
|
158
|
+
f = send( method )
|
159
|
+
expect( f.level ).to eq 'ERROR'
|
160
|
+
expect( f.loggers ).to eq 'com.example.app' => 'DEBUG'
|
161
|
+
expect( f.appenders.size ).to eq 3
|
162
|
+
# console
|
163
|
+
expect( f.appenders[0].threshold ).to eq 'DEBUG'
|
164
|
+
expect( f.appenders[0].target ).to eq 'STDERR'
|
165
|
+
# file
|
166
|
+
expect( f.appenders[1].threshold ).to eq 'INFO'
|
167
|
+
expect( f.appenders[1].current_log_filename ).to eq './logs/example.log'
|
168
|
+
expect( f.appenders[1].archived_log_filename_pattern ).to eq './logs/example-%d.log.gz'
|
169
|
+
expect( f.appenders[1].archived_file_count ).to eq 12
|
170
|
+
# syslog
|
171
|
+
expect( f.appenders[2].host ).to eq '127.0.0.1'
|
172
|
+
expect( f.appenders[2].port ).to eq 123
|
173
|
+
expect( f.appenders[2].facility ).to eq 'KERN'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
level: ERROR
|
2
|
+
loggers:
|
3
|
+
com.example.app: DEBUG
|
4
|
+
appenders:
|
5
|
+
- type: console
|
6
|
+
threshold: DEBUG
|
7
|
+
target: STDERR
|
8
|
+
- type: file
|
9
|
+
threshold: INFO
|
10
|
+
currentLogFilename: ./logs/example.log
|
11
|
+
archivedLogFilenamePattern: ./logs/example-%d.log.gz
|
12
|
+
archivedFileCount: 12
|
13
|
+
- type: syslog
|
14
|
+
host: 127.0.0.1
|
15
|
+
port: 123
|
16
|
+
facility: KERN
|
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Lookout
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
@@ -0,0 +1,221 @@
|
|
1
|
+
# Leafy-Metrics
|
2
|
+
|
3
|
+
## installation
|
4
|
+
|
5
|
+
via rubygems
|
6
|
+
```
|
7
|
+
gem install leafy-metrics
|
8
|
+
```
|
9
|
+
or add to your Gemfile
|
10
|
+
```
|
11
|
+
gem 'leafy-metrics'
|
12
|
+
```
|
13
|
+
|
14
|
+
installing the gem also takes care of the jar dependencies with jruby-1.7.16+
|
15
|
+
|
16
|
+
## usage
|
17
|
+
|
18
|
+
an instance of the registry ```Leafy::Metrics::Registry``` can register various metrics like gauge, timer, meter, counter and histogram and remove them again.
|
19
|
+
|
20
|
+
registry = Leafy::Metrics::Registry.new
|
21
|
+
|
22
|
+
### gauge
|
23
|
+
|
24
|
+
it can be other a given block or any object with a #call method returning the gauge - a number
|
25
|
+
|
26
|
+
registry.register_gauge( 'app.uptime') do
|
27
|
+
App.uptime
|
28
|
+
end
|
29
|
+
|
30
|
+
or with an object
|
31
|
+
|
32
|
+
class UptimeGauge
|
33
|
+
def call
|
34
|
+
App.uptime
|
35
|
+
enf
|
36
|
+
end
|
37
|
+
registry.register_gauge( 'app.uptime', UptimeGauge.new )
|
38
|
+
|
39
|
+
### timer
|
40
|
+
|
41
|
+
a timer can measure the time an block needs to execute:
|
42
|
+
|
43
|
+
timer = registry.register_timer( 'app.timer' )
|
44
|
+
timer.time do
|
45
|
+
App.update_data
|
46
|
+
end
|
47
|
+
|
48
|
+
### counter
|
49
|
+
|
50
|
+
a counter simply counts i.e. can be incremented or decremented
|
51
|
+
|
52
|
+
counter = registry.register_counter( 'active.users.counter' )
|
53
|
+
|
54
|
+
# one new user logged on
|
55
|
+
counter.inc
|
56
|
+
|
57
|
+
# three new users logged on
|
58
|
+
counter.inc 3
|
59
|
+
|
60
|
+
# one user logged off
|
61
|
+
counter.dec
|
62
|
+
|
63
|
+
# two users logged off
|
64
|
+
counter.dec 2
|
65
|
+
|
66
|
+
### meter
|
67
|
+
|
68
|
+
used = registry.register_meter( 'app.used' )
|
69
|
+
|
70
|
+
mark the occurrence of an event
|
71
|
+
|
72
|
+
used.mark
|
73
|
+
|
74
|
+
mark the occurrence of 'n' events
|
75
|
+
|
76
|
+
used.mark n
|
77
|
+
|
78
|
+
|
79
|
+
### histogram
|
80
|
+
|
81
|
+
measures the distribution of values in a stream of data using an exponentially decaying reservoir
|
82
|
+
|
83
|
+
histogram = registry.register_histogram( 'search.results' )
|
84
|
+
histogram.update( Search.last_result.size )
|
85
|
+
|
86
|
+
### remove any metrics
|
87
|
+
|
88
|
+
registry.unregister( 'app.uptime )
|
89
|
+
|
90
|
+
### note
|
91
|
+
|
92
|
+
currently there is not further introspection on the registry and its health-check. with the ```Leafy::Json::MetricsWriter``` (from leafy-rack) you can get a json representation of the current **metrics report**
|
93
|
+
|
94
|
+
Leafy::Json::MetricsWriter.to_json( registry.metrics )
|
95
|
+
|
96
|
+
## reporters
|
97
|
+
|
98
|
+
all reporters use a builder pattern. there are following timeunits for
|
99
|
+
configuration:
|
100
|
+
|
101
|
+
* ```Leafy::Metrics::Reporter::DAYS```
|
102
|
+
* ```Leafy::Metrics::Reporter::HOURS```
|
103
|
+
* ```Leafy::Metrics::Reporter::MINUTES```
|
104
|
+
* ```Leafy::Metrics::Reporter::SECONDS```
|
105
|
+
* ```Leafy::Metrics::Reporter::MILLISECONDS```
|
106
|
+
* ```Leafy::Metrics::Reporter::MICROSECONDS```
|
107
|
+
* ```Leafy::Metrics::Reporter::NANOSECONDS```
|
108
|
+
|
109
|
+
in all examples below ```metrics = Leafy::Metrics::Registry.new```
|
110
|
+
|
111
|
+
### console reporter
|
112
|
+
|
113
|
+
require 'leafy/metrics/console_reporter'
|
114
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::ConsoleReporter ).build
|
115
|
+
reporter.start( 1, Leafy::Metrics::Reporter::SECONDS )
|
116
|
+
....
|
117
|
+
reporter.stop
|
118
|
+
|
119
|
+
or with all the possible configuration
|
120
|
+
|
121
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::ConsoleReporter )
|
122
|
+
.convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
123
|
+
.convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
124
|
+
.output_to( STDERR )
|
125
|
+
.build
|
126
|
+
|
127
|
+
or the config via a block
|
128
|
+
|
129
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::ConsoleReporter ) do
|
130
|
+
convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
131
|
+
convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
132
|
+
output_to( STDERR )
|
133
|
+
end.build
|
134
|
+
|
135
|
+
### csv reporter
|
136
|
+
|
137
|
+
for each metric there will be a CSV file inside a given directory
|
138
|
+
|
139
|
+
require 'leafy/metrics/csv_reporter'
|
140
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::CSVReporter )
|
141
|
+
.build( 'metrics/directory' )
|
142
|
+
reporter.start( 1, Leafy::Metrics::Reporter::SECONDS )
|
143
|
+
....
|
144
|
+
reporter.stop
|
145
|
+
|
146
|
+
or with all possible configuration
|
147
|
+
|
148
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::CSVReporter )
|
149
|
+
.convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
150
|
+
.convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
151
|
+
.build( 'metrics/directory' )
|
152
|
+
|
153
|
+
or configuration via block
|
154
|
+
|
155
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::CSVReporter ) do
|
156
|
+
convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
157
|
+
convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
158
|
+
end.build( 'metrics/directory' )
|
159
|
+
|
160
|
+
### graphite reporter
|
161
|
+
|
162
|
+
there are three targets where to send the data
|
163
|
+
|
164
|
+
* ```Leafy::Metrics::Graphite.new_tcp( hostname, port )```
|
165
|
+
* ```Leafy::Metrics::Graphite.new_udp( hostname, port )```
|
166
|
+
* ```Leafy::Metrics::Graphite.new_pickled( hostname, port, batchsize )```
|
167
|
+
|
168
|
+
the latter is collecting a few report event and sends them as batch. the ```sender``` is one of the above targets.
|
169
|
+
|
170
|
+
require 'leafy/metrics/graphite_reporter'
|
171
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::GraphiteReporter )
|
172
|
+
.build_tcp( hostname, port )
|
173
|
+
reporter.start( 1, Leafy::Metrics::Reporter::SECONDS )
|
174
|
+
....
|
175
|
+
reporter.stop
|
176
|
+
|
177
|
+
or with full configuration
|
178
|
+
|
179
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::GraphiteReporter )
|
180
|
+
.convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
181
|
+
.convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
182
|
+
.prefixed_with( 'myapp' )
|
183
|
+
.build( sender )
|
184
|
+
|
185
|
+
or with block configuration
|
186
|
+
|
187
|
+
reporter = metrics.reporter_builder( Leafy::Metrics::GraphiteReporter ) do
|
188
|
+
convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
189
|
+
convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
190
|
+
prefixed_with( 'myapp' )
|
191
|
+
end.build_udp( host, port )
|
192
|
+
|
193
|
+
### any third party reporter
|
194
|
+
|
195
|
+
reporter = metrics.reporter_builder( com.readytalk.metrics.StatsDReporter ) do
|
196
|
+
convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
197
|
+
convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
198
|
+
end.build( host, port )
|
199
|
+
|
200
|
+
or using the Java module reference
|
201
|
+
|
202
|
+
reporter = metrics.reporter_builder( Java::ComReadytalkMetrics::StatsDReporter ) do
|
203
|
+
convert_rates_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
204
|
+
convert_durations_to( Leafy::Metrics::Reporter::MILLISECONDS )
|
205
|
+
prefixed_with( 'app' )
|
206
|
+
end.build( host, port )
|
207
|
+
|
208
|
+
## developement
|
209
|
+
|
210
|
+
get all the gems and jars in place
|
211
|
+
|
212
|
+
gem install jar-dependencies --development
|
213
|
+
bundle install
|
214
|
+
|
215
|
+
for running all specs
|
216
|
+
|
217
|
+
rake
|
218
|
+
|
219
|
+
or
|
220
|
+
|
221
|
+
rspec spec/reporter_spec.rb
|