### Home Classes Methods

### In Files

- lib/phusion_passenger/rails3_extensions/init.rb

### Parent

ActiveSupport::LogSubscriber

### Namespace

- MODULE PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- MODULE PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension
- CLASS PhusionPassenger::Rails3Extensions::AnalyticsLogging::ExceptionLogger

### Methods

- ::install!
- #cache_fetch_hit
- #cache_generate
- #cache_read
- #process_action
- #sql

### Included Modules

- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension

### Class/Module Index

Quicksearch

- PhusionPassenger
- PhusionPassenger::AbstractInstaller
- PhusionPassenger::AbstractInstaller::Abort
- PhusionPassenger::AbstractInstaller::CommandError
- PhusionPassenger::AdminTools
- PhusionPassenger::AdminTools::MemoryStats
- PhusionPassenger::AdminTools::MemoryStats::Process
- PhusionPassenger::AdminTools::ServerInstance
- PhusionPassenger::AdminTools::ServerInstance::CorruptedDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::GenerationsAbsentError
- PhusionPassenger::AdminTools::ServerInstance::Group
- PhusionPassenger::AdminTools::ServerInstance::Process
- PhusionPassenger::AdminTools::ServerInstance::RoleDeniedError
- PhusionPassenger::AdminTools::ServerInstance::StaleDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::Stats
- PhusionPassenger::AdminTools::ServerInstance::UnsupportedGenerationStructureVersionError
- PhusionPassenger::AnalyticsLogger
- PhusionPassenger::AnalyticsLogger::Connection
- PhusionPassenger::AnalyticsLogger::Lock
- PhusionPassenger::AnalyticsLogger::Log
- PhusionPassenger::ClassicRails
- PhusionPassenger::ClassicRails::CGIFixed
- PhusionPassenger::ClassicRails::ThreadHandlerExtension
- PhusionPassenger::ConsoleTextTemplate
- PhusionPassenger::DebugLogging
- PhusionPassenger::LoaderSharedHelpers
- PhusionPassenger::MessageChannel
- PhusionPassenger::MessageChannel::InvalidHashError
- PhusionPassenger::MessageClient
- PhusionPassenger::NativeSupportLoader
- PhusionPassenger::Packaging
- PhusionPassenger::PlatformInfo
- PhusionPassenger::PlatformInfo::ApacheDetector
- PhusionPassenger::PlatformInfo::ApacheDetector::Result
- PhusionPassenger::PlatformInfo::Depcheck
- PhusionPassenger::PlatformInfo::Depcheck::ConsoleRunner
- PhusionPassenger::PlatformInfo::Depcheck::Dependency
- PhusionPassenger::PlatformInfo::RuntimeError
- PhusionPassenger::Plugin
- PhusionPassenger::PreloaderSharedHelpers
- PhusionPassenger::Rack
- PhusionPassenger::Rack::OutOfBandGc
- PhusionPassenger::Rack::ThreadHandlerExtension
- PhusionPassenger::Rails3Extensions
- PhusionPassenger::Rails3Extensions::AnalyticsLogging
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ExceptionLogger
- PhusionPassenger::RequestHandler
- PhusionPassenger::RequestHandler::ThreadHandler
- PhusionPassenger::RequestHandler::ThreadHandler::Interrupted
- PhusionPassenger::SharedConstants
- PhusionPassenger::Standalone
- PhusionPassenger::Standalone::AppFinder
- PhusionPassenger::Standalone::Command
- PhusionPassenger::Standalone::ConfigFile
- PhusionPassenger::Standalone::ConfigFile::DisallowedContextError
- PhusionPassenger::Standalone::HelpCommand
- PhusionPassenger::Standalone::Main
- PhusionPassenger::Standalone::PackageRuntimeCommand
- PhusionPassenger::Standalone::RuntimeInstaller
- PhusionPassenger::Standalone::RuntimeLocator
- PhusionPassenger::Standalone::StartCommand
- PhusionPassenger::Standalone::StatusCommand
- PhusionPassenger::Standalone::StopCommand
- PhusionPassenger::Standalone::Utils
- PhusionPassenger::Standalone::VersionCommand
- PhusionPassenger::Utils
- PhusionPassenger::Utils::AnsiColors
- PhusionPassenger::Utils::FileSystemWatcher
- PhusionPassenger::Utils::FileSystemWatcher::DirInfo
- PhusionPassenger::Utils::FileSystemWatcher::FileInfo
- PhusionPassenger::Utils::GeneratorTest
- PhusionPassenger::Utils::HostsFileParser
- PhusionPassenger::Utils::JSON
- PhusionPassenger::Utils::JSON::Generator
- PhusionPassenger::Utils::ParserTest
- PhusionPassenger::Utils::TeeInput
- PhusionPassenger::Utils::TmpIO
- PhusionPassenger::Utils::UnseekableSocket
- CommonLibraryBuilder
- Exception
- GC
- IO
- Object
- Signal

