SlideShare a Scribd company logo
Garelic: Google
Analytics as App
Performance
Monitoring
@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
   ○ "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
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
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
Limitations
● Cannot measure redirect, AJAX, async jobs

● Everything is visible in source code
   ○ Reporting stacktrace & raw SQL considered harmful


● Page caching breaks reports

● It's a hack & GA has its own limitations
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
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

More Related Content

Viewers also liked (6)

PDF
SQL: Query optimization in practice
Jano Suchal
 
PPT
Sql Server Performance Tuning
Bala Subra
 
PPTX
Google Cloud Platform monitoring with Zabbix
Max Kuzkin
 
PDF
Performance tuning and optimization (ppt)
Harish Chand
 
PDF
Bias Driven Development - Mario Fusco - Codemotion Milan 2016
Codemotion
 
PDF
How to Apply Big Data Analytics and Machine Learning to Real Time Processing ...
Codemotion
 
SQL: Query optimization in practice
Jano Suchal
 
Sql Server Performance Tuning
Bala Subra
 
Google Cloud Platform monitoring with Zabbix
Max Kuzkin
 
Performance tuning and optimization (ppt)
Harish Chand
 
Bias Driven Development - Mario Fusco - Codemotion Milan 2016
Codemotion
 
How to Apply Big Data Analytics and Machine Learning to Real Time Processing ...
Codemotion
 

Similar to Garelic: Google Analytics as App Performance monitoring (20)

KEY
improving the performance of Rails web Applications
John McCaffrey
 
PDF
User Tracking with Google Analytics and how it survives the break of the Glo...
Rafael Biriba
 
PPTX
Usando metodologías ágiles en UX
Paradigma Digital
 
PPTX
Yehoshua coren event tracking smx israel 2012
Barry Schwartz
 
PPTX
New Relic_Heroku_Presentation_Dreamforce11
New Relic
 
PPTX
Understanding Google Analytics: Who's Oggling My Company
Kimberly Swetland
 
PPTX
Google Analytics Workshop 2013
Milad Safarzadeh
 
PDF
Do we need a bigger dev data culture
Simon Dittlmann
 
PDF
New Relic .NET Agent Overview
Brian Doll
 
PDF
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
Nico Miceli
 
PDF
Google Analytics Class One
Noel Gomes
 
PDF
How to use pertinently Google Analytics, by Gilles Barbier
TheFamily
 
PDF
Web analytics masterclass Howest
Evelien De Mey
 
PDF
Zagat.com Case Study (DrupalCon Denver 2012)
Phase2
 
PDF
Google Analytics for Particularly Curious SaaS People
Chargebee
 
PPTX
AN INTRODUCTION ABOUT GOOGLE ANALYITICS
Chandra sai Satyavarapu
 
PPTX
Evolution or Extinction: Survive and Thrive with New Google Analytics Features
4Ps Marketing
 
PPTX
Mobile App Analytics. Why, How, What's new - Mar 2019
Dmitry Klymenko
 
PDF
Track Report & Optimize Your Web Creations
Empirical Path
 
DOC
Understanding Google Analytics
Shubha Brota Raha
 
improving the performance of Rails web Applications
John McCaffrey
 
User Tracking with Google Analytics and how it survives the break of the Glo...
Rafael Biriba
 
Usando metodologías ágiles en UX
Paradigma Digital
 
Yehoshua coren event tracking smx israel 2012
Barry Schwartz
 
New Relic_Heroku_Presentation_Dreamforce11
New Relic
 
Understanding Google Analytics: Who's Oggling My Company
Kimberly Swetland
 
Google Analytics Workshop 2013
Milad Safarzadeh
 
Do we need a bigger dev data culture
Simon Dittlmann
 
New Relic .NET Agent Overview
Brian Doll
 
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
Nico Miceli
 
Google Analytics Class One
Noel Gomes
 
How to use pertinently Google Analytics, by Gilles Barbier
TheFamily
 
Web analytics masterclass Howest
Evelien De Mey
 
Zagat.com Case Study (DrupalCon Denver 2012)
Phase2
 
Google Analytics for Particularly Curious SaaS People
Chargebee
 
AN INTRODUCTION ABOUT GOOGLE ANALYITICS
Chandra sai Satyavarapu
 
Evolution or Extinction: Survive and Thrive with New Google Analytics Features
4Ps Marketing
 
Mobile App Analytics. Why, How, What's new - Mar 2019
Dmitry Klymenko
 
Track Report & Optimize Your Web Creations
Empirical Path
 
Understanding Google Analytics
Shubha Brota Raha
 
Ad

More from Jano Suchal (20)

PDF
Slovensko.Digital: Čo ďalej?
Jano Suchal
 
PDF
Datanest 3.0
Jano Suchal
 
PDF
Improving code quality
Jano Suchal
 
PDF
Beyond search queries
Jano Suchal
 
PDF
Rank all the things!
Jano Suchal
 
PDF
Rank all the (geo) things!
Jano Suchal
 
PDF
Ako si vybrať programovácí jazyk alebo framework?
Jano Suchal
 
PPTX
Bonetics: Mastering Puppet Workshop
Jano Suchal
 
PPTX
Peter Mihalik: Puppet
Jano Suchal
 
PDF
Tomáš Čorej: Configuration management & CFEngine3
Jano Suchal
 
PDF
Ako si vybrať programovací jazyk a framework?
Jano Suchal
 
PDF
Miroslav Šimulčík: Temporálne databázy
Jano Suchal
 
PDF
Vojtech Rinik: Internship v USA - moje skúsenosti
Jano Suchal
 
PDF
Profiling and monitoring ruby & rails applications
Jano Suchal
 
PDF
Aký programovací jazyk a framework si vybrať a prečo?
Jano Suchal
 
PDF
Čo po GAMČI?
Jano Suchal
 
PDF
Petr Joachim: Redis na Super.cz
Jano Suchal
 
PDF
Metaprogramovanie #1
Jano Suchal
 
PDF
PostgreSQL: Advanced features in practice
Jano Suchal
 
PDF
elasticsearch - advanced features in practice
Jano Suchal
 
Slovensko.Digital: Čo ďalej?
Jano Suchal
 
Datanest 3.0
Jano Suchal
 
Improving code quality
Jano Suchal
 
Beyond search queries
Jano Suchal
 
Rank all the things!
Jano Suchal
 
Rank all the (geo) things!
Jano Suchal
 
Ako si vybrať programovácí jazyk alebo framework?
Jano Suchal
 
Bonetics: Mastering Puppet Workshop
Jano Suchal
 
Peter Mihalik: Puppet
Jano Suchal
 
Tomáš Čorej: Configuration management & CFEngine3
Jano Suchal
 
Ako si vybrať programovací jazyk a framework?
Jano Suchal
 
Miroslav Šimulčík: Temporálne databázy
Jano Suchal
 
Vojtech Rinik: Internship v USA - moje skúsenosti
Jano Suchal
 
Profiling and monitoring ruby & rails applications
Jano Suchal
 
Aký programovací jazyk a framework si vybrať a prečo?
Jano Suchal
 
Čo po GAMČI?
Jano Suchal
 
Petr Joachim: Redis na Super.cz
Jano Suchal
 
Metaprogramovanie #1
Jano Suchal
 
PostgreSQL: Advanced features in practice
Jano Suchal
 
elasticsearch - advanced features in practice
Jano Suchal
 
Ad

Recently uploaded (20)

PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
July Patch Tuesday
Ivanti
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 

Garelic: Google Analytics as App Performance monitoring

  • 1. Garelic: Google Analytics as App Performance Monitoring @jsuchal (@rubyslava #21)
  • 10. and much more... compare, segment, slice & dice
  • 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. 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. 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. Limitations ● Cannot measure redirect, AJAX, async jobs ● Everything is visible in source code ○ Reporting stacktrace & raw SQL considered harmful ● Page caching breaks reports ● It's a hack & GA has its own limitations
  • 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. 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