• Stars
    star
    498
  • Rank 88,494 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ˆ The friendly gem that instruments everything for you, like I would if I could.

nunes

The friendly gem that instruments everything for you, like I would if I could.

Why "nunes"?

Because I don't work for you, but even that could not stop me from trying to make it as easy as possible for you to instrument ALL THE THINGS.

Installation

Add this line to your application's Gemfile:

gem "nunes"

Or install it yourself as:

$ gem install nunes

Compatibility

  • = Ruby 2.0

  • Rails 4.2.x, 5.0.x

Note: you can use v0.3.1 is for rails 3.2.x support.

Usage

nunes works out of the box with instrumental app (my personal favorite) and statsd. All you need to do is subscribe using an instance of statsd or instrumental's agent and you are good to go.

With Instrumental

require "nunes"
I = Instrument::Agent.new(...)
Nunes.subscribe(I)

With Statsd

require "nunes"
statsd = Statsd.new(...)
Nunes.subscribe(statsd)

With Some Other Service

If you would like for nunes to work with some other service, you can easily make an adapter. Check out the existing adapters for examples. The key is to inherit from Nunes::Adapter and then convert the increment and timing methods to whatever the service requires.

What Can I Do For You?

If you are using nunes with Rails, I will subscribe to the following events:

  • process_action.action_controller
  • render_template.action_view
  • render_partial.action_view
  • deliver.action_mailer
  • receive.action_mailer
  • sql.active_record
  • cache_read.active_support
  • cache_generate.active_support
  • cache_fetch_hit.active_support
  • cache_write.active_support
  • cache_delete.active_support
  • cache_exist?.active_support

Whoa! You would do all that for me? Yep, I would. Because I care. Deeply.

Based on those events, you'll get metrics like this in instrumental and statsd:

Counters

  • action_controller.status.200
  • action_controller.format.html
  • action_controller.controller.Admin.PostsController.new.status.403
  • action_controller.controller.Admin.PostsController.index.format.json
  • active_support.cache.hit
  • active_support.cache.miss

Timers

  • action_controller.runtime.total
  • action_controller.runtime.view
  • action_controller.runtime.db
  • action_controller.controller.PostsController.index.runtime.total
  • action_controller.controller.PostsController.index.runtime.view
  • action_controller.controller.PostsController.index.runtime.db
  • action_controller.controller.PostsController.index.status.200
  • action_controller.controller.PostsController.index.format.html
  • action_view.template.app.views.posts.index.html.erb - where app.views.posts.index.html.erb is the path of the view file
  • action_view.partial.app.views.posts._post.html.erb - I can even do partials! woot woot!
  • action_mailer.deliver.PostMailer
  • action_mailer.receive.PostMailer
  • active_record.sql
  • active_record.sql.select
  • active_record.sql.insert
  • active_record.sql.update
  • active_record.sql.delete
  • active_support.cache.read
  • active_support.cache.fetch
  • active_support.cache.fetch_hit
  • active_support.cache.fetch_generate
  • active_support.cache.write
  • active_support.cache.delete
  • active_support.cache.exist

But wait, there's more!!!

In addition to doing all that automagical work for you, I also allow you to wrap your own code with instrumentation. I know, I know, sounds too good to be true.

class User < ActiveRecord::Base
  extend Nunes::Instrumentable

  # wrap save and instrument the timing of it
  instrument_method_time :save
end

This will instrument the timing of the User instance method save. What that means is when you do this:

user = User.new(name: 'NUNES!')
user.save

An event named instrument_method_time.nunes will be generated, which in turn is subscribed to and sent to whatever you used to send instrumentation to (statsd, instrumental, etc.). The metric name will default to class.method. For the example above, the metric name would be User.save. No fear, you can customize this.

class User < ActiveRecord::Base
  extend Nunes::Instrumentable

  # wrap save and instrument the timing of it
  instrument_method_time :save, 'crazy_town.save'
end

Passing a string as the second argument sets the name of the metric. You can also customize the name using a Hash as the second argument.

class User < ActiveRecord::Base
  extend Nunes::Instrumentable

  # wrap save and instrument the timing of it
  instrument_method_time :save, name: 'crazy_town.save'
end

In addition to name, you can also pass a payload that will get sent along with the generated event.

class User < ActiveRecord::Base
  extend Nunes::Instrumentable

  # wrap save and instrument the timing of it
  instrument_method_time :save, payload: {pay: "loading"}
end

If you subscribe to the event on your own, say to log some things, you'll get a key named :pay with a value of "loading" in the event's payload. Pretty neat, eh?

script/bootstrap

This script will get all the dependencies ready so you can start hacking on nunes.

# to learn more about script/bootstrap
script/bootstrap help

script/test

For your convenience, there is a script to run the tests. It will also perform script/bootstrap, which bundles and all that jazz.

# to learn more about script test
script/test help

script/watch

If you are like me, you are too lazy to continually run script/test. For this scenario, I have included script/watch, which will run script/test automatically anytime a relevant file changes.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

More Repositories

1

httparty

