mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-09-11 12:55:37 +03:00
Lazyloaded @sentry/profiling-node
dependency
- we don't need to load this if we haven't configured Node profiling to occur - this might help fix random segfaults we've been seeing in CI, which only started occurring after this dependency was added
This commit is contained in:
parent
b639993a1b
commit
a667b160c1
@ -4,15 +4,6 @@ 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;
|
||||
@ -89,9 +80,20 @@ if (sentryConfig && !sentryConfig.disabled) {
|
||||
sentryInitConfig.integrations.push(new Sentry.Integrations.Http({tracing: true}));
|
||||
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;
|
||||
if (sentryConfig.profiling?.enabled === true) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (ProfilingIntegration) {
|
||||
sentryInitConfig.integrations.push(new ProfilingIntegration());
|
||||
sentryInitConfig.profilesSampleRate = parseFloat(sentryConfig.profiling.sampleRate) || 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Sentry.init(sentryInitConfig);
|
||||
|
Loading…
Reference in New Issue
Block a user