Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update examples in README

  • Loading branch information...
commit f32062c2190af7391ea876000ac10bee6138dd7e 1 parent 64fce97
@sax authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 README.md
View
13 README.md
@@ -5,6 +5,8 @@ instruments in Rails, turning them into DTrace probes.
## Requirements
+Rails > 3.0
+
An OS that supports DTrace. For example:
* MacOS X
* Illumos
@@ -57,6 +59,17 @@ sudo dtrace -n 'ruby*:rails:: { printf("%d %d %s %s", arg0, arg1,
copyinstr(arg2), copyinstr(arg3)) }'
```
+Example output:
+
+```
+1 15406 start_processing:action_controller 1344495838 1344495838 b02472370ff8f9669301 {:controller=>"ThingsController", :action=>"index", :params=>{"action"=>"index", "controller"=>"things"}, :format=>"*/*", :method=>"GET", :path=>"/things"}
+1 15407 sql:active_record 1344495838 1344495838 4595e4d30b17bdb96fe9 {:sql=>"SELECT \"things\".* FROM \"things\" ", :name=>"Thing Load", :connection_id=>70184895988280, :binds=>[]}
+1 15408 !render_template:action_view 1344495838 1344495838 b02472370ff8f9669301 {:virtual_path=>"things/index"}
+1 15409 render_template:action_view 1344495838 1344495838 b02472370ff8f9669301 {:identifier=>"/path/to/application/app/views/things/index.html.erb", :layout=>"layouts/application"}
+1 15408 !render_template:action_view 1344495838 1344495838 b02472370ff8f9669301 {:virtual_path=>"layouts/application"}
+1 15410 process_action:action_controller 1344495838 1344495838 b02472370ff8f9669301 {:controller=>"ThingsController", :action=>"index", :params=>{"action"=>"index", "controller"=>"things"}, :format=>"*/*", :method=>"GET", :path=>"/things", :status=>200, :view_runtime=>5.199, :db_runtime=>0.128}
+```
+
Notifications are lazy-loaded, so even though rails-dtrace subscribes to
all available instruments, they will only be converted to probes as
they fire in Rails code. For this reason, in order to get a full picture

2 comments on commit f32062c

@rbriank

This is an great tool. I'm new to DTrace and having trouble finding examples.. is there a way to find out what I can monitor?

@sax
Owner

I was struggling with that as well. I was not able to find a way of listing all available notifications in Rails. The gem subscribes to every new ActiveSupport notification that fires, though, so what you can do is throw some real traffic at the application, then use dtrace -l -n ruby*:rails:: to list available probes.

Also, take a look here if you haven't already: http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html
You can easily write new notifications into your code, and rails-dtrace will report on them.

If you think of improvements, definitely open issues or submit pull requests. There's a DTrace patch in Illumos for parsing JSON, but who knows if and when that will work its way down into other OS's.

Please sign in to comment.
Something went wrong with that request. Please try again.