passenger 5.2.3 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG +13 -0
- data/CONTRIBUTORS +5 -1
- data/build/agent.rb +22 -2
- data/build/cxx_tests.rb +41 -5
- data/build/misc.rb +4 -1
- data/build/support/cxx_dependency_map.rb +1746 -908
- data/build/support/vendor/cxx_hinted_parser/CxxHintedParser.sublime-project +8 -0
- data/build/support/vendor/cxx_hinted_parser/Gemfile +5 -0
- data/build/support/vendor/cxx_hinted_parser/Gemfile.lock +30 -0
- data/{src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core → build/support/vendor/cxx_hinted_parser}/LICENSE.md +1 -1
- data/build/support/vendor/cxx_hinted_parser/README.md +95 -0
- data/build/support/vendor/cxx_hinted_parser/Rakefile +4 -0
- data/{src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/initialize.rb → build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser.rb} +2 -9
- data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser/parser.rb +239 -0
- data/dev/ci/README.md +15 -2
- data/dev/ci/lib/set-container-envvars.sh +6 -0
- data/dev/ci/lib/setup-container.sh +4 -1
- data/dev/ci/scripts/debug-console-wrapper.sh +3 -1
- data/dev/ci/setup-host +5 -0
- data/dev/ci/tests/binaries/Jenkinsfile +105 -0
- data/dev/ci/tests/binaries/build-linux +38 -0
- data/dev/ci/tests/binaries/build-macos +40 -0
- data/dev/ci/tests/binaries/prepare-macos +38 -0
- data/dev/ci/tests/binaries/test-linux +45 -0
- data/dev/ci/tests/binaries/test-macos +38 -0
- data/dev/ci/tests/debian/Jenkinsfile +2 -2
- data/dev/ci/tests/rpm/Jenkinsfile +1 -1
- data/dev/configkit-schemas/index.json +3 -24
- data/dev/vagrant/nginx_rakefile +0 -1
- data/package.json +15 -5
- data/resources/templates/error_renderer/.editorconfig +19 -0
- data/resources/templates/error_renderer/with_details/README.md +9 -0
- data/resources/templates/error_renderer/with_details/dist/bundle.js +33 -0
- data/resources/templates/error_renderer/with_details/dist/styles.css +17 -0
- data/resources/templates/error_renderer/with_details/src/DetailsView.jsx +52 -0
- data/resources/templates/error_renderer/with_details/src/GetHelpView.jsx +61 -0
- data/resources/templates/error_renderer/with_details/src/JourneyView.css +50 -0
- data/resources/templates/error_renderer/with_details/src/JourneyView.jsx +621 -0
- data/resources/templates/error_renderer/with_details/src/PageMain.css +114 -0
- data/resources/templates/error_renderer/with_details/src/PageMain.jsx +136 -0
- data/resources/templates/error_renderer/with_details/src/ProblemDescriptionView.jsx +14 -0
- data/resources/templates/error_renderer/with_details/src/ProcessDetailsView.jsx +56 -0
- data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.css +5 -0
- data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.jsx +15 -0
- data/resources/templates/error_renderer/with_details/src/SummaryView.jsx +35 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentView.css +34 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentView.jsx +168 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentsView.css +13 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentsView.jsx +116 -0
- data/resources/templates/error_renderer/with_details/src/Tab.jsx +12 -0
- data/resources/templates/error_renderer/with_details/src/Tabs.jsx +104 -0
- data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.css +3446 -0
- data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.js +293 -0
- data/resources/templates/error_renderer/with_details/src/bootstrap/config.json +401 -0
- data/resources/templates/error_renderer/with_details/src/index.html.template +22 -0
- data/resources/templates/error_renderer/with_details/src/index.jsx +23 -0
- data/resources/templates/error_renderer/with_details/webpack.config.js +47 -0
- data/resources/templates/error_renderer/without_details/dist/bundle.js +1 -0
- data/resources/templates/error_renderer/without_details/dist/styles.css +1 -0
- data/resources/templates/{undisclosed_error.html.template → error_renderer/without_details/src/index.html.template} +7 -11
- data/resources/templates/error_renderer/without_details/src/index.js +1 -0
- data/resources/templates/{error_layout.css → error_renderer/without_details/src/main.css} +5 -2
- data/resources/templates/error_renderer/without_details/webpack.config.js +42 -0
- data/src/agent/AgentMain.cpp +3 -3
- data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +13 -0
- data/src/agent/Core/ApplicationPool/Common.h +3 -4
- data/src/agent/Core/ApplicationPool/Context.h +27 -17
- data/src/agent/Core/ApplicationPool/Group.h +3 -1
- data/src/agent/Core/ApplicationPool/Group/InitializationAndShutdown.cpp +2 -12
- data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +55 -10
- data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/SpawningAndRestarting.cpp +13 -6
- data/src/agent/Core/ApplicationPool/Implementation.cpp +16 -100
- data/src/agent/Core/ApplicationPool/Options.h +8 -65
- data/src/agent/Core/ApplicationPool/Pool.h +4 -21
- data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +1 -60
- data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +10 -13
- data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +3 -8
- data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +2 -34
- data/src/agent/Core/ApplicationPool/Pool/StateInspection.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Process.cpp +17 -12
- data/src/agent/Core/ApplicationPool/Process.h +146 -93
- data/src/agent/Core/ApplicationPool/Session.h +2 -2
- data/src/agent/Core/ApplicationPool/Socket.h +28 -27
- data/src/agent/Core/Config.h +1 -3
- data/src/agent/Core/ConfigChange.cpp +2 -4
- data/src/agent/Core/Controller.h +2 -8
- data/src/agent/Core/Controller/BufferBody.cpp +0 -2
- data/src/agent/Core/Controller/CheckoutSession.cpp +12 -24
- data/src/agent/Core/Controller/Config.h +1 -9
- data/src/agent/Core/Controller/ForwardResponse.cpp +0 -34
- data/src/agent/Core/Controller/Hooks.cpp +0 -7
- data/src/agent/Core/Controller/InitRequest.cpp +0 -43
- data/src/agent/Core/Controller/InitializationAndShutdown.cpp +0 -4
- data/src/agent/Core/Controller/Request.h +1 -35
- data/src/agent/Core/Controller/SendRequest.cpp +0 -32
- data/src/agent/Core/CoreMain.cpp +19 -32
- data/src/agent/Core/SpawningKit/Config.h +329 -55
- data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +369 -0
- data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h.cxxcodebuilder +307 -0
- data/src/agent/Core/SpawningKit/Context.h +211 -0
- data/src/agent/Core/SpawningKit/DirectSpawner.h +112 -122
- data/src/agent/Core/SpawningKit/DummySpawner.h +59 -20
- data/src/agent/Core/SpawningKit/ErrorRenderer.h +117 -0
- data/src/agent/Core/SpawningKit/Exceptions.h +1157 -0
- data/src/agent/Core/SpawningKit/Factory.h +24 -17
- data/src/agent/Core/SpawningKit/{BackgroundIOCapturer.h → Handshake/BackgroundIOCapturer.h} +48 -18
- data/src/agent/Core/SpawningKit/Handshake/Perform.h +1650 -0
- data/src/agent/Core/SpawningKit/Handshake/Prepare.h +582 -0
- data/src/agent/Core/SpawningKit/Handshake/Session.h +91 -0
- data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +100 -0
- data/src/agent/Core/SpawningKit/Journey.h +561 -0
- data/src/agent/Core/SpawningKit/PipeWatcher.h +41 -18
- data/src/agent/Core/SpawningKit/README.md +534 -0
- data/src/agent/Core/SpawningKit/Result.h +182 -7
- data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +69 -0
- data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h.cxxcodebuilder +110 -0
- data/src/agent/Core/SpawningKit/SmartSpawner.h +1027 -562
- data/src/agent/Core/SpawningKit/Spawner.h +70 -1134
- data/src/agent/Core/SpawningKit/UserSwitchingRules.h +3 -33
- data/src/agent/README.md +2 -3
- data/src/agent/Shared/ApiServerUtils.h +2 -3
- data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +932 -0
- data/src/agent/Watchdog/Config.h +1 -3
- data/src/agent/Watchdog/WatchdogMain.cpp +2 -1
- data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +5 -0
- data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
- data/src/apache2_module/ConfigGeneral/ManifestGeneration.h +22 -13
- data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +5 -0
- data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +3 -0
- data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +13 -0
- data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +7 -0
- data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +13 -0
- data/src/cxx_supportlib/Constants.h +3 -1
- data/src/cxx_supportlib/Exceptions.h +0 -121
- data/src/cxx_supportlib/LoggingKit/Implementation.cpp +7 -6
- data/src/cxx_supportlib/LoggingKit/Logging.h +3 -1
- data/src/cxx_supportlib/Utils.cpp +42 -0
- data/src/cxx_supportlib/Utils.h +7 -0
- data/src/cxx_supportlib/Utils/IOUtils.cpp +58 -0
- data/src/cxx_supportlib/Utils/IOUtils.h +13 -0
- data/src/cxx_supportlib/Utils/JsonUtils.h +130 -23
- data/src/cxx_supportlib/Utils/ScopeGuard.h +9 -4
- data/src/cxx_supportlib/Utils/StrIntUtils.cpp +7 -0
- data/src/cxx_supportlib/Utils/StrIntUtils.h +1 -0
- data/src/cxx_supportlib/Utils/SystemTime.h +1 -1
- data/src/cxx_supportlib/Utils/Timer.h +1 -1
- data/src/cxx_supportlib/WebSocketCommandReverseServer.h +6 -4
- data/src/cxx_supportlib/vendor-copy/adhoc_lve.h +1 -0
- data/src/helper-scripts/node-loader.js +54 -59
- data/src/helper-scripts/rack-loader.rb +63 -60
- data/src/helper-scripts/rack-preloader.rb +125 -72
- data/src/helper-scripts/wsgi-loader.py +100 -43
- data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +120 -112
- data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +15 -8
- data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +142 -142
- data/src/nginx_module/ConfigGeneral/ManifestGeneration.c +26 -15
- data/src/nginx_module/ConfigGeneral/ManifestGeneration.h +3 -0
- data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +76 -70
- data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c +114 -99
- data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +170 -156
- data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +38 -35
- data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +5 -1
- data/src/ruby_supportlib/phusion_passenger.rb +5 -5
- data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +14 -1
- data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +8 -0
- data/src/ruby_supportlib/phusion_passenger/common_library.rb +0 -3
- data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +0 -1
- data/src/ruby_supportlib/phusion_passenger/constants.rb +2 -0
- data/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb +646 -238
- data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +117 -95
- data/src/ruby_supportlib/phusion_passenger/packaging.rb +0 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +5 -1
- data/src/ruby_supportlib/phusion_passenger/preloader_shared_helpers.rb +92 -69
- data/src/ruby_supportlib/phusion_passenger/public_api.rb +0 -17
- data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +0 -3
- data/src/ruby_supportlib/phusion_passenger/request_handler.rb +4 -5
- data/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb +0 -22
- metadata +64 -67
- data/resources/templates/error_layout.html.template +0 -86
- data/resources/templates/general_error.html.template +0 -1
- data/resources/templates/general_error_with_html.html.template +0 -1
- data/src/agent/Core/ApplicationPool/ErrorRenderer.h +0 -131
- data/src/agent/Core/SpawningKit/Options.h +0 -41
- data/src/agent/Core/UnionStation/Connection.h +0 -173
- data/src/agent/Core/UnionStation/Context.h +0 -536
- data/src/agent/Core/UnionStation/StopwatchLog.h +0 -147
- data/src/agent/Core/UnionStation/Transaction.h +0 -249
- data/src/agent/SpawnPreparer/SpawnPreparerMain.cpp +0 -208
- data/src/cxx_supportlib/UnionStationFilterSupport.cpp +0 -67
- data/src/cxx_supportlib/UnionStationFilterSupport.h +0 -1622
- data/src/nodejs_supportlib/phusion_passenger/log_express.js +0 -106
- data/src/nodejs_supportlib/phusion_passenger/log_mongodb.js +0 -202
- data/src/nodejs_supportlib/phusion_passenger/ustreporter.js +0 -227
- data/src/nodejs_supportlib/phusion_passenger/ustrouter_connector.js +0 -448
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/CONFIG.md +0 -37
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile +0 -17
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile.lock +0 -59
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README-API.md +0 -5
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README.md +0 -117
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Rakefile +0 -115
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +0 -423
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +0 -238
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/connection.rb +0 -67
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +0 -281
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/lock.rb +0 -62
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/log.rb +0 -66
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/message_channel.rb +0 -157
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +0 -150
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb +0 -199
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb +0 -187
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb +0 -303
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/view_rendering.rb +0 -91
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +0 -396
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/spec_helper.rb +0 -279
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/time_point.rb +0 -39
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +0 -173
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +0 -177
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version.rb +0 -32
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +0 -44
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.example +0 -16
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +0 -20
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +0 -18
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/union_station_hooks_core.gemspec +0 -23
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile +0 -14
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile.lock +0 -45
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/LICENSE.md +0 -19
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/README.md +0 -104
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Rakefile +0 -160
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb +0 -200
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_controller_extension.rb +0 -45
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_view_subscriber.rb +0 -55
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_record_subscriber.rb +0 -41
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_benchmarkable_extension.rb +0 -47
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_cache_subscriber.rb +0 -79
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/exception_logger.rb +0 -57
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version.rb +0 -32
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version_data.rb +0 -44
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/union_station_hooks_rails.gemspec +0 -34
@@ -1,187 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2010-2015 Phusion Holding B.V.
|
3
|
-
#
|
4
|
-
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
23
|
-
|
24
|
-
UnionStationHooks.require_lib 'utils'
|
25
|
-
|
26
|
-
module UnionStationHooks
|
27
|
-
class RequestReporter
|
28
|
-
###### Logging controller-related information ######
|
29
|
-
|
30
|
-
# Logs that you are calling a web framework controller action. Of course,
|
31
|
-
# you should only call this if your web framework has the concept of
|
32
|
-
# controller actions. For example Rails does, but Sinatra and Grape
|
33
|
-
# don't.
|
34
|
-
#
|
35
|
-
# This form takes an options hash as well as a block. You can pass
|
36
|
-
# additional information about the web framework controller action, which
|
37
|
-
# will be logged. The block is expected to perform the actual request
|
38
|
-
# handling. When the block returns, timing information about the block is
|
39
|
-
# automatically logged.
|
40
|
-
#
|
41
|
-
# See also {#log_controller_action} for a form that doesn't
|
42
|
-
# expect a block.
|
43
|
-
#
|
44
|
-
# The `union_station_hooks_rails` gem automatically calls this for you
|
45
|
-
# if your application is a Rails app.
|
46
|
-
#
|
47
|
-
# @yield The given block is expected to perform request handling.
|
48
|
-
# @param [Hash] options Information about the controller action.
|
49
|
-
# All options are optional.
|
50
|
-
# @option options [String] :controller_name
|
51
|
-
# The controller's name, e.g. `PostsController`.
|
52
|
-
# @option options [String] :action_name
|
53
|
-
# The controller action's name, e.g. `create`.
|
54
|
-
# @option options [String] :method
|
55
|
-
# The HTTP method that the web framework thinks this request should have,
|
56
|
-
# e.g. `GET` and `PUT`. The main use case for this option is to support
|
57
|
-
# Rails's HTTP verb emulation. Rails uses a parameter named
|
58
|
-
# [`_method`](http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark)
|
59
|
-
# to emulate HTTP verbs besides GET and POST. Other web frameworks may
|
60
|
-
# have a similar mechanism.
|
61
|
-
# @return The return value of the block.
|
62
|
-
#
|
63
|
-
# @example Rails example
|
64
|
-
# # This example shows what to put inside a Rails controller action
|
65
|
-
# # method. Note that all of this is automatically done for you if you
|
66
|
-
# # use the union_station_hooks_rails gem.
|
67
|
-
# options = {
|
68
|
-
# :controller_name => self.class.name,
|
69
|
-
# :action_name => action_name,
|
70
|
-
# :method => request.request_method
|
71
|
-
# }
|
72
|
-
# reporter.log_controller_action_block(options) do
|
73
|
-
# do_some_request_processing_here
|
74
|
-
# end
|
75
|
-
def log_controller_action_block(options = {})
|
76
|
-
if null?
|
77
|
-
do_nothing_on_null(:log_controller_action_block)
|
78
|
-
yield
|
79
|
-
else
|
80
|
-
build_full_controller_action_string(options)
|
81
|
-
has_error = true
|
82
|
-
begin_time = UnionStationHooks.now
|
83
|
-
begin
|
84
|
-
result = yield
|
85
|
-
has_error = false
|
86
|
-
result
|
87
|
-
ensure
|
88
|
-
log_controller_action(
|
89
|
-
options.merge(
|
90
|
-
:begin_time => begin_time,
|
91
|
-
:end_time => UnionStationHooks.now,
|
92
|
-
:has_error => has_error
|
93
|
-
)
|
94
|
-
)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Logs that you are calling a web framework controller action. Of course,
|
100
|
-
# you should only call this if your web framework has the concept of
|
101
|
-
# controller actions. For example Rails does, but Sinatra and Grape
|
102
|
-
# don't.
|
103
|
-
#
|
104
|
-
# You can pass additional information about the web framework controller
|
105
|
-
# action, which will be logged.
|
106
|
-
#
|
107
|
-
# Unlike {#log_controller_action_block}, this form does not expect a block.
|
108
|
-
# However, you are expected to pass timing information to the options
|
109
|
-
# hash.
|
110
|
-
#
|
111
|
-
# The `union_station_hooks_rails` gem automatically calls
|
112
|
-
# {#log_controller_action_block} for you if your application is a Rails
|
113
|
-
# app.
|
114
|
-
#
|
115
|
-
# @param [Hash] options Information about the controller action.
|
116
|
-
# @option options [String] :controller_name (optional)
|
117
|
-
# The controller's name, e.g. `PostsController`.
|
118
|
-
# @option options [String] :action_name (optional if :controller_name
|
119
|
-
# isn't set) The controller action's name, e.g. `create`.
|
120
|
-
# @option options [String] :method (optional)
|
121
|
-
# The HTTP method that the web framework thinks this request should have,
|
122
|
-
# e.g. `GET` and `PUT`. The main use case for this option is to support
|
123
|
-
# Rails's HTTP verb emulation. Rails uses a parameter named
|
124
|
-
# [`_method`](http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark)
|
125
|
-
# to emulate HTTP verbs besides GET and POST. Other web frameworks may
|
126
|
-
# have a similar mechanism.
|
127
|
-
# @option options [TimePoint or Time] :begin_time The time at which the
|
128
|
-
# controller action begun. See {UnionStationHooks.now} to learn more.
|
129
|
-
# @option options [TimePoint or Time] :end_time The time at which the
|
130
|
-
# controller action ended. See {UnionStationHooks.now} to learn more.
|
131
|
-
# @option options [Boolean] :has_error (optional) Whether an uncaught
|
132
|
-
# exception occurred during the request. Default: false.
|
133
|
-
#
|
134
|
-
# @example
|
135
|
-
# # This example shows what to put inside a Rails controller action
|
136
|
-
# # method. Note that all of this is automatically done for you if you
|
137
|
-
# # use the union_station_hooks_rails gem.
|
138
|
-
# options = {
|
139
|
-
# :controller_name => self.class.name,
|
140
|
-
# :action_name => action_name,
|
141
|
-
# :method => request.request_method,
|
142
|
-
# :begin_time => UnionStationHooks.now
|
143
|
-
# }
|
144
|
-
# begin
|
145
|
-
# do_some_request_processing_here
|
146
|
-
# rescue Exception
|
147
|
-
# options[:has_error] = true
|
148
|
-
# raise
|
149
|
-
# ensure
|
150
|
-
# options[:end_time] = UnionStationHooks.now
|
151
|
-
# reporter.log_controller_action(options)
|
152
|
-
# end
|
153
|
-
def log_controller_action(options)
|
154
|
-
return do_nothing_on_null(:log_controller_action) if null?
|
155
|
-
Utils.require_key(options, :begin_time)
|
156
|
-
Utils.require_key(options, :end_time)
|
157
|
-
|
158
|
-
if options[:controller_name]
|
159
|
-
build_full_controller_action_string(options)
|
160
|
-
@transaction.message("Controller action: #{@controller_action}")
|
161
|
-
end
|
162
|
-
if options[:method]
|
163
|
-
@transaction.message("Application request method: #{options[:method]}")
|
164
|
-
end
|
165
|
-
@transaction.log_activity('framework request processing',
|
166
|
-
options[:begin_time], options[:end_time], nil, options[:has_error])
|
167
|
-
end
|
168
|
-
|
169
|
-
# Returns whether {#log_controller_action_block} or
|
170
|
-
# {#log_controller_action} has been called during this request.
|
171
|
-
#
|
172
|
-
# @return [Boolean]
|
173
|
-
def controller_action_logged?
|
174
|
-
!!@controller_action
|
175
|
-
end
|
176
|
-
|
177
|
-
private
|
178
|
-
|
179
|
-
def build_full_controller_action_string(options)
|
180
|
-
if options[:controller_name]
|
181
|
-
Utils.require_key(options, :action_name)
|
182
|
-
@controller_action = "#{options[:controller_name]}#" \
|
183
|
-
"#{options[:action_name]}"
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
@@ -1,303 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2010-2015 Phusion Holding B.V.
|
3
|
-
#
|
4
|
-
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
23
|
-
|
24
|
-
UnionStationHooks.require_lib 'utils'
|
25
|
-
|
26
|
-
module UnionStationHooks
|
27
|
-
class RequestReporter
|
28
|
-
###### Logging miscellaneous other information ######
|
29
|
-
|
30
|
-
# Logs a user-defined activity, for display in the activity timeline.
|
31
|
-
#
|
32
|
-
# An activity is a block in the activity timeline in the Union Station
|
33
|
-
# user interace. It has a name, a begin time and an end time.
|
34
|
-
#
|
35
|
-
# This form takes a block. Before and after the block runs, the time
|
36
|
-
# is measured.
|
37
|
-
#
|
38
|
-
# @param name The name that should show up in the activity timeline.
|
39
|
-
# It can be any arbitrary name but may not contain newlines.
|
40
|
-
# @return The return value of the block.
|
41
|
-
# @yield The block is expected to perform the activity.
|
42
|
-
# @example
|
43
|
-
# reporter.log_user_activity_block('Preheat cache') do
|
44
|
-
# calculate_preheat_values.each_pair do |key, value|
|
45
|
-
# Rails.cache.write(key, value)
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
def log_user_activity_block(name, &block)
|
49
|
-
if null?
|
50
|
-
do_nothing_on_null(:log_user_activity_block)
|
51
|
-
yield
|
52
|
-
else
|
53
|
-
@transaction.log_activity_block(next_user_activity_name,
|
54
|
-
name, &block)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Logs the begin of a user-defined activity, for display in the
|
59
|
-
# activity timeline.
|
60
|
-
#
|
61
|
-
# An activity is a block in the activity timeline in the Union Station
|
62
|
-
# user interace. It has a name, a begin time and an end time.
|
63
|
-
#
|
64
|
-
# This form logs only the name and the begin time. You *must* also
|
65
|
-
# call {#log_user_activity_end} later with the same name to log the end
|
66
|
-
# time.
|
67
|
-
#
|
68
|
-
# @param name The name that should show up in the activity timeline.
|
69
|
-
# It can be any arbitrary name but may not contain newlines.
|
70
|
-
# @return id An ID which you must pass to {#log_user_activity_end} later.
|
71
|
-
def log_user_activity_begin(name)
|
72
|
-
return do_nothing_on_null(:log_user_activity_begin) if null?
|
73
|
-
id = next_user_activity_name
|
74
|
-
@transaction.log_activity_begin(id, UnionStationHooks.now, name)
|
75
|
-
id
|
76
|
-
end
|
77
|
-
|
78
|
-
# Logs the end of a user-defined activity, for display in the
|
79
|
-
# activity timeline.
|
80
|
-
#
|
81
|
-
# An activity is a block in the activity timeline in the Union Station
|
82
|
-
# user interace. It has a name, a begin time and an end time.
|
83
|
-
#
|
84
|
-
# This form logs only the name and the end time. You *must* also
|
85
|
-
# have called {#log_user_activity_begin} earlier with the same name to log
|
86
|
-
# the begin time.
|
87
|
-
#
|
88
|
-
# @param id The ID which you obtained from {#log_user_activity_begin}
|
89
|
-
# earlier.
|
90
|
-
# @param [Boolean] has_error Whether an uncaught
|
91
|
-
# exception occurred during the activity.
|
92
|
-
def log_user_activity_end(id, has_error = false)
|
93
|
-
return do_nothing_on_null(:log_user_activity_end) if null?
|
94
|
-
@transaction.log_activity_end(id, UnionStationHooks.now, has_error)
|
95
|
-
end
|
96
|
-
|
97
|
-
# Logs a user-defined activity, for display in the activity timeline.
|
98
|
-
#
|
99
|
-
# An activity is a block in the activity timeline in the Union Station
|
100
|
-
# user interace. It has a name, a begin time and an end time.
|
101
|
-
#
|
102
|
-
# Unlike {#log_user_activity_block}, this form does not expect a block.
|
103
|
-
# However, you are expected to pass timing information.
|
104
|
-
#
|
105
|
-
# @param name The name that should show up in the activity timeline.
|
106
|
-
# It can be any arbitrary name but may not contain newlines.
|
107
|
-
# @param [TimePoint or Time] begin_time The time at which this activity
|
108
|
-
# begun. See {UnionStationHooks.now} to learn more.
|
109
|
-
# @param [TimePoint or Time] end_time The time at which this activity
|
110
|
-
# ended. See {UnionStationHooks.now} to learn more.
|
111
|
-
# @param [Boolean] has_error Whether an uncaught
|
112
|
-
# exception occurred during the activity.
|
113
|
-
def log_user_activity(name, begin_time, end_time, has_error = false)
|
114
|
-
return do_nothing_on_null(:log_user_activity) if null?
|
115
|
-
@transaction.log_activity(next_user_activity_name,
|
116
|
-
begin_time, end_time, name, has_error)
|
117
|
-
end
|
118
|
-
|
119
|
-
# Logs a benchmarking activity, for display in the activity timeline.
|
120
|
-
#
|
121
|
-
# An activity is a block in the activity timeline in the Union Station
|
122
|
-
# user interace. It has a name, a begin time and an end time.
|
123
|
-
#
|
124
|
-
# The primary use case of this method is to integrate with Rails's
|
125
|
-
# benchmarking API (`ActiveSupport::Benchmarkable`). The Rails benchmarking
|
126
|
-
# API allows you to run a block and to log how long that block has taken.
|
127
|
-
# But you can also use it to integrate with the Ruby standard library's
|
128
|
-
# `Benchmark` class.
|
129
|
-
#
|
130
|
-
# You can wrap a benchmark call in a
|
131
|
-
# `UnionStationHooks.log_benchmark_block` call, so that an entry for it is
|
132
|
-
# displayed in the acitivity timeline. This method measures the time before
|
133
|
-
# and after the block runs.
|
134
|
-
#
|
135
|
-
# The difference between this method and {#log_user_activity_block} is that
|
136
|
-
# this method generates timeline blocks of a different color, as to
|
137
|
-
# differentiate user-defined activities from benchmark activities.
|
138
|
-
#
|
139
|
-
# If your app is a Rails app, then the `union_station_hooks_rails` gem
|
140
|
-
# automatically calls this for you every time
|
141
|
-
# `ActiveSupport::Benchmarkable#benchmark` is called. This includes
|
142
|
-
# `benchmark` calls from controllers and from views.
|
143
|
-
#
|
144
|
-
# @param title A title for this benchmark. It can be any arbitrary name but
|
145
|
-
# may not contain newlines.
|
146
|
-
# @return The return value of the block.
|
147
|
-
# @yield The block is expected to perform the benchmarking activity.
|
148
|
-
# @example Rails example
|
149
|
-
# # This example shows what to put inside a Rails controller action
|
150
|
-
# # method. Note that the `log_benchmark_block` call is automatically done
|
151
|
-
# # for you if you use the union_station_hooks_rails gem.
|
152
|
-
# UnionStationHooks.log_benchmark_block('Process data files') do
|
153
|
-
# benchmark('Process data files') do
|
154
|
-
# expensive_files_operation
|
155
|
-
# end
|
156
|
-
# end
|
157
|
-
def log_benchmark_block(title = 'Benchmarking', &block)
|
158
|
-
if null?
|
159
|
-
do_nothing_on_null(:log_benchmark_block)
|
160
|
-
yield
|
161
|
-
else
|
162
|
-
@transaction.log_activity_block(next_benchmark_name,
|
163
|
-
title, &block)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
# Logs an exception that occurred during a request.
|
168
|
-
#
|
169
|
-
# If you want to use an exception that occurred outside the
|
170
|
-
# request/response cycle, e.g. an exception that occurred in a thread,
|
171
|
-
# use {UnionStationHooks.log_exception} instead.
|
172
|
-
#
|
173
|
-
# If {#log_controller_action_block} or {#log_controller_action}
|
174
|
-
# was called during the same request, then the information passed to
|
175
|
-
# those methods will be included in the exception report.
|
176
|
-
#
|
177
|
-
# @param [Exception] exception
|
178
|
-
def log_exception(exception)
|
179
|
-
transaction = @context.new_transaction(
|
180
|
-
@app_group_name,
|
181
|
-
:exceptions,
|
182
|
-
@key)
|
183
|
-
begin
|
184
|
-
return do_nothing_on_null(:log_exception) if transaction.null?
|
185
|
-
|
186
|
-
base64_message = exception.message
|
187
|
-
base64_message = exception.to_s if base64_message.empty?
|
188
|
-
base64_message = Utils.base64(base64_message)
|
189
|
-
base64_backtrace = Utils.base64(exception.backtrace.join("\n"))
|
190
|
-
|
191
|
-
if controller_action_logged?
|
192
|
-
transaction.message("Controller action: #{@controller_action}")
|
193
|
-
end
|
194
|
-
transaction.message("Request transaction ID: #{@txn_id}")
|
195
|
-
transaction.message("Message: #{base64_message}")
|
196
|
-
transaction.message("Class: #{exception.class.name}")
|
197
|
-
transaction.message("Backtrace: #{base64_backtrace}")
|
198
|
-
ensure
|
199
|
-
transaction.close
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
# Logs a database query that was performed during the request.
|
204
|
-
#
|
205
|
-
# @option options [String] :name (optional) A name for this database
|
206
|
-
# query activity. Default: "SQL"
|
207
|
-
# @option options [TimePoint or Time] :begin_time The time at which this
|
208
|
-
# database query begun. See {UnionStationHooks.now} to learn more.
|
209
|
-
# @option options [TimePoint or Time] :end_time The time at which this
|
210
|
-
# database query ended. See {UnionStationHooks.now} to learn more.
|
211
|
-
# @option options [String] :query The database query string.
|
212
|
-
def log_database_query(options)
|
213
|
-
return do_nothing_on_null(:log_database_query) if null?
|
214
|
-
Utils.require_key(options, :begin_time)
|
215
|
-
Utils.require_key(options, :end_time)
|
216
|
-
Utils.require_non_empty_key(options, :query)
|
217
|
-
|
218
|
-
name = options[:name] || 'SQL'
|
219
|
-
begin_time = options[:begin_time]
|
220
|
-
end_time = options[:end_time]
|
221
|
-
query = options[:query]
|
222
|
-
|
223
|
-
@transaction.log_activity(next_database_query_name,
|
224
|
-
begin_time, end_time, "#{name}\n#{query}")
|
225
|
-
end
|
226
|
-
|
227
|
-
# Logs that something was successfully retrieved from a cache.
|
228
|
-
# This can be any cache, be it an in-memory Hash, Redis, Memcached, a
|
229
|
-
# flat file or whatever.
|
230
|
-
#
|
231
|
-
# There is just one exception. You should not use this method to log cache
|
232
|
-
# hits in the ActiveRecord SQL cache or similar mechanisms.
|
233
|
-
# Database-related timing should be logged with {#log_database_query}.
|
234
|
-
#
|
235
|
-
# If your app is a Rails app, then the `union_station_hooks_rails` gem
|
236
|
-
# automatically calls this for you every time an `ActiveSupport::Cache`
|
237
|
-
# `#fetch` or `#read` call success. This includes calls to
|
238
|
-
# `Rails.cache.fetch` or `Rails.cache.read`, because `Rails.cache` is
|
239
|
-
# an instance of `ActiveSupport::Cache`.
|
240
|
-
#
|
241
|
-
# @param [String] name A unique name for this cache hit event. The cache
|
242
|
-
# key is a good value to use.
|
243
|
-
# @note At present (30 September 2015), logged cache hit/miss information
|
244
|
-
# isn't shown in the Union Station interface. We may implement this
|
245
|
-
# feature in the near future.
|
246
|
-
def log_cache_hit(name)
|
247
|
-
return do_nothing_on_null(:log_cache_hit) if null?
|
248
|
-
@transaction.message("Cache hit: #{name}")
|
249
|
-
end
|
250
|
-
|
251
|
-
# Logs the failure to retrieve something from a cache.
|
252
|
-
# This can be any cache, be it an in-memory Hash, Redis, Memcached, a
|
253
|
-
# flat file or whatever.
|
254
|
-
#
|
255
|
-
# There is just one exception. You should not use this method to log cache
|
256
|
-
# misses in the ActiveRecord SQL cache or similar mechanisms.
|
257
|
-
# Database-related timing should be logged with {#log_database_query}.
|
258
|
-
#
|
259
|
-
# If your app is a Rails app, then the `union_station_hooks_rails` gem
|
260
|
-
# automatically calls this for you every time an `ActiveSupport::Cache`
|
261
|
-
# `#fetch` or `#read` call success. This includes calls to
|
262
|
-
# `Rails.cache.fetch` or `Rails.cache.read`, because `Rails.cache` is
|
263
|
-
# an instance of `ActiveSupport::Cache`.
|
264
|
-
#
|
265
|
-
# @param [String] name A unique name for this cache miss event. The cache
|
266
|
-
# key is a good value to use.
|
267
|
-
# @param [Numeric] miss_cost_duration The amount of time that was spent in
|
268
|
-
# calculating or processing something, as a result of this cache miss.
|
269
|
-
# This time is in **microseconds**.
|
270
|
-
# @note At present (30 September 2015), logged cache hit/miss information
|
271
|
-
# isn't shown in the Union Station interface. We may implement this
|
272
|
-
# feature in the near future.
|
273
|
-
def log_cache_miss(name, miss_cost_duration = nil)
|
274
|
-
return do_nothing_on_null(:log_cache_miss) if null?
|
275
|
-
if miss_cost_duration
|
276
|
-
@transaction.message("Cache miss (#{miss_cost_duration.to_i} usec): " \
|
277
|
-
"#{name}")
|
278
|
-
else
|
279
|
-
@transaction.message("Cache miss: #{name}")
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
private
|
284
|
-
|
285
|
-
def next_user_activity_name
|
286
|
-
result = @next_user_activity_number
|
287
|
-
@next_user_activity_number += 1
|
288
|
-
"user activity #{result}"
|
289
|
-
end
|
290
|
-
|
291
|
-
def next_benchmark_name
|
292
|
-
result = @next_benchmark_number
|
293
|
-
@next_benchmark_number += 1
|
294
|
-
"benchmark #{result}"
|
295
|
-
end
|
296
|
-
|
297
|
-
def next_database_query_name
|
298
|
-
result = @next_database_query_number
|
299
|
-
@next_database_query_number += 1
|
300
|
-
"database query #{result}"
|
301
|
-
end
|
302
|
-
end
|
303
|
-
end
|