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,106 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-2017 Phusion
|
4
|
-
*
|
5
|
-
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
-
*
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
12
|
-
* furnished to do so, subject to the following conditions:
|
13
|
-
*
|
14
|
-
* The above copyright notice and this permission notice shall be included in
|
15
|
-
* all copies or substantial portions of the Software.
|
16
|
-
*
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
-
* THE SOFTWARE.
|
24
|
-
*/
|
25
|
-
|
26
|
-
var ustReporter = global.phusion_passenger_ustReporter;
|
27
|
-
|
28
|
-
var log;
|
29
|
-
var express;
|
30
|
-
|
31
|
-
var applicationThis;
|
32
|
-
|
33
|
-
exports.initPreLoad = function() {
|
34
|
-
log = ustReporter.getPassengerLogger();
|
35
|
-
var appRoot = ustReporter.getApplicationRoot();
|
36
|
-
|
37
|
-
try {
|
38
|
-
express = require(appRoot + "/node_modules/express");
|
39
|
-
} catch (e) {
|
40
|
-
// express not present, no need to instrument.
|
41
|
-
log.debug("Not instrumenting Express (probably not used): " + e);
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
|
45
|
-
try {
|
46
|
-
log.info("==== Instrumentation [Express] ==== initialize");
|
47
|
-
log.debug("hook application.init, to be the first in the use() line..");
|
48
|
-
|
49
|
-
express.application.initOrig = express.application.init;
|
50
|
-
express.application.init = function() {
|
51
|
-
log.debug("Express application.init() called, chain and then be the first to use()..");
|
52
|
-
var rval = express.application.initOrig.apply(this, arguments);
|
53
|
-
|
54
|
-
this.use(logRequest);
|
55
|
-
|
56
|
-
applicationThis = this; // store for initPostLoad use
|
57
|
-
|
58
|
-
return rval;
|
59
|
-
};
|
60
|
-
|
61
|
-
log.debug("Express tap: application.use, to be as late as possible in the use() line, but before any other error handlers..");
|
62
|
-
express.application.useOrig = express.application.use;
|
63
|
-
express.application.use = function() {
|
64
|
-
// Express recognizes error handlers by #params = 4
|
65
|
-
if (arguments[0].length == 4) {
|
66
|
-
express.application.useOrig.call(this, logException);
|
67
|
-
}
|
68
|
-
|
69
|
-
return express.application.useOrig.apply(this, arguments);
|
70
|
-
};
|
71
|
-
} catch (e) {
|
72
|
-
log.error("Unable to instrument Express due to error: " + e);
|
73
|
-
}
|
74
|
-
};
|
75
|
-
|
76
|
-
exports.initPostLoad = function() {
|
77
|
-
if (!express) {
|
78
|
-
return;
|
79
|
-
}
|
80
|
-
|
81
|
-
log.debug("add final error handler..");
|
82
|
-
try {
|
83
|
-
if (applicationThis) {
|
84
|
-
express.application.useOrig.call(applicationThis, logException);
|
85
|
-
}
|
86
|
-
} catch (e) {
|
87
|
-
log.error("Unable to instrument Express error flow due to error: " + e);
|
88
|
-
}
|
89
|
-
};
|
90
|
-
|
91
|
-
function logRequest(req, res, next) {
|
92
|
-
log.verbose("==== Instrumentation [Express] ==== REQUEST [" + req.method + " " + req.url + "] attach");
|
93
|
-
ustReporter.attachToRequest(req, res, next);
|
94
|
-
}
|
95
|
-
|
96
|
-
function logException(err, req, res, next) {
|
97
|
-
// We may have multiple exception handlers in the routing chain, ensure only the first one actually logs.
|
98
|
-
if (!res.hasLoggedException) {
|
99
|
-
log.verbose("==== Instrumentation [Express] ==== EXCEPTION + TRACE FOR [" + req.url + "]");
|
100
|
-
|
101
|
-
ustReporter.logException(err.name, err.message, err.stack);
|
102
|
-
|
103
|
-
res.hasLoggedException = true;
|
104
|
-
}
|
105
|
-
next(err);
|
106
|
-
}
|
@@ -1,202 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-2017 Phusion
|
4
|
-
*
|
5
|
-
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
-
*
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
12
|
-
* furnished to do so, subject to the following conditions:
|
13
|
-
*
|
14
|
-
* The above copyright notice and this permission notice shall be included in
|
15
|
-
* all copies or substantial portions of the Software.
|
16
|
-
*
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
-
* THE SOFTWARE.
|
24
|
-
*/
|
25
|
-
|
26
|
-
var ustReporter = global.phusion_passenger_ustReporter;
|
27
|
-
|
28
|
-
var log;
|
29
|
-
var mongodb;
|
30
|
-
|
31
|
-
// From http://docs.mongodb.org/manual/reference/method/js-collection/
|
32
|
-
var collectionMethods = [
|
33
|
-
"aggregate", "count", "copyTo", "createIndex", "dataSize", "distinct", "drop", "dropIndex", "dropIndexes",
|
34
|
-
"ensureIndex", "explain", "find", "findAndModify", "findOne", "getIndexes", "getShardDistribution", "getShardVersion",
|
35
|
-
"group", "insert", "isCapped", "mapReduce", "reIndex", "remove", "renameCollection", "save", "stats",
|
36
|
-
"storageSize", "totalSize", "totalIndexSize", "update", "validate"
|
37
|
-
];
|
38
|
-
|
39
|
-
function instrumentCollectionMethod(origParent, functionName, newFn) {
|
40
|
-
var originalFn = origParent[functionName];
|
41
|
-
|
42
|
-
// not used yet (unwrapping N/I)
|
43
|
-
origParent["_passenger_wrapped_" + functionName] = originalFn;
|
44
|
-
|
45
|
-
origParent[functionName] = function() {
|
46
|
-
var databaseName;
|
47
|
-
var collectionName;
|
48
|
-
|
49
|
-
if (this.s) {
|
50
|
-
// Plain driver
|
51
|
-
databaseName = this.s.dbName;
|
52
|
-
collectionName = this.s.name;
|
53
|
-
} else if (this.db) {
|
54
|
-
// Mongoskin 1.4.13
|
55
|
-
databaseName = this.db.databaseName;
|
56
|
-
collectionName = this.collectionName;
|
57
|
-
} else if (this._collection_args) {
|
58
|
-
// Mongoskin driver
|
59
|
-
databaseName = this._skin_db._connect_args[0];
|
60
|
-
collectionName = this._collection_args[0];
|
61
|
-
}
|
62
|
-
|
63
|
-
return newFn.call(this, arguments, databaseName, collectionName, functionName, originalFn);
|
64
|
-
};
|
65
|
-
}
|
66
|
-
|
67
|
-
function collectionFn(origArguments, databaseName, collectionName, functionName, originalFn) {
|
68
|
-
var query = "";
|
69
|
-
for (var i = 0; i < origArguments.length; i++) {
|
70
|
-
if (typeof(origArguments[i]) != 'function') { // mongoskin
|
71
|
-
query += (i > 0 ? "," : "") + JSON.stringify(origArguments[i]);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
query = "'" + databaseName + "'.collection['" + collectionName + "']." + functionName + "(" + query + ")";
|
75
|
-
|
76
|
-
var tBegin = ustReporter.nowTimestamp();
|
77
|
-
var rval = originalFn.apply(this, origArguments);
|
78
|
-
var tEnd = ustReporter.nowTimestamp();
|
79
|
-
|
80
|
-
log.verbose("==== Instrumentation [MongoDB] ==== [" + query + "] (attach to txnId " + ustReporter.getCurrentTxnId() + ")");
|
81
|
-
|
82
|
-
ustReporter.logTimedActivityMongo("mongo: " + query, tBegin, tEnd, query);
|
83
|
-
|
84
|
-
return rval;
|
85
|
-
}
|
86
|
-
|
87
|
-
exports.initPreLoad = function() {
|
88
|
-
log = ustReporter.getPassengerLogger();
|
89
|
-
var appRoot = ustReporter.getApplicationRoot();
|
90
|
-
|
91
|
-
// See if the mongodb driver is used. It can also be used through mongoskin, in which case older mongoskin
|
92
|
-
// versions will have it as part of their own node_modules.
|
93
|
-
try {
|
94
|
-
mongodb = require(appRoot + "/node_modules/mongodb");
|
95
|
-
} catch (e1) {
|
96
|
-
try {
|
97
|
-
mongodb = require(appRoot + "/node_modules/mongoskin/node_modules/mongodb");
|
98
|
-
} catch (e2) {
|
99
|
-
log.verbose("Not instrumenting MongoDB (probably not used): (default) " + e1 + ", (mongoskin) " + e2);
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
|
104
|
-
log.info("==== Instrumentation [MongoDB] ==== initialize");
|
105
|
-
|
106
|
-
// The 1.4 mongo driver series uses a callback mechanism that breaks continuation-local-storage.
|
107
|
-
wrapRepairCLSMongo14();
|
108
|
-
|
109
|
-
// Newer mongoskin techniques break continuation-local-storage, so we need to skin the skinner there.
|
110
|
-
wrapRepairCLSMongoskinUtils(appRoot);
|
111
|
-
|
112
|
-
try {
|
113
|
-
for (var i = 0; i < collectionMethods.length; i++) {
|
114
|
-
instrumentCollectionMethod(mongodb.Collection.prototype, collectionMethods[i], collectionFn);
|
115
|
-
}
|
116
|
-
} catch (e) {
|
117
|
-
log.error("Unable to instrument MongoDB due to error: " + e);
|
118
|
-
}
|
119
|
-
};
|
120
|
-
|
121
|
-
function wrapRepairCLSMongo14() {
|
122
|
-
try {
|
123
|
-
if (!mongodb.Db.prototype._executeQueryCommand || mongodb.Db.prototype._executeInsertCommand) {
|
124
|
-
log.verbose("Not using MongoDB 1.4.x, so don't need MongoDB continuation-local-storage workaround");
|
125
|
-
return;
|
126
|
-
}
|
127
|
-
|
128
|
-
mongodb.Db.prototype._passenger_wrapped__executeQueryCommand = mongodb.Db.prototype._executeQueryCommand;
|
129
|
-
mongodb.Db.prototype._executeQueryCommand = function() {
|
130
|
-
if (arguments.length > 0 && typeof(arguments[arguments.length - 1]) === 'function') {
|
131
|
-
var callback = ustReporter.getCLSWrappedCallback(arguments[arguments.length - 1]);
|
132
|
-
var newArgs = [];
|
133
|
-
for (var i = 0; i < arguments.length - 1; i++) {
|
134
|
-
newArgs.push(arguments[i]);
|
135
|
-
}
|
136
|
-
newArgs.push(callback);
|
137
|
-
this._passenger_wrapped__executeQueryCommand.apply(this, newArgs);
|
138
|
-
} else {
|
139
|
-
this._passenger_wrapped__executeQueryCommand.apply(this, arguments);
|
140
|
-
}
|
141
|
-
};
|
142
|
-
|
143
|
-
mongodb.Db.prototype._passenger_wrapped__executeInsertCommand = mongodb.Db.prototype._executeInsertCommand;
|
144
|
-
mongodb.Db.prototype._executeInsertCommand = function() {
|
145
|
-
if (arguments.length > 0 && typeof(arguments[arguments.length - 1]) === 'function') {
|
146
|
-
var callback = ustReporter.getCLSWrappedCallback(arguments[arguments.length - 1]);
|
147
|
-
var newArgs = [];
|
148
|
-
for (var i = 0; i < arguments.length - 1; i++) {
|
149
|
-
newArgs.push(arguments[i]);
|
150
|
-
}
|
151
|
-
newArgs.push(callback);
|
152
|
-
this._passenger_wrapped__executeInsertCommand.apply(this, newArgs);
|
153
|
-
} else {
|
154
|
-
this._passenger_wrapped__executeInsertCommand.apply(this, arguments);
|
155
|
-
}
|
156
|
-
};
|
157
|
-
log.verbose("Using MongoDB 1.4.x continuation-local-storage workaround");
|
158
|
-
} catch (e) {
|
159
|
-
log.error("Not using MongoDB continuation-local-storage workaround: " + e);
|
160
|
-
}
|
161
|
-
}
|
162
|
-
|
163
|
-
// Mongoskin utils creates skin (wrapper) classes and in the process introduce an emitter for supporting
|
164
|
-
// delayed open() (e.g. while the driver is still connecting).
|
165
|
-
// The emitter breaks continuation-local-storage, but since it is for top-level classes (Db, Collection, etc.)
|
166
|
-
// we can't bind it per request, so we need to bind the individual callbacks that get pushed onto it.
|
167
|
-
function wrapRepairCLSMongoskinUtils(appRoot) {
|
168
|
-
var mongoskinUtils;
|
169
|
-
try {
|
170
|
-
mongoskinUtils = require(appRoot + "/node_modules/mongoskin/lib/utils");
|
171
|
-
} catch (e) {
|
172
|
-
log.verbose("Not using mongoskin continuation-local-storage workaround (either not used, old version, or new unsupported version): " + e);
|
173
|
-
return;
|
174
|
-
}
|
175
|
-
|
176
|
-
try {
|
177
|
-
// makeSkinClass is a factory, so need a double wrap: one to get the run-time factory output (skinClass),
|
178
|
-
// and then one that hooks the actual method in that output.
|
179
|
-
mongoskinUtils._passenger_wrapped_makeSkinClass = mongoskinUtils.makeSkinClass;
|
180
|
-
mongoskinUtils.makeSkinClass = function(NativeClass, useNativeConstructor) {
|
181
|
-
var skinClass = mongoskinUtils._passenger_wrapped_makeSkinClass(NativeClass, useNativeConstructor);
|
182
|
-
|
183
|
-
skinClass.prototype._passenger_wrapped_open = skinClass.prototype.open;
|
184
|
-
skinClass.prototype.open = function(callback) {
|
185
|
-
// Finally we can bind the callback so that when the emitter calls it, the cls is mapped correctly.
|
186
|
-
return skinClass.prototype._passenger_wrapped_open.call(this, ustReporter.getCLSWrappedCallback(callback));
|
187
|
-
};
|
188
|
-
|
189
|
-
return skinClass;
|
190
|
-
};
|
191
|
-
log.verbose("Using mongoskin continuation-local-storage workaround");
|
192
|
-
} catch (e) {
|
193
|
-
log.error("Not using mongoskin continuation-local-storage workaround (probably an unsupported version): " + e);
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
exports.initPostLoad = function() {
|
198
|
-
//if (!mongodb) {
|
199
|
-
// return;
|
200
|
-
//}
|
201
|
-
};
|
202
|
-
|
@@ -1,227 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-2017 Phusion
|
4
|
-
*
|
5
|
-
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
-
*
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
12
|
-
* furnished to do so, subject to the following conditions:
|
13
|
-
*
|
14
|
-
* The above copyright notice and this permission notice shall be included in
|
15
|
-
* all copies or substantial portions of the Software.
|
16
|
-
*
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
-
* THE SOFTWARE.
|
24
|
-
*/
|
25
|
-
|
26
|
-
var codify = require('vendor-copy/codify');
|
27
|
-
|
28
|
-
var reqNamespace = require('vendor-copy/continuation-local-storage').getNamespace('passenger-request-ctx');
|
29
|
-
|
30
|
-
// Assigned by init()
|
31
|
-
var ustLog;
|
32
|
-
var log;
|
33
|
-
var appRoot;
|
34
|
-
|
35
|
-
/**
|
36
|
-
* @return logger set to Passenger's loglevel. For example, log.error("") maps to Passenger loglevel 1. All mappings:
|
37
|
-
* 1: error
|
38
|
-
* 2: warn
|
39
|
-
* 3: notice
|
40
|
-
* 4: info
|
41
|
-
* 5: verbose
|
42
|
-
* 6: debug
|
43
|
-
* 7: silly
|
44
|
-
* (other levels are mapped to critical)
|
45
|
-
*/
|
46
|
-
exports.getPassengerLogger = function() {
|
47
|
-
return log;
|
48
|
-
};
|
49
|
-
|
50
|
-
/**
|
51
|
-
* @return the application root path, needed for instrumenting an application's node modules.
|
52
|
-
*/
|
53
|
-
exports.getApplicationRoot = function() {
|
54
|
-
return appRoot;
|
55
|
-
};
|
56
|
-
|
57
|
-
/**
|
58
|
-
* @return timestamp in microseconds to be used as the start or end timestamp for timed logging (monotonic clock, not wall clock).
|
59
|
-
*/
|
60
|
-
exports.nowTimestamp = function() {
|
61
|
-
var secAndUsec = process.hrtime();
|
62
|
-
return Math.round((secAndUsec[0] * 1e6) + (secAndUsec[1] / 1e3));
|
63
|
-
};
|
64
|
-
|
65
|
-
/**
|
66
|
-
* All Activity logs will be dropped unless they are done after this method, from within an execution chain starting with the callback. So it is
|
67
|
-
* essential to call this function whenever you intercept a request, before code that might want to log can be reached. The function adds context
|
68
|
-
* to the execution chain such that future logs can be correctly appended to the currently open request log, also for modules that don't
|
69
|
-
* have access to the request object (such as database drivers).
|
70
|
-
*
|
71
|
-
* @param callback
|
72
|
-
* The "next" handler in line for processing the request. Logging will only work from this handler or within the same execution chain!
|
73
|
-
*/
|
74
|
-
exports.attachToRequest = function(request, response, callback) {
|
75
|
-
try {
|
76
|
-
log.debug("ustReporter: attachToRequest(" + request.method + " " + request.url + ")");
|
77
|
-
var attachToTxnId = request.headers['!~passenger-txn-id'];
|
78
|
-
if (!attachToTxnId) {
|
79
|
-
log.warn("Dropping Union Station request log due to lack of txnId from Passenger Core (probably a temporary UstRouter failure)");
|
80
|
-
return callback();
|
81
|
-
}
|
82
|
-
|
83
|
-
reqNamespace.bindEmitter(request);
|
84
|
-
reqNamespace.bindEmitter(response);
|
85
|
-
|
86
|
-
// The Passenger core has an open transaction associated with the request, to which we can attach info from node instrumentation.
|
87
|
-
// However, logToUstTransaction() communicates async with the ustrouter, and is not guaranteed to deliver before the application response arrives
|
88
|
-
// back to the core (at which point the core will close the transaction and later additions will not be taken into account).
|
89
|
-
// That's why we intercept response.end() (from the doc: the method, response.end(), MUST be called on each response), so we can defer it
|
90
|
-
// until we are sure the ustrouter is aware of any attachments generated during the request handling.
|
91
|
-
response._passenger_wrapped_end = response.end;
|
92
|
-
response.end = function() {
|
93
|
-
return ustLog.deferIfPendingTxns(attachToTxnId, this, response._passenger_wrapped_end, arguments);
|
94
|
-
};
|
95
|
-
|
96
|
-
// Make request transaction ID available for other instrumentation modules, e.g. mongo doesn't know about requests (which is how the core passes
|
97
|
-
// txn ID).
|
98
|
-
reqNamespace.run(function() {
|
99
|
-
reqNamespace.set("attachToTxnId", attachToTxnId);
|
100
|
-
callback();
|
101
|
-
});
|
102
|
-
} catch (e) {
|
103
|
-
log.error("Dropping Union Station request log due to error:\n" + e.stack);
|
104
|
-
}
|
105
|
-
};
|
106
|
-
|
107
|
-
/**
|
108
|
-
* Log a timed block, described by activityName, with an optional message to display (e.g. in a mouseover).
|
109
|
-
*/
|
110
|
-
exports.logTimedActivityGeneric = function(activityName, tBegin, tEnd, message) {
|
111
|
-
logTimedActivity(activityName, tBegin, tEnd, "generic", message ? { "message": message } : undefined);
|
112
|
-
};
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Log a timed mongo database interaction block, described by activityName, with an optional query to display (e.g. in a mouseover).
|
116
|
-
*/
|
117
|
-
exports.logTimedActivityMongo = function(activityName, tBegin, tEnd, query) {
|
118
|
-
logTimedActivity(activityName, tBegin, tEnd, "mongo", query ? { "query": query } : undefined);
|
119
|
-
};
|
120
|
-
|
121
|
-
/**
|
122
|
-
* Log a timed SQL database interaction block, described by activityName, with an optional query to display (e.g. in a mouseover).
|
123
|
-
*/
|
124
|
-
exports.logTimedActivitySQL = function(activityName, tBegin, tEnd, query) {
|
125
|
-
logTimedActivity(activityName, tBegin, tEnd, "sql", query ? { "query": query } : undefined);
|
126
|
-
};
|
127
|
-
|
128
|
-
/**
|
129
|
-
* Internal, base for the public logTimedActivity...()
|
130
|
-
* @param activityName
|
131
|
-
* the name to display for this activity
|
132
|
-
* @param tBegin
|
133
|
-
* activity start timestamp, acquired using .nowTimestamp()
|
134
|
-
* @param tEnd
|
135
|
-
* activity end timestamp, acquired using .nowTimestamp()
|
136
|
-
* @param dataType
|
137
|
-
* the type of this activity, and the data in the dataObj; assumed to be one of "generic", "sql", "mongo", "view"
|
138
|
-
* @param dataObj
|
139
|
-
* optional; usually content for a mouseover
|
140
|
-
*/
|
141
|
-
function logTimedActivity(activityName, tBegin, tEnd, dataType, dataObj) {
|
142
|
-
try {
|
143
|
-
log.debug("ustReporter: logTimedActivity(activityName: " + activityName + ")");
|
144
|
-
if (!activityName || !tBegin || !tEnd) {
|
145
|
-
log.error("ustReporter: logTimedActivity is missing name or begin/end timestamp, dropping.");
|
146
|
-
return;
|
147
|
-
}
|
148
|
-
|
149
|
-
var attachToTxnId = getCurrentTxnId();
|
150
|
-
if (!attachToTxnId) {
|
151
|
-
log.warn("Dropping Union Station timed action log due to lack of txnId to attach to " +
|
152
|
-
"(either request was not intercepted, cls context lost, or temporary UstRouter failure).\nCall stack: " + (new Error().stack));
|
153
|
-
return;
|
154
|
-
}
|
155
|
-
|
156
|
-
var uniqueTag = codify.toCode(tBegin);
|
157
|
-
var extraInfo;
|
158
|
-
if (!dataType) {
|
159
|
-
extraInfo = JSON.stringify({ "name": activityName });
|
160
|
-
} else {
|
161
|
-
extraInfo = JSON.stringify({ "name": activityName, "data_type": dataType, "data": dataObj });
|
162
|
-
}
|
163
|
-
var logBuf = [];
|
164
|
-
logBuf.push("BEGIN: " + uniqueTag + " (" + codify.toCode(tBegin) + ") " + new Buffer(extraInfo).toString('base64'));
|
165
|
-
logBuf.push("END: " + uniqueTag + " (" + codify.toCode(tEnd) + ")");
|
166
|
-
ustLog.logToUstTransaction("requests", logBuf, attachToTxnId);
|
167
|
-
} catch (e) {
|
168
|
-
log.error("Dropping Union Station timed action log due to error:\n" + e.stack);
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
/**
|
173
|
-
* For logging intercepted exceptions. If the exception occurred in relation to a request (i.e. within an execution chain from the attachToRequest
|
174
|
-
* callback), the exception will be associated with that request, otherwise it's sent as a standalone.
|
175
|
-
*
|
176
|
-
* @param name
|
177
|
-
* E.g. "NameError"
|
178
|
-
* @param message
|
179
|
-
* E.g. "undefined local variable or method for .."
|
180
|
-
* @param trace
|
181
|
-
* Backtrace
|
182
|
-
*/
|
183
|
-
exports.logException = function(name, message, trace) {
|
184
|
-
try {
|
185
|
-
log.debug("ustReporter: logException(name: " + name + ", message: " + message + ")");
|
186
|
-
var logBuf = [];
|
187
|
-
|
188
|
-
var requestTxnId = getCurrentTxnId();
|
189
|
-
if (requestTxnId) {
|
190
|
-
logBuf.push("Request transaction ID: " + requestTxnId);
|
191
|
-
}
|
192
|
-
|
193
|
-
logBuf.push("Message: " + new Buffer(message).toString('base64'));
|
194
|
-
logBuf.push("Class: " + name);
|
195
|
-
logBuf.push("Backtrace: " + new Buffer(trace).toString('base64'));
|
196
|
-
|
197
|
-
ustLog.logToUstTransaction("exceptions", logBuf);
|
198
|
-
} catch (e) {
|
199
|
-
log.error("Dropping Union Station exception log due to error:\n" + e.stack);
|
200
|
-
}
|
201
|
-
};
|
202
|
-
|
203
|
-
/**
|
204
|
-
* Get the current request transaction id necessary to append logs to it. This is normally done automatically, but some modules break automatic attachment
|
205
|
-
* in the execution chain (implemented by continuation-local-storage). This method can be used to trace until at what point the transaction id gets
|
206
|
-
* lost, and patch that place with .getCLSWrappedCallback().
|
207
|
-
*/
|
208
|
-
function getCurrentTxnId() {
|
209
|
-
return reqNamespace.get("attachToTxnId");
|
210
|
-
}
|
211
|
-
exports.getCurrentTxnId = getCurrentTxnId;
|
212
|
-
|
213
|
-
/**
|
214
|
-
* For patching callback systems that are incompatible with continuation-local-storage.
|
215
|
-
*/
|
216
|
-
exports.getCLSWrappedCallback = function(origCallback) {
|
217
|
-
return reqNamespace.bind(origCallback);
|
218
|
-
};
|
219
|
-
|
220
|
-
/**
|
221
|
-
* For internal use. Called by Passenger loader, no need to call from anywhere else.
|
222
|
-
*/
|
223
|
-
exports.init = function(logger, applicationRoot, ustLogger) {
|
224
|
-
log = logger;
|
225
|
-
appRoot = applicationRoot;
|
226
|
-
ustLog = ustLogger;
|
227
|
-
};
|