### Home Classes Methods

### In Files

- lib/phusion_passenger/analytics_logger.rb

### Parent

Object

### Methods

- ::new
- #begin_measure
- #close
- #closed?
- #end_measure
- #measure
- #measured_time_points
- #message
- #null?

### 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::AnalyticsLogger::Log

### Attributes

txn_id[R]

### Public Class Methods

new(connection = nil, txn_id = nil) click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 41
    def initialize(connection = nil, txn_id = nil)
            if connection
                    @connection = connection
                    @txn_id = txn_id
                    connection.ref
            end
    end

### Public Instance Methods

begin_measure(name, extra_info = nil) click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 76
    def begin_measure(name, extra_info = nil)
            if extra_info
                    extra_info_base64 = [extra_info].pack("m")
                    extra_info_base64.gsub!("\n", "")
                    extra_info_base64.strip!
            else
                    extra_info_base64 = nil
            end
            times = NativeSupport.process_times
            message "BEGIN: #{name} (#{current_timestamp.to_s(36)},#{times.utime.to_s(36)},#{times.stime.to_s(36)}) #{extra_info_base64}"
    end

close(flush_to_disk = false) click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 124
    def close(flush_to_disk = false)
            @connection.synchronize do
                    return if !@connection.connected?
                    begin
                            # We need an ACK here. See abstract_request_handler.rb finalize_request.
                            @connection.channel.write("closeTransaction", @txn_id,
                                    AnalyticsLogger.timestamp_string, true)
                            result = @connection.channel.read
                            if result != ["ok"]
                                    raise "Expected logging agent to respond with 'ok', but got #{result.inspect} instead"
                            end
                            if flush_to_disk
                                    @connection.channel.write("flush")
                                    result = @connection.channel.read
                                    if result != ["ok"]
                                            raise "Invalid logging agent response #{result.inspect} to the 'flush' command"
                                    end
                            end
                    rescue SystemCallError, IOError => e
                            @connection.disconnect
                            DebugLogging.warn("Error communicating with the logging agent: #{e.message}")
                    rescue Exception => e
                            @connection.disconnect
                            raise e
                    ensure
                            @connection.unref
                            @connection = nil
                    end
            end if @connection
    end

closed?() click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 155
    def closed?
            if @connection
                    @connection.synchronize do
                            return !@connection.connected?
                    end
            else
                    return nil
            end
    end

end_measure(name, error_encountered = false) click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 88
    def end_measure(name, error_encountered = false)
            times = NativeSupport.process_times
            if error_encountered
                    message "FAIL: #{name} (#{current_timestamp.to_s(36)},#{times.utime.to_s(36)},#{times.stime.to_s(36)})"
            else
                    message "END: #{name} (#{current_timestamp.to_s(36)},#{times.utime.to_s(36)},#{times.stime.to_s(36)})"
            end
    end

measure(name, extra_info = nil) click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 97
    def measure(name, extra_info = nil)
            begin_measure(name, extra_info)
            begin
                    yield
            rescue Exception
                    error = true
                    is_closed = closed?
                    raise
            ensure
                    end_measure(name, error) if !is_closed
            end
    end

measured_time_points(name, begin_time, end_time, extra_info = nil) click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 110
    def measured_time_points(name, begin_time, end_time, extra_info = nil)
            if extra_info
                    extra_info_base64 = [extra_info].pack("m")
                    extra_info_base64.gsub!("\n", "")
                    extra_info_base64.strip!
            else
                    extra_info_base64 = nil
            end
            begin_timestamp = begin_time.to_i * 1_000_000 + begin_time.usec
            end_timestamp = end_time.to_i * 1_000_000 + end_time.usec
            message "BEGIN: #{name} (#{begin_timestamp.to_s(36)}) #{extra_info_base64}"
            message "END: #{name} (#{end_timestamp.to_s(36)})"
    end

message(text) click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 53
    def message(text)
            if !@connection
                    timestamp_string = AnalyticsLogger.timestamp_string
                    DebugLogging.trace(3, "[Union Station log to null] #{@txn_id} #{timestamp_string} #{text}")
                    return
            end
            @connection.synchronize do
                    return if !@connection.connected?
                    begin
                            timestamp_string = AnalyticsLogger.timestamp_string
                            DebugLogging.trace(3, "[Union Station log] #{@txn_id} #{timestamp_string} #{text}")
                            @connection.channel.write("log", @txn_id, timestamp_string)
                            @connection.channel.write_scalar(text)
                    rescue SystemCallError, IOError => e
                            @connection.disconnect
                            DebugLogging.warn("Error communicating with the logging agent: #{e.message}")
                    rescue Exception => e
                            @connection.disconnect
                            raise e
                    end
            end
    end

null?() click to toggle source

    # File lib/phusion_passenger/analytics_logger.rb, line 49
    def null?
            return !@connection || !@connection.connected?
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.