mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(tools): sentry apm and other telemetry (#49230)
This commit is contained in:
committed by
GitHub
parent
2b63eaa8bb
commit
b4fa56be3e
@@ -29,7 +29,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@freecodecamp/loopback-component-passport": "1.2.0",
|
||||
"@sentry/node": "6.19.7",
|
||||
"@sentry/node": "7.37.1",
|
||||
"@sentry/tracing": "7.37.1",
|
||||
"accepts": "1.3.8",
|
||||
"axios": "0.23.0",
|
||||
"bad-words": "3.0.4",
|
||||
|
||||
@@ -2,6 +2,7 @@ const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
|
||||
const Sentry = require('@sentry/node');
|
||||
const Tracing = require('@sentry/tracing');
|
||||
const createDebugger = require('debug');
|
||||
const _ = require('lodash');
|
||||
const loopback = require('loopback');
|
||||
@@ -14,16 +15,32 @@ const { setupPassport } = require('./component-passport');
|
||||
const log = createDebugger('fcc:server');
|
||||
const reqLogFormat = ':date[iso] :status :method :response-time ms - :url';
|
||||
|
||||
const app = loopback();
|
||||
|
||||
if (sentry.dsn === 'dsn_from_sentry_dashboard') {
|
||||
log('Sentry reporting disabled unless DSN is provided.');
|
||||
} else {
|
||||
Sentry.init({
|
||||
dsn: sentry.dsn
|
||||
dsn: sentry.dsn,
|
||||
integrations: [
|
||||
new Sentry.Integrations.Http({ tracing: true }),
|
||||
new Tracing.Integrations.Express({
|
||||
app
|
||||
})
|
||||
],
|
||||
// Capture 20% of transactions to avoid
|
||||
// overwhelming Sentry and remain within
|
||||
// the usage quota
|
||||
tracesSampleRate: 0.2
|
||||
});
|
||||
log('Sentry initialized');
|
||||
}
|
||||
|
||||
const app = loopback();
|
||||
// RequestHandler creates a separate execution context using domains, so that every
|
||||
// transaction/span/breadcrumb is attached to its own Hub instance
|
||||
app.use(Sentry.Handlers.requestHandler());
|
||||
// TracingHandler creates a trace for every incoming request
|
||||
app.use(Sentry.Handlers.tracingHandler());
|
||||
|
||||
app.set('state namespace', '__fcc__');
|
||||
app.set('port', process.env.API_PORT || 3000);
|
||||
|
||||
Reference in New Issue
Block a user