Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Jan 8, 2025
1 parent 6b63020 commit 6fae9e4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
9 changes: 8 additions & 1 deletion packages/@n8n/task-runner/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ void (async function start() {
if (dsn) {
const { ErrorReporter } = await import('n8n-core');
errorReporter = Container.get(ErrorReporter);
await errorReporter.init({ serverType: 'task_runner', ...config.sentryConfig });
const { deploymentName, environment, n8nVersion } = config.sentryConfig;
await errorReporter.init({
serverType: 'task_runner',
dsn,
serverName: deploymentName,
environment,
release: n8nVersion,
});
}

runner = new JsTaskRunner(config);
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export abstract class BaseCommand extends Command {
await this.errorReporter.init({
serverType: this.instanceSettings.instanceType,
dsn: this.globalConfig.sentry.backendDsn,
environment: process.env.ENVIRONMENT ?? '',
release: process.env.N8N_VERSION ?? '',
serverName: process.env.DEPLOYMENT_NAME ?? '',
});
initExpressionEvaluator();

Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/error-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { Logger } from './logging/logger';
type ErrorReporterInitOptions = {
serverType: InstanceType | 'task_runner';
dsn: string;
release?: string;
environment?: string;
serverName?: string;
release: string;
environment: string;
serverName: string;
};

@Service()
Expand Down Expand Up @@ -52,12 +52,12 @@ export class ErrorReporter {
await close(timeoutInMs);
}

async init(opts: ErrorReporterInitOptions) {
async init({ dsn, serverType, release, environment, serverName }: ErrorReporterInitOptions) {
process.on('uncaughtException', (error) => {
this.error(error);
});

if (!opts.dsn) return;
if (!dsn) return;

// Collect longer stacktraces
Error.stackTraceLimit = 50;
Expand All @@ -74,11 +74,11 @@ export class ErrorReporter {
];

init({
dsn: opts.dsn,
release: opts.release ?? process.env.N8N_VERSION,
environment: opts.environment ?? process.env.ENVIRONMENT,
dsn,
release,
environment,
enableTracing: false,
serverName: opts.serverName ?? process.env.DEPLOYMENT_NAME,
serverName,
beforeBreadcrumb: () => null,
beforeSend: this.beforeSend.bind(this) as NodeOptions['beforeSend'],
integrations: (integrations) => [
Expand All @@ -97,7 +97,7 @@ export class ErrorReporter {
],
});

setTag('server_type', opts.serverType);
setTag('server_type', serverType);

this.report = (error, options) => captureException(error, options);
}
Expand Down

0 comments on commit 6fae9e4

Please sign in to comment.