Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2 from phlipper/patch-1

add GitHub Flavored Markdown to README
  • Loading branch information...
commit 52bdb5b323285cd48204b99d85bb1c90bbba7564 2 parents 0c0cb36 + d2f97ab
Ilya Grigorik authored
Showing with 32 additions and 26 deletions.
  1. +32 −26 README.md
58 README.md
View
@@ -31,48 +31,54 @@ Rack::SpeedTracer provides a Tracer class which you can use to instrument your c
### Quickstart Guide with Rack ###
- gem install rack-speedtracer
+```ruby
+gem install rack-speedtracer
- # in your rack app / rackup file
- use Rack::SpeedTracer
+# in your rack app / rackup file
+use Rack::SpeedTracer
- # in your app
- env['st.tracer'].run('name of operation') do
- ... your code ...
- end
+# in your app
+env['st.tracer'].run('name of operation') do
+ ... your code ...
+end
+```
Check out a full sample rack app: examples/runner.rb
### Instrumenting Rails 3 application ###
Rails 3 provides new [Notifications API](http://edgeapi.rubyonrails.org/classes/ActiveSupport/Notifications.html), which we can use to automatically instrument your Rails applications! It's as easy as:
- # in your Gemfile
- gem 'rack-speedtracer', :require => 'rack/speedtracer'
+```ruby
+# in your Gemfile
+gem 'rack-speedtracer', :require => 'rack/speedtracer'
- # in development.rb environment
- config.middleware.use Rack::SpeedTracer
+# in development.rb environment
+config.middleware.use Rack::SpeedTracer
+```
### Manually instrumenting Rails ###
To produce a server-side trace equivalent to one in the screenshot above:
- # in your Gemfile
- gem 'rack-speedtracer', :require => 'rack/speedtracer'
-
- # in development.rb environment
- config.middleware.use Rack::SpeedTracer
+```ruby
+# in your Gemfile
+gem 'rack-speedtracer', :require => 'rack/speedtracer'
- # define a widgets controller
- class WidgetsController < ApplicationController
- def index
- env['st.tracer'].run('Widgets#index') do
- env['st.tracer'].run("ActiveRecord: Widgets.all") do
- Widget.all
- end
+# in development.rb environment
+config.middleware.use Rack::SpeedTracer
- env['st.tracer'].run('Render') { render :text => 'oh hai' }
- end
+# define a widgets controller
+class WidgetsController < ApplicationController
+ def index
+ env['st.tracer'].run('Widgets#index') do
+ env['st.tracer'].run("ActiveRecord: Widgets.all") do
+ Widget.all
end
+
+ env['st.tracer'].run('Render') { render :text => 'oh hai' }
end
+ end
+end
+```
Speed Tracer
------------
@@ -97,4 +103,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please sign in to comment.
Something went wrong with that request. Please try again.