๐ŸŽ‰ Makes http fun again!
Ruby
5,789
star
2

flipper

๐Ÿฌ Beautiful, performant feature flags for Ruby.
Ruby
3,295
star
3

crack

Really simple JSON and XML parsing, ripped from Merb and Rails.
Ruby
539
star
4

fancy-zoom

[DEAD] Zoomy JavaScript based loosely on Fancy Zoom by Cabel Sasser.
JavaScript
475
star
5

canable

Simple Ruby authorization system.
Ruby
312
star
6

happymapper

[unmaintained] XML to object mapping library
Ruby
300
star
7

twitter-app

example rails 3 application that uses oauth
Ruby
132
star
8

joint

[DEAD AND UNMAINTAINED] MongoMapper and GridFS joined in file upload love.
Ruby
129
star
9

resilient

๐Ÿ”Œ circuit breaker based on netflix/hystrix but in ruby, hopefully commands/semaphores eventually too
Ruby
103
star
10

user_stamp

A Rails plugin that adds the ability to automatically stamp each record with the currently logged in user.
Ruby
84
star
11

flipper-ui

[MOVED] ... to main flipper repo. See readme.
67
star
12

google-weather

stupid simple fetching of the weather using google's api
Ruby
54
star
13

bin

DEAD AND UNMAINTAINED. ActiveSupport MongoDB Cache store.
Ruby
54
star
14

scrobbler

[DEAD] Scrobbler is a wrapper for the audioscrobbler (last.fm) web services.
Ruby
48
star
15

hunt

really simple search for mongomapper
Ruby
38
star
16

lorem

Ever get tired of opening up lipsum.com, filling out a form and waiting for it to give you your filler text? Yeah, me too. I threw this together in an hour to generate lipsum text from the command line.
Ruby
33
star
17

scam

Really basic fake model for doing types in memory
Ruby
32
star
18

dotfiles

Some of my dotfiles, nothing fancy or worthwhile
Shell
30
star
19

googlereader

[DEAD AND UNMAINTAINED] Wrapper for Google Reader's undocumented and possibly "unstable" API. By unstable, I mean if they haven't documented it, then they could change it at anytime without notice.
Ruby
28
star
20

cassanity

Brings sanity to CQL + Ruby.
Ruby
25
star
21

columbus

Autodiscovers feeds from urls
Ruby
24
star
22

gemwhois

Whois for gems, because gem names are like domains in the 90's
Ruby
23
star
23

googlebase

[DEAD] Google Base Auth Class is a base for authenticating to google and making requests to google services.
Ruby
21
star
24

brow

๐Ÿคจ A generic background thread worker for shipping events to some API backend.
Ruby
20
star
25

wand

Mime-Type gem with fallback to unix file command. You most likely don't need this gem.
Ruby
20
star
26

javascripts

[DEAD] some various js files and examples for me to refer to and use
JavaScript
17
star
27

stars

collects github.com stars from people you follow
Ruby
14
star
28

adapter-mongo

Adapter for mongo
Ruby
13
star
29

adapter-redis

Redis adapter
Ruby
12
star
30

flipper-redis

[MOVED] into flipper, check out readme for more
11
star
31

mirrored

[DEAD] Mirrored is a wrapper for the mirrored del.icio.us and ma.gnolia apis.
Ruby
11
star
32

ag

Nothing serious or finished, just playing with events, feeds, activities, timelines, wooooooooooo
Ruby
10
star
33

adapter-riak

Riak adapter
Ruby
9
star
34

wufoo

simple wrapper for the wufoo submission api
Ruby
9
star
35

wordpress_live_search_plugin

[DEAD] live search plugin for wordpress that just works (with prototype)
PHP
8
star
36

twitter

The twitter gem has moved to https://github.com/sferik/twitter
7
star
37

common_helpers

[old and dead] helpers that i use often in apps, nothing special
Ruby
6
star
38

crdts

Nothing serious or finished, just playing with convergent replicated data types
Ruby
6
star
39

adapter-memcached

Memcached adapter
Ruby
6
star
40

snitch

[DEAD AND UNMAINTAINED] Drop dead easy subversion commit notifications.
Ruby
5
star
41

chinwag

[DEAD] chat app that steve and i are playing with, uses google app engine, html5, css3 and jquery
Python
5
star
42

toystore-mongo

Mongo integration for Toystore
Ruby
5
star
43

tao

Nothing serious or finished, just playing with facebook tao concepts
Ruby
5
star
44

scout-plugins

scout plugins as i make them...
Ruby
4
star
45

flipper-mongo

[MOVED] merged into flipper repo, check out readme for more
3
star
46

disk_queue

Nothing to see here. Move along.
Ruby
3
star
47

adapter-cassanity

Adapter for Cassanity
Ruby
1
star
48

clostar

star slurper
Clojure
1
star
49

jnunemaker.github.com

my new blog
CSS
1
star
50

prey

[UNFINISHED] Kestrel client gem based on thrift interface.
Ruby
1
star
51

flipper-cassanity

Cassanity adapter for Flipper.
Ruby
1
star