Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(telemetry): Only flush after the root span finished #460

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,23 @@ export async function withTelemetry<F>(
const sentrySession = sentryHub.startSession();
sentryHub.captureSession();

return startSpan(
{
name: 'sentry-wizard-execution',
status: 'ok',
op: 'wizard.flow',
},
async (span) => {
if (!span) {
return runWithAsyncContext(() => callback());
}
try {
return await runWithAsyncContext(() => callback());
} catch (e) {
sentryHub.captureException('Error during wizard execution.');
span.setStatus('internal_error');
sentrySession.status = 'crashed';
throw e;
} finally {
sentryHub.endSession();
await sentryClient.flush(3000);
}
},
);
try {
return await startSpan(
{
name: 'sentry-wizard-execution',
status: 'ok',
op: 'wizard.flow',
},
async () => runWithAsyncContext(callback),
);
} catch (e) {
sentryHub.captureException('Error during wizard execution.');
sentrySession.status = 'crashed';
throw e;
} finally {
sentryHub.endSession();
await sentryClient.flush(3000);
}
}

function createSentryInstance(enabled: boolean, integration: string) {
Expand Down
Loading