class UnionStationHooks::RequestReporter
A RequestReporter object is used for logging request-specific information to Union Station. “Information” may include (and are not limited to):
* Web framework controller and action name. * Exceptions raised during the request. * Cache hits and misses. * Database actions.
A unique RequestReporter is created by Passenger at the beginning of every request (by calling {UnionStationHooks.begin_rack_request}). This object is closed at the end of the same request (after the Rack body object is closed).
As an application developer, the RequestReporter is the main class that you will be interfacing with. See the {UnionStationHooks} module description for an example of how you can use RequestReporter.
## Obtaining a RequestReporter
You are not supposed to create a RequestReporter object directly. You are supposed to obtain the RequestReporter object that Passenger creates for you. This is done through the `union_station_hooks` key in the Rack environment hash, as well as through the `:union_station_hooks` key in the current thread's object:
env['union_station_hooks'] # => RequestReporter object or nil Thread.current[:union_station_hooks] # => RequestReporter object or nil
Note that Passenger may not have created such an object because of an error. At present, there are two error conditions that would cause a RequestReporter object not to be created. However, your code should take into account that in the future more error conditions may trigger this.
1. There is no transaction ID associated with the current request.
When Union Station support is enabled in Passenger, Passenger always
assigns a transaction ID. However, administrators can also
{https://www.phusionpassenger.com/library/admin/nginx/request_individual_processes.html
access Ruby processes directly} through process-private HTTP sockets,
bypassing Passenger's load balancing mechanism. In that case, no
transaction ID will be assigned.
2. An error occurred recently while sending data to the UstRouter, either
because the UstRouter crashed or because of some other kind of
communication error occurred. This error condition isn't cleared until
certain a timeout has passed.
The UstRouter is a Passenger process which runs locally and is
responsible for aggregating Union Station log data from multiple
processes, with the goal of sending the aggregate data over the network
to the Union Station service.
This kind of error is automatically recovered from after a certain
period of time.
## Null mode
The error condition 2 described above may also cause an existing RequestReporter object to enter the “null mode”. When this mode is entered, any further actions on the RequestReporter object will become no-ops. You can check whether the null mode is active by calling {#null?}.
Closing a RequestReporter also causes it to enter the null mode.
## Thread-safety
RequestReporter is not thread-safe. If you access it concurrently, be sure to wrap its operations in a mutex.
Constants
- GC_MUTEX
A mutex for synchronizing GC stats reporting. We do this because in multithreaded situations we don't want to interleave GC stats access with calls to `GC.clear_stats`. Not that GC stats are very helpful in multithreaded situations, but this is better than nothing.
@private
- GC_SUPPORTS_CLEAR_STATS
@private
- GC_SUPPORTS_TIME
@private
- OBJECT_SPACE_SUPPORTS_ALLOCATED_OBJECTS
@private
- OBJECT_SPACE_SUPPORTS_COUNT_OBJECTS
@private
- OBJECT_SPACE_SUPPORTS_LIVE_OBJECTS
@private
Public Class Methods
Returns a new RequestReporter object. You should not call `RequestReporter.new` directly. See “Obtaining a RequestReporter” in the {RequestReporter class description}.
@api private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb, line 105 def initialize(context, txn_id, app_group_name, key) raise ArgumentError, 'Transaction ID must be given' if txn_id.nil? raise ArgumentError, 'App group name must be given' if app_group_name.nil? raise ArgumentError, 'Union Station key must be given' if key.nil? @context = context @txn_id = txn_id @app_group_name = app_group_name @key = key @transaction = continue_transaction @next_view_rendering_number = 1 @next_user_activity_number = 1 @next_benchmark_number = 1 @next_database_query_number = 1 end
Public Instance Methods
Indicates that no further information will be logged for this request.
@api private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb, line 124 def close @transaction.close end
Returns whether {#log_controller_action_block} or {#log_controller_action} has been called during this request.
@return [Boolean]
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb, line 173 def controller_action_logged? !!@controller_action end
Logs a benchmarking activity, for display in the activity timeline.
An activity is a block in the activity timeline in the Union Station user interace. It has a name, a begin time and an end time.
The primary use case of this method is to integrate with Rails's benchmarking API (`ActiveSupport::Benchmarkable`). The Rails benchmarking API allows you to run a block and to log how long that block has taken. But you can also use it to integrate with the Ruby standard library's `Benchmark` class.
You can wrap a benchmark call in a `UnionStationHooks.log_benchmark_block` call, so that an entry for it is displayed in the acitivity timeline. This method measures the time before and after the block runs.
The difference between this method and {#log_user_activity_block} is that this method generates timeline blocks of a different color, as to differentiate user-defined activities from benchmark activities.
If your app is a Rails app, then the `union_station_hooks_rails` gem automatically calls this for you every time `ActiveSupport::Benchmarkable#benchmark` is called. This includes `benchmark` calls from controllers and from views.
@param title A title for this benchmark. It can be any arbitrary name but
may not contain newlines.
@return The return value of the block. @yield The block is expected to perform the benchmarking activity. @example Rails example
# This example shows what to put inside a Rails controller action
# method. Note that the `log_benchmark_block` call is automatically done
# for you if you use the union_station_hooks_rails gem.
UnionStationHooks.log_benchmark_block('Process data files') do
benchmark('Process data files') do
expensive_files_operation
end
end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 157 def log_benchmark_block(title = 'Benchmarking', &block) if null? do_nothing_on_null(:log_benchmark_block) yield else @transaction.log_activity_block(next_benchmark_name, title, &block) end end
Logs that something was successfully retrieved from a cache. This can be any cache, be it an in-memory Hash, Redis, Memcached, a flat file or whatever.
There is just one exception. You should not use this method to log cache hits in the ActiveRecord SQL cache or similar mechanisms. Database-related timing should be logged with {#log_database_query}.
If your app is a Rails app, then the `union_station_hooks_rails` gem automatically calls this for you every time an `ActiveSupport::Cache` `#fetch` or `#read` call success. This includes calls to `Rails.cache.fetch` or `Rails.cache.read`, because `Rails.cache` is an instance of `ActiveSupport::Cache`.
@param [String] name A unique name for this cache hit event. The cache
key is a good value to use.
@note At present (30 September 2015), logged cache hit/miss information
isn't shown in the Union Station interface. We may implement this feature in the near future.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 242 def log_cache_hit(name) return do_nothing_on_null(:log_cache_hit) if null? @transaction.message("Cache hit: #{name}") end
Logs the failure to retrieve something from a cache. This can be any cache, be it an in-memory Hash, Redis, Memcached, a flat file or whatever.
There is just one exception. You should not use this method to log cache misses in the ActiveRecord SQL cache or similar mechanisms. Database-related timing should be logged with {#log_database_query}.
If your app is a Rails app, then the `union_station_hooks_rails` gem automatically calls this for you every time an `ActiveSupport::Cache` `#fetch` or `#read` call success. This includes calls to `Rails.cache.fetch` or `Rails.cache.read`, because `Rails.cache` is an instance of `ActiveSupport::Cache`.
@param [String] name A unique name for this cache miss event. The cache
key is a good value to use.
@param [Numeric] miss_cost_duration The amount of time that was spent in
calculating or processing something, as a result of this cache miss. This time is in **microseconds**.
@note At present (30 September 2015), logged cache hit/miss information
isn't shown in the Union Station interface. We may implement this feature in the near future.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 269 def log_cache_miss(name, miss_cost_duration = nil) return do_nothing_on_null(:log_cache_miss) if null? if miss_cost_duration @transaction.message("Cache miss (#{miss_cost_duration.to_i} usec): " "#{name}") else @transaction.message("Cache miss: #{name}") end end
Logs that the application server is about to call `#close` on the Rack body object.
This call must be followed by a call to {#log_closing_rack_body_end} some time later.
This is automatically called by Passenger's Rack handler.
@private @return An ID to be passed later to {#log_closing_rack_body_end}.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 179 def log_closing_rack_body_begin return do_nothing_on_null(:log_closing_rack_body_begin) if null? @transaction.log_activity_begin('closing rack body object') nil end
Logs that the application server is done calling `#close` on the Rack body object.
This is automatically called by Passenger's Rack handler.
@private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 191 def log_closing_rack_body_end(id) return do_nothing_on_null(:log_closing_rack_body_end) if null? @transaction.log_activity_end('closing rack body object') end
Logs that you are calling a web framework controller action. Of course, you should only call this if your web framework has the concept of controller actions. For example Rails does, but Sinatra and Grape don't.
You can pass additional information about the web framework controller action, which will be logged.
Unlike {#log_controller_action_block}, this form does not expect a block. However, you are expected to pass timing information to the options hash.
The `union_station_hooks_rails` gem automatically calls {#log_controller_action_block} for you if your application is a Rails app.
@param [Hash] options Information about the controller action. @option options [String] :controller_name (optional)
The controller's name, e.g. `PostsController`.
@option options [String] :action_name (optional if :controller_name
isn't set) The controller action's name, e.g. `create`.
@option options [String] :method (optional)
The HTTP method that the web framework thinks this request should have, e.g. `GET` and `PUT`. The main use case for this option is to support Rails's HTTP verb emulation. Rails uses a parameter named [`_method`](http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark) to emulate HTTP verbs besides GET and POST. Other web frameworks may have a similar mechanism.
@option options [TimePoint or Time] :begin_time The time at which the
controller action begun. See {UnionStationHooks.now} to learn more.
@option options [TimePoint or Time] :end_time The time at which the
controller action ended. See {UnionStationHooks.now} to learn more.
@option options [Boolean] :has_error (optional) Whether an uncaught
exception occurred during the request. Default: false.
@example
# This example shows what to put inside a Rails controller action # method. Note that all of this is automatically done for you if you # use the union_station_hooks_rails gem. options = { :controller_name => self.class.name, :action_name => action_name, :method => request.request_method, :begin_time => UnionStationHooks.now } begin do_some_request_processing_here rescue Exception options[:has_error] = true raise ensure options[:end_time] = UnionStationHooks.now reporter.log_controller_action(options) end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb, line 153 def log_controller_action(options) return do_nothing_on_null(:log_controller_action) if null? Utils.require_key(options, :begin_time) Utils.require_key(options, :end_time) if options[:controller_name] build_full_controller_action_string(options) @transaction.message("Controller action: #{@controller_action}") end if options[:method] @transaction.message("Application request method: #{options[:method]}") end @transaction.log_activity('framework request processing', options[:begin_time], options[:end_time], nil, options[:has_error]) end
Logs that you are calling a web framework controller action. Of course, you should only call this if your web framework has the concept of controller actions. For example Rails does, but Sinatra and Grape don't.
This form takes an options hash as well as a block. You can pass additional information about the web framework controller action, which will be logged. The block is expected to perform the actual request handling. When the block returns, timing information about the block is automatically logged.
See also {#log_controller_action} for a form that doesn't expect a block.
The `union_station_hooks_rails` gem automatically calls this for you if your application is a Rails app.
@yield The given block is expected to perform request handling. @param [Hash] options Information about the controller action.
All options are optional.
@option options [String] :controller_name
The controller's name, e.g. `PostsController`.
@option options [String] :action_name
The controller action's name, e.g. `create`.
@option options [String] :method
The HTTP method that the web framework thinks this request should have, e.g. `GET` and `PUT`. The main use case for this option is to support Rails's HTTP verb emulation. Rails uses a parameter named [`_method`](http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark) to emulate HTTP verbs besides GET and POST. Other web frameworks may have a similar mechanism.
@return The return value of the block.
@example Rails example
# This example shows what to put inside a Rails controller action # method. Note that all of this is automatically done for you if you # use the union_station_hooks_rails gem. options = { :controller_name => self.class.name, :action_name => action_name, :method => request.request_method } reporter.log_controller_action_block(options) do do_some_request_processing_here end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb, line 75 def log_controller_action_block(options = {}) if null? do_nothing_on_null(:log_controller_action_block) yield else build_full_controller_action_string(options) has_error = true begin_time = UnionStationHooks.now begin result = yield has_error = false result ensure log_controller_action( options.merge( :begin_time => begin_time, :end_time => UnionStationHooks.now, :has_error => has_error ) ) end end end
Logs a database query that was performed during the request.
@option options [String] :name (optional) A name for this database
query activity. Default: "SQL"
@option options [TimePoint or Time] :begin_time The time at which this
database query begun. See {UnionStationHooks.now} to learn more.
@option options [TimePoint or Time] :end_time The time at which this
database query ended. See {UnionStationHooks.now} to learn more.
@option options [String] :query The database query string.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 208 def log_database_query(options) return do_nothing_on_null(:log_database_query) if null? Utils.require_key(options, :begin_time) Utils.require_key(options, :end_time) Utils.require_non_empty_key(options, :query) name = options[:name] || 'SQL' begin_time = options[:begin_time] end_time = options[:end_time] query = options[:query] @transaction.log_activity(next_database_query_name, begin_time, end_time, "#{name}\n#{query}") end
Logs an exception that occurred during a request.
If {#log_controller_action_block} or {#log_controller_action} was called during the same request, then the information passed to those methods will be included in the exception report.
@param [Exception] exception
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 174 def log_exception(exception) transaction = @context.new_transaction( @app_group_name, :exceptions, @key) begin return do_nothing_on_null(:log_exception) if transaction.null? base64_message = exception.message base64_message = exception.to_s if base64_message.empty? base64_message = Utils.base64(base64_message) base64_backtrace = Utils.base64(exception.backtrace.join("\n")) if controller_action_logged? transaction.message("Controller action: #{@controller_action}") end transaction.message("Request transaction ID: #{@txn_id}") transaction.message("Message: #{base64_message}") transaction.message("Class: #{exception.class.name}") transaction.message("Backtrace: #{base64_backtrace}") ensure transaction.close end end
@private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 86 def log_gc_stats_on_request_begin return do_nothing_on_null(:log_gc_stats_on_request_begin) if null? # See the docs for MUTEX on why we synchronize this. GC_MUTEX.synchronize do if OBJECT_SPACE_SUPPORTS_LIVE_OBJECTS @transaction.message('Initial objects on heap: ' "#{ObjectSpace.live_objects}") end if OBJECT_SPACE_SUPPORTS_ALLOCATED_OBJECTS @transaction.message('Initial objects allocated so far: ' "#{ObjectSpace.allocated_objects}") elsif OBJECT_SPACE_SUPPORTS_COUNT_OBJECTS count = ObjectSpace.count_objects @transaction.message('Initial objects allocated so far: ' "#{count[:TOTAL] - count[:FREE]}") end if GC_SUPPORTS_TIME @transaction.message("Initial GC time: #{GC.time}") end end end
@private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 110 def log_gc_stats_on_request_end return do_nothing_on_null(:log_gc_stats_on_request_end) if null? # See the docs for MUTEX on why we synchronize this. GC_MUTEX.synchronize do if OBJECT_SPACE_SUPPORTS_LIVE_OBJECTS @transaction.message('Final objects on heap: ' "#{ObjectSpace.live_objects}") end if OBJECT_SPACE_SUPPORTS_ALLOCATED_OBJECTS @transaction.message('Final objects allocated so far: ' "#{ObjectSpace.allocated_objects}") elsif OBJECT_SPACE_SUPPORTS_COUNT_OBJECTS count = ObjectSpace.count_objects @transaction.message('Final objects allocated so far: ' "#{count[:TOTAL] - count[:FREE]}") end if GC_SUPPORTS_TIME @transaction.message("Final GC time: #{GC.time}") end if GC_SUPPORTS_CLEAR_STATS # Clear statistics to void integer wraps. GC.clear_stats end end end
Logs the beginning of a Rack request. This is automatically called from {UnionStationHooks.begin_rack_request} (and thus automatically from Passenger).
@private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 60 def log_request_begin return do_nothing_on_null(:log_request_begin) if null? @transaction.log_activity_begin('app request handler processing') end
Logs the end of a Rack request. This means that the Rack response body has been written out, and that the `#close` has been called on the Rack response body.
This does not necessarily indicate that any buffering mechanism in between the app and the client (e.g. Nginx, or the Passenger core) is done flushing the response to the client.
This is automatically called from {UnionStationHooks.begin_rack_request} (and thus automatically from Passenger).
@private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 77 def log_request_end(uncaught_exception_raised_during_request = false) return do_nothing_on_null(:log_request_end) if null? @transaction.log_activity_end('app request handler processing', UnionStationHooks.now, uncaught_exception_raised_during_request) end
Logs a user-defined activity, for display in the activity timeline.
An activity is a block in the activity timeline in the Union Station user interace. It has a name, a begin time and an end time.
Unlike {#log_user_activity_block}, this form does not expect a block. However, you are expected to pass timing information.
@param name The name that should show up in the activity timeline.
It can be any arbitrary name but may not contain newlines.
@param [TimePoint or Time] begin_time The time at which this activity
begun. See {UnionStationHooks.now} to learn more.
@param [TimePoint or Time] end_time The time at which this activity
ended. See {UnionStationHooks.now} to learn more.
@param [Boolean] has_error Whether an uncaught
exception occurred during the activity.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 113 def log_user_activity(name, begin_time, end_time, has_error = false) return do_nothing_on_null(:log_user_activity) if null? @transaction.log_activity(next_user_activity_name, begin_time, end_time, name, has_error) end
Logs the begin of a user-defined activity, for display in the activity timeline.
An activity is a block in the activity timeline in the Union Station user interace. It has a name, a begin time and an end time.
This form logs only the name and the begin time. You must also call {#log_user_activity_end} later with the same name to log the end time.
@param name The name that should show up in the activity timeline.
It can be any arbitrary name but may not contain newlines.
@return id An ID which you must pass to {#log_user_activity_end} later.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 71 def log_user_activity_begin(name) return do_nothing_on_null(:log_user_activity_begin) if null? id = next_user_activity_name @transaction.log_activity_begin(id, UnionStationHooks.now, name) id end
Logs a user-defined activity, for display in the activity timeline.
An activity is a block in the activity timeline in the Union Station user interace. It has a name, a begin time and an end time.
This form takes a block. Before and after the block runs, the time is measured.
@param name The name that should show up in the activity timeline.
It can be any arbitrary name but may not contain newlines.
@return The return value of the block. @yield The block is expected to perform the activity. @example
reporter.log_user_activity_block('Preheat cache') do calculate_preheat_values.each_pair do |key, value| Rails.cache.write(key, value) end end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 48 def log_user_activity_block(name, &block) if null? do_nothing_on_null(:log_user_activity_block) yield else @transaction.log_activity_block(next_user_activity_name, name, &block) end end
Logs the end of a user-defined activity, for display in the activity timeline.
An activity is a block in the activity timeline in the Union Station user interace. It has a name, a begin time and an end time.
This form logs only the name and the end time. You must also have called {#log_user_activity_begin} earlier with the same name to log the begin time.
@param id The ID which you obtained from {#log_user_activity_begin}
earlier.
@param [Boolean] has_error Whether an uncaught
exception occurred during the activity.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 92 def log_user_activity_end(id, has_error = false) return do_nothing_on_null(:log_user_activity_end) if null? @transaction.log_activity_end(id, UnionStationHooks.now, has_error) end
Logs timing information about the rendering of a single view, template or partial.
Unlike {#log_view_rendering_block}, this form does not expect a block. However, you are expected to pass timing information to the options hash.
The `union_station_hooks_rails` gem automatically calls {#log_view_rendering_block} for you if your application is a Rails app. It will call this on every view or partial rendering.
@option options [String] :name Name of the view, template or partial
that is being rendered.
@option options [TimePoint or Time] :begin_time The time at which this
view rendering begun. See {UnionStationHooks.now} to learn more.
@option options [TimePoint or Time] :end_time The time at which this view
rendering ended. See {UnionStationHooks.now} to learn more.
@option options [Boolean] :has_error (optional) Whether an uncaught
exception occurred during the view rendering. Default: false.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/view_rendering.rb, line 72 def log_view_rendering(options) return do_nothing_on_null(:log_view_rendering) if null? Utils.require_key(options, :name) Utils.require_key(options, :begin_time) Utils.require_key(options, :end_time) @transaction.log_activity(next_view_rendering_name, options[:begin_time], options[:end_time], options[:name], options[:has_error]) end
Logs timing information about the rendering of a single view, template or partial. This form expects a block, which is to perform the view/template/partial rendering. Timing information is collected before and after the block returns.
The `union_station_hooks_rails` gem automatically calls this for you if your application is a Rails app. It will call this on every view or partial rendering.
@param [String] name Name of the view, template or partial that is being
rendered.
@yield The given block is expected to perform the actual view rendering. @return The return value of the block.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/view_rendering.rb, line 43 def log_view_rendering_block(name, &block) if null? do_nothing_on_null(:log_view_rendering_block) yield else @transaction.log_activity_block(next_view_rendering_name, name, &block) end end
Logs that the application server is about to write out the Rack response body.
This call must be followed by a call to {#log_writing_rack_body_end} some time later.
This is automatically called by Passenger's Rack handler.
@private @return An ID to be passed later to {#log_writing_rack_body_end}.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 149 def log_writing_rack_body_begin return do_nothing_on_null(:log_writing_rack_body_begin) if null? @transaction.log_activity_begin('app writing out response body') nil end
Logs that the application server is done writing out the Rack response body. This does not necessarily indicate that any buffering mechanism in between the app and the client (e.g. Nginx, or the Passenger core) is done flushing the response to the client.
This is automatically called by Passenger's Rack handler.
@private
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb, line 163 def log_writing_rack_body_end(id) return do_nothing_on_null(:log_writing_rack_body_end) if null? @transaction.log_activity_end('app writing out response body') nil end
Returns whether is this RequestReporter object is in null mode. See the {RequestReporter class description} for more information.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb, line 130 def null? @transaction.null? end
Private Instance Methods
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb, line 179 def build_full_controller_action_string(options) if options[:controller_name] Utils.require_key(options, :action_name) @controller_action = "#{options[:controller_name]}#" "#{options[:action_name]}" end end
Other methods are implemented in the files in the 'request_reporter/' subdirectory.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb, line 139 def continue_transaction @context.continue_transaction(@txn_id, @app_group_name, :requests, @key) end
Called when one of the methods return early upon detecting null mode. Used by tests to verify that methods return early.
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb, line 146 def do_nothing_on_null(_source) # Do nothing by default. Tests will stub this. end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 287 def next_benchmark_name result = @next_benchmark_number @next_benchmark_number += 1 "benchmark #{result}" end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 293 def next_database_query_name result = @next_database_query_number @next_database_query_number += 1 "database query #{result}" end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb, line 281 def next_user_activity_name result = @next_user_activity_number @next_user_activity_number += 1 "user activity #{result}" end
# File src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/view_rendering.rb, line 85 def next_view_rendering_name result = @next_view_rendering_number @next_view_rendering_number += 1 "view rendering #{result}" end