mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-09-11 12:55:37 +03:00
Added Sentry Profiling to Ghost server (#19319)
refs ARCH-29 - Added Sentry Profiling to collect more detailed performance data on the backend. - This feature is opt-in behind a config. To enable profiling, first enable tracing with `sentry.tracing.enabled: true`, then set `sentry.profiling.enabled: true` and `sentry.profiling.sampleRate` to a decimal number between 0 and 1.
This commit is contained in:
parent
bd6bfe13c0
commit
0feebfcf63
@ -1,8 +1,18 @@
|
||||
const config = require('./config');
|
||||
const logging = require('@tryghost/logging');
|
||||
const SentryKnexTracingIntegration = require('./SentryKnexTracingIntegration');
|
||||
const sentryConfig = config.get('sentry');
|
||||
const errors = require('@tryghost/errors');
|
||||
|
||||
// Import Sentry's profiling integration if available
|
||||
let ProfilingIntegration;
|
||||
try {
|
||||
({ProfilingIntegration} = require('@sentry/profiling-node'));
|
||||
} catch (err) {
|
||||
logging.warn('Sentry Profiling Integration not available');
|
||||
ProfilingIntegration = null;
|
||||
}
|
||||
|
||||
const beforeSend = function (event, hint) {
|
||||
try {
|
||||
const exception = hint.originalException;
|
||||
@ -74,6 +84,11 @@ if (sentryConfig && !sentryConfig.disabled) {
|
||||
sentryInitConfig.integrations.push(new Sentry.Integrations.Http({tracing: true}));
|
||||
sentryInitConfig.integrations.push(new Sentry.Integrations.Express());
|
||||
sentryInitConfig.tracesSampleRate = parseFloat(sentryConfig.tracing.sampleRate) || 0.0;
|
||||
// Enable profiling, if configured, only if tracing is also configured
|
||||
if (ProfilingIntegration && sentryConfig.profiling?.enabled === true) {
|
||||
sentryInitConfig.integrations.push(new ProfilingIntegration());
|
||||
sentryInitConfig.profilesSampleRate = parseFloat(sentryConfig.profiling.sampleRate) || 0.0;
|
||||
}
|
||||
}
|
||||
Sentry.init(sentryInitConfig);
|
||||
|
||||
|
@ -225,6 +225,7 @@
|
||||
"yjs": "13.6.10"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@sentry/profiling-node": "1.3.2",
|
||||
"@tryghost/html-to-mobiledoc": "2.0.42",
|
||||
"sqlite3": "5.1.6"
|
||||
},
|
||||
|
15
yarn.lock
15
yarn.lock
@ -4920,6 +4920,14 @@
|
||||
"@sentry/utils" "7.84.0"
|
||||
https-proxy-agent "^5.0.0"
|
||||
|
||||
"@sentry/profiling-node@1.3.2":
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/profiling-node/-/profiling-node-1.3.2.tgz#68b802b6f4d6730c653d0120ebb688a99cfc3493"
|
||||
integrity sha512-Dm2FmR0+BYrTm3YSmbCxjeklAsXZecOwWarZQdrCQniPYlxS9GPgWv1P+J78+CrHZ4IpoIvnlRppGPMrJwPXkw==
|
||||
dependencies:
|
||||
detect-libc "^2.0.2"
|
||||
node-abi "^3.52.0"
|
||||
|
||||
"@sentry/react@7.84.0":
|
||||
version "7.84.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.84.0.tgz#2cb3192f7fb67b7696e8ece08d67229b193ddaa4"
|
||||
@ -23871,6 +23879,13 @@ node-abi@^3.3.0:
|
||||
dependencies:
|
||||
semver "^7.3.5"
|
||||
|
||||
node-abi@^3.52.0:
|
||||
version "3.52.0"
|
||||
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.52.0.tgz#ffba0a85f54e552547e5849015f40f9514d5ba7c"
|
||||
integrity sha512-JJ98b02z16ILv7859irtXn4oUaFWADtvkzy2c0IAatNVX2Mc9Yoh8z6hZInn3QwvMEYhHuQloYi+TTQy67SIdQ==
|
||||
dependencies:
|
||||
semver "^7.3.5"
|
||||
|
||||
node-addon-api@^3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
|
||||
|
Loading…
Reference in New Issue
Block a user