Statful client for Ruby applications using Aspect-Oriented Programming.
Staful client for Ruby usgin AOP. This client is intended to gather metrics and send them to Statful.
Tested Ruby versions |
---|
2.1.8 , 2.2.4 , 2.3.0 |
$ gem install statful-client-aop
This gem requires a valid initialized statful client - refer to the documentation on how to do it.
require 'statful-client-aop'
config = {
:transport => 'http',
:token => 'test_token',
}
statful = StatfulClient.new(config)
statful_aspects = StatfulAspects.new(statful)
Creates a simple client configuration and use it to send some metrics.
# consider statful_aspects is an instance of the previously created StatfulAspects
class MyClass
# measure how long my_method takes to execute in ms
# save it as a metric timer called 'execution' with a custom tag
statful_aspects.timer(self, 'my_method', 'execution', { :tags => {:host => 'test_host', :status => 'SUCCESS' } })
def my_method
# do stuff
end
end
Detailed reference if you want to take full advantage from Statful.
The custom options that can be set on config param are detailed below.
Option | Description | Type | Default | Required |
---|---|---|---|---|
statful | Initialized Statful client to be used on annotations. | Object |
none | YES |
- staful_aspects.timer(myClass, 'my_method', 'my_metric_name', { :namespace => 'sandbox' });
Arguments for the timer
method are much like the timer
method from the Ruby client with the exceptions:
- the first argument is the class [
Object
] of the method to be annotated - the second argument is the name [
String
] of the method to be annotated - not possible to set a value for the timer
Use bundle to install all dev dependencies:
$ bundle install
It uses rspec and minitest to specify the unit tests suite.
There's a rake task which runs the specs:
$ rake spec
Use gem to build a gem according to the spec if required:
$ gem build statful-client-aop.gemspec
It uses yard to generate documentation.
There's a rake task which generates the doc directory with the output:
$ rake yard
Statful Client For Ruby using AOP is available under the MIT license. See the LICENSE file for more information.