Skip to content

Commit

Permalink
fix(instrumentation): Call Sentry.init() as early as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Apr 23, 2024
1 parent 095e73e commit 8fc43db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#!/usr/bin/env node

import * as Sentry from '@sentry/node';
import {nodeProfilingIntegration} from '@sentry/profiling-node';

Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [nodeProfilingIntegration()],
profilesSampleRate: 1,
tracesSampleRate: 1,
_experiments: {
metricsAggregator: true,
},
});

import dotenv from 'dotenv';
import yargs from 'yargs';

Expand All @@ -11,7 +23,6 @@ import {renderStream} from './renderStream';
import {PollingConfig} from './types';

dotenv.config();
Sentry.init({dsn: process.env.SENTRY_DSN});

const defaultPollingConfig: PollingConfig = {
/**
Expand Down
11 changes: 0 additions & 11 deletions src/renderServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import {performance} from 'node:perf_hooks';

import * as Sentry from '@sentry/node';
import {nodeProfilingIntegration} from '@sentry/profiling-node';
import express from 'express';

import {ConfigService} from './config';
Expand All @@ -17,16 +16,6 @@ export function renderServer(config: ConfigService) {
const app = express();
const renderRoutes = express.Router();

Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [nodeProfilingIntegration()],
profilesSampleRate: 1,
tracesSampleRate: 1,
_experiments: {
metricsAggregator: true,
},
});

renderRoutes.use(express.json({limit: '20mb'}));
renderRoutes.use((req, resp) => {
if (!config.isLoaded) {
Expand Down

0 comments on commit 8fc43db

Please sign in to comment.