No matching classes.

# PhusionPassenger::Rails3Extensions::AnalyticsLogging

### Public Class Methods

install!(options) click to toggle source

    # File lib/phusion_passenger/rails3_extensions/init.rb, line 41
    def self.install!(options)
            analytics_logger = options["analytics_logger"]
            app_group_name = options["app_group_name"]
            return false if !analytics_logger || !options["analytics"]

            # 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)

            subscriber = self.new
            AnalyticsLogging.attach_to(:action_controller, subscriber)
            AnalyticsLogging.attach_to(:active_record, subscriber)
            if defined?(ActiveSupport::Cache::Store)
                    ActiveSupport::Cache::Store.instrument = true
                    AnalyticsLogging.attach_to(:active_support, subscriber)
            end
            PhusionPassenger.on_event(:starting_request_handler_thread) do
                    if defined?(ActiveSupport::Cache::Store)
                            # This flag is thread-local.
                            ActiveSupport::Cache::Store.instrument = true
                    end
            end

            if defined?(ActionDispatch::DebugExceptions)
                    exceptions_middleware = ActionDispatch::DebugExceptions
            elsif defined?(ActionDispatch::ShowExceptions)
                    exceptions_middleware = ActionDispatch::ShowExceptions
            end
            if exceptions_middleware
                    Rails.application.middleware.insert_after(
                            exceptions_middleware,
                            ExceptionLogger, analytics_logger, app_group_name)
            end

            if defined?(ActionController::Base)
                    ActionController::Base.class_eval do
                            include ACExtension
                    end
            end

            if defined?(ActiveSupport::Benchmarkable)
                    ActiveSupport::Benchmarkable.class_eval do
                            include ASBenchmarkableExtension
                            alias_method_chain :benchmark, :passenger
                    end
            end

            return true
    end

### Public Instance Methods

cache_fetch_hit(event) click to toggle source

    # File lib/phusion_passenger/rails3_extensions/init.rb, line 117
    def cache_fetch_hit(event)
            PhusionPassenger.log_cache_hit(nil, event.payload[:key])
    end

cache_generate(event) click to toggle source

    # File lib/phusion_passenger/rails3_extensions/init.rb, line 121
    def cache_generate(event)
            PhusionPassenger.log_cache_miss(nil, event.payload[:key],
                    event.duration * 1000)
    end

cache_read(event) click to toggle source

    # File lib/phusion_passenger/rails3_extensions/init.rb, line 109
    def cache_read(event)
            if event.payload[:hit]
                    PhusionPassenger.log_cache_hit(nil, event.payload[:key])
            else
                    PhusionPassenger.log_cache_miss(nil, event.payload[:key])
            end
    end

process_action(event) click to toggle source

    # File lib/phusion_passenger/rails3_extensions/init.rb, line 91
    def process_action(event)
            log = Thread.current[PASSENGER_ANALYTICS_WEB_LOG]
            if log
                    view_runtime = event.payload[:view_runtime]
                    log.message("View rendering time: #{(view_runtime * 1000).to_i}") if view_runtime
            end
    end

sql(event) click to toggle source

    # File lib/phusion_passenger/rails3_extensions/init.rb, line 99
    def sql(event)
            if log = Thread.current[PASSENGER_ANALYTICS_WEB_LOG]
                    name = event.payload[:name] || "SQL"
                    sql = event.payload[:sql]
                    digest = Digest::MD5.hexdigest("#{name}\00##{sql}\00##{rand}")
                    log.measured_time_points("DB BENCHMARK: #{digest}",
                            event.time, event.end, "#{name}\n#{sql}")
            end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.