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

ODP
Changing Etsy's Architectural Foundations with Continuous Deployment
PDF
Java2day 2013 : Modern workflows for javascript integration
PDF
Intro to sbt-web
PDF
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
PDF
Front end microservices - October 2019
PPTX
intro to Angular js
PDF
Client Side Measurement & Performance With Rails
PPTX
Introduction to Serverless and Google Cloud Functions
Changing Etsy's Architectural Foundations with Continuous Deployment
Java2day 2013 : Modern workflows for javascript integration
Intro to sbt-web
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
Front end microservices - October 2019
intro to Angular js
Client Side Measurement & Performance With Rails
Introduction to Serverless and Google Cloud Functions

Viewers also liked (6)

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

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

KEY
improving the performance of Rails web Applications
PDF
User Tracking with Google Analytics and how it survives the break of the Glo...
PPTX
Usando metodologías ágiles en UX
PPTX
Yehoshua coren event tracking smx israel 2012
PPTX
New Relic_Heroku_Presentation_Dreamforce11
PPTX
Understanding Google Analytics: Who's Oggling My Company
PPTX
Google Analytics Workshop 2013
PDF
Do we need a bigger dev data culture
PDF
New Relic .NET Agent Overview
PDF
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
PDF
Google Analytics Class One
PDF
How to use pertinently Google Analytics, by Gilles Barbier
PDF
Web analytics masterclass Howest
PDF
Zagat.com Case Study (DrupalCon Denver 2012)
PDF
Google Analytics for Particularly Curious SaaS People
PPTX
AN INTRODUCTION ABOUT GOOGLE ANALYITICS
PPTX
Evolution or Extinction: Survive and Thrive with New Google Analytics Features
PPTX
Mobile App Analytics. Why, How, What's new - Mar 2019
PDF
Track Report & Optimize Your Web Creations
DOC
Understanding Google Analytics
improving the performance of Rails web Applications
User Tracking with Google Analytics and how it survives the break of the Glo...
Usando metodologías ágiles en UX
Yehoshua coren event tracking smx israel 2012
New Relic_Heroku_Presentation_Dreamforce11
Understanding Google Analytics: Who's Oggling My Company
Google Analytics Workshop 2013
Do we need a bigger dev data culture
New Relic .NET Agent Overview
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
Google Analytics Class One
How to use pertinently Google Analytics, by Gilles Barbier
Web analytics masterclass Howest
Zagat.com Case Study (DrupalCon Denver 2012)
Google Analytics for Particularly Curious SaaS People
AN INTRODUCTION ABOUT GOOGLE ANALYITICS
Evolution or Extinction: Survive and Thrive with New Google Analytics Features
Mobile App Analytics. Why, How, What's new - Mar 2019
Track Report & Optimize Your Web Creations
Understanding Google Analytics
Ad

More from Jano Suchal (20)

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

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Spectroscopy.pptx food analysis technology
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Network Security Unit 5.pdf for BCA BBA.
Spectral efficient network and resource selection model in 5G networks
Group 1 Presentation -Planning and Decision Making .pptx
Machine learning based COVID-19 study performance prediction
Digital-Transformation-Roadmap-for-Companies.pptx
TLE Review Electricity (Electricity).pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Getting Started with Data Integration: FME Form 101
NewMind AI Weekly Chronicles - August'25-Week II
Univ-Connecticut-ChatGPT-Presentaion.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Unlocking AI with Model Context Protocol (MCP)
A comparative analysis of optical character recognition models for extracting...
Assigned Numbers - 2025 - Bluetooth® Document
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
1. Introduction to Computer Programming.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectroscopy.pptx food analysis technology
cloud_computing_Infrastucture_as_cloud_p
Network Security Unit 5.pdf for BCA BBA.

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