No commit activity in last 3 years
No release in over 3 years
Statful Ruby Client for Aspect-Oriented Programming (https://www.statful.com)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Statful client for Ruby applications using Aspect-Oriented Programming

Statful client for Ruby applications using Aspect-Oriented Programming.

Build Status Gem Version

Staful client for Ruby usgin AOP. This client is intended to gather metrics and send them to Statful.

Table of Contents

  • Supported Versions of Ruby
  • Installation
  • Quick Start
  • Examples
  • Reference
  • Development
  • Authors
  • License

Supported Versions of Ruby

Tested Ruby versions
2.1.8, 2.2.4, 2.3.0

Installation

$ gem install statful-client-aop

Quick start

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)

Examples

Annotate method with a timer

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

Reference

Detailed reference if you want to take full advantage from Statful.

Global configuration

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

Timer

- 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

Development

Dependencies

Use bundle to install all dev dependencies:

$ bundle install

Tests

It uses rspec and minitest to specify the unit tests suite.

There's a rake task which runs the specs:

$ rake spec

Build

Use gem to build a gem according to the spec if required:

$ gem build statful-client-aop.gemspec

Docs

It uses yard to generate documentation.

There's a rake task which generates the doc directory with the output:

$ rake yard

Authors

Mindera - Software Craft

License

Statful Client For Ruby using AOP is available under the MIT license. See the LICENSE file for more information.