Module: PhusionPassenger::ClassicRailsExtensions::AnalyticsLogging

Defined in:
lib/phusion_passenger/classic_rails_extensions/init.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_base_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_rescue_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_benchmarking_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ar_abstract_adapter_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/av_benchmark_helper_extension.rb

Defined Under Namespace

Modules: ACBaseExtension, ACBenchmarkingExtension, ACRescueExtension, ARAbstractAdapterExtension, AVBenchmarkHelperExtension, CacheStoreExtension, ConcreteCacheStoreExtension

Constant Summary collapse

@@analytics_logger =

Instantiated from prepare_app_process in utils.rb.

nil

Class Method Summary collapse

Class Method Details

.install!(options) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/phusion_passenger/classic_rails_extensions/init.rb', line 45

def self.install!(options)
	@@analytics_logger = options["analytics_logger"]
	# If the Ruby interpreter supports GC statistics then turn it on
	# so that the info can be logged.
	GC.enable_stats if GC.respond_to?(:enable_stats)
	
	if defined?(ActionController)
		require 'phusion_passenger/classic_rails_extensions/analytics_logging/ac_base_extension'
		ActionController::Base.class_eval do
			include ACBaseExtension
			alias_method_chain :perform_action, :passenger
			alias_method_chain :render, :passenger
		end
		
		require 'phusion_passenger/classic_rails_extensions/analytics_logging/ac_benchmarking_extension'
		ActionController::Benchmarking::ClassMethods.class_eval do
			include ACBenchmarkingExtension
			alias_method_chain :benchmark, :passenger
		end
		
		require 'phusion_passenger/classic_rails_extensions/analytics_logging/ac_rescue_extension'
		ActionController::Rescue.class_eval do
			include ACRescueExtension
			alias_method_chain :rescue_action, :passenger
		end
	end
	
	if defined?(ActionView)
		require 'phusion_passenger/classic_rails_extensions/analytics_logging/av_benchmark_helper_extension'
		ActionView::Helpers::BenchmarkHelper.class_eval do
			include AVBenchmarkHelperExtension
			alias_method_chain :benchmark, :passenger
		end
	end
	
	if defined?(ActiveRecord)
		require 'phusion_passenger/classic_rails_extensions/analytics_logging/ar_abstract_adapter_extension'
		ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
			include ARAbstractAdapterExtension
			alias_method_chain :log, :passenger
		end
	end
	
	if defined?(ActiveSupport::Cache::Store) && Rails.cache
		require 'phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension'
		ActiveSupport::Cache::Store.class_eval do
			include CacheStoreExtension
			case Rails::VERSION::MINOR
			when 1
				# Rails 2.1
				alias_method :fetch, :fetch_2_1
			when 2
				# Rails 2.2
				alias_method :fetch, :fetch_2_2
			when 3
				# Rails 2.3
				alias_method :fetch, :fetch_2_3
			end
		end
		Rails.cache.extend(ConcreteCacheStoreExtension)
	end
end

.new_transaction_log(env, category = :requests) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/phusion_passenger/classic_rails_extensions/init.rb', line 108

def self.new_transaction_log(env, category = :requests)
	if env[PASSENGER_TXN_ID]
		group_name = env[PASSENGER_GROUP_NAME]
		union_station_key = env[PASSENGER_UNION_STATION_KEY]
		log = @@analytics_logger.new_transaction(group_name, category,
			union_station_key)
		begin
			yield log
		ensure
			log.close
		end
	end
end