Garelic: GoogleAnalytics as AppPerformanceMonitoring@jsuchal (@rubyslava #21)
Features
Controller:Average response times per action
Controller:Most time spent per action
Controller:Slowest pages
Controller:Response times histogram
Controller:Response times on timeline
ActiveRecord:Average/most time spent per model
Deployments:Average response times per deploy
and much more...compare, segment,slice & dice
Why?● NewRelic is really great...but   ○ "Database call response times"     ■ Standard package = $24/month/server   ○ "Tra...
How?● Google Analytics Site Speed User Timing  _gaq.push([‘_trackTiming’, category, variable, time, opt_label, opt_sample]...
How?● Ruby Monkey Patching  module ActionController   class Metal < AbstractController::Base    alias :dispatch_without_ga...
Limitations● Cannot measure redirect, AJAX, async jobs● Everything is visible in source code   ○ Reporting stacktrace & ra...
Ideas for future development● Tracking errors via GA events on error 500  pages● Tracking only slow responses (thresholdin...
Related resources● All Presentation Software is Broken http://www.   igvita.com/2012/05/14/all-presentation-software-is-br...
Upcoming SlideShare
Loading in...5
×

Garelic: Google Analytics as App Performance monitoring

2,235

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,235
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
30
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Garelic: Google Analytics as App Performance monitoring"

  1. 1. Garelic: GoogleAnalytics as AppPerformanceMonitoring@jsuchal (@rubyslava #21)
  2. 2. Features
  3. 3. Controller:Average response times per action
  4. 4. Controller:Most time spent per action
  5. 5. Controller:Slowest pages
  6. 6. Controller:Response times histogram
  7. 7. Controller:Response times on timeline
  8. 8. ActiveRecord:Average/most time spent per model
  9. 9. Deployments:Average response times per deploy
  10. 10. and much more...compare, segment,slice & dice
  11. 11. Why?● NewRelic is really great...but ○ "Database call response times" ■ Standard package = $24/month/server ○ "Transaction tracing" ■ Pro package = $149/month/server ○ basically unavailable for freelancers and small projects● Proof-of-concept ○ 2 hours of hacking ○ 2 hours of waiting for Google Analytics
  12. 12. How?● Google Analytics Site Speed User Timing _gaq.push([‘_trackTiming’, category, variable, time, opt_label, opt_sample]);● Google Analytics Custom Variables _gaq.push([`_setCustomVar’, index, name, value, opt_scope]);● ActiveSupport::Notifications ActiveSupport::Notifications.subscribe(process_action.action_controller) do |_, from, to, _, payload| Garelic::Metrics.report(:action, :db_runtime, payload[:db_runtime] || 0) Garelic::Metrics.report(:action, :view_runtime, payload[:view_runtime] || 0) Garelic::Metrics.report(:action, :total_runtime, (to - from) * 1000) Garelic::Metrics.action_identifier = "#{payload[:controller]}##{payload[:action]}" end ActiveSupport::Notifications.subscribe(sql.active_record) do |_, start, finish, _, payload| type = payload[:name] || Other SQL Garelic::Metrics.report(:active_record, type, (finish - start) * 1000) if type != CACHE end
  13. 13. How?● Ruby Monkey Patching module ActionController class Metal < AbstractController::Base alias :dispatch_without_garelic :dispatch def dispatch(*args) Garelic::Metrics.reset! response = dispatch_without_garelic(*args) timing_data = Garelic.report_user_timing_from_metrics(Garelic::Metrics) _, _, chunks = response chunks.each do |chunk| chunk.gsub!(Garelic::Timing, timing_data) end response end end end
  14. 14. Limitations● Cannot measure redirect, AJAX, async jobs● Everything is visible in source code ○ Reporting stacktrace & raw SQL considered harmful● Page caching breaks reports● Its a hack & GA has its own limitations
  15. 15. Ideas for future development● Tracking errors via GA events on error 500 pages● Tracking only slow responses (thresholding)● Share Google Analytics dashboards & custom reports● Pull requests welcome! https://github. com/jsuchal/garelic
  16. 16. Related resources● All Presentation Software is Broken http://www. igvita.com/2012/05/14/all-presentation-software-is-broken/● GA User Timing Method https://developers.google. com/analytics/devguides/collection/gajs/methods/gaJSApiUserTiming● GA Custom Variables https://developers.google. com/analytics/devguides/collection/gajs/gaTrackingCustomVariables#setu p
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×