Skip to content

Commit

Permalink
ref(telemetry): Use new startSpan function (#459)
Browse files Browse the repository at this point in the history
- bump the Node SDK to the latest version
- replace manual `startTransaction` call with `startSpan` in `withTelemetry`
- replace `trace` (RIP) with `startSpan` in `traceStep`
  • Loading branch information
Lms24 authored Sep 15, 2023
1 parent ca93673 commit e041bfa
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@clack/core": "0.3.3",
"@clack/prompts": "0.7.0",
"@sentry/cli": "^1.72.0",
"@sentry/node": "^7.57.0",
"@sentry/node": "^7.69.0",
"axios": "1.3.5",
"chalk": "^2.4.1",
"glob": "^7.1.3",
Expand Down
45 changes: 25 additions & 20 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
makeNodeTransport,
NodeClient,
runWithAsyncContext,
trace,
startSpan,
} from '@sentry/node';
import packageJson from '../package.json';

Expand All @@ -24,27 +24,32 @@ export async function withTelemetry<F>(

makeMain(sentryHub);

const transaction = sentryHub.startTransaction({
name: 'sentry-wizard-execution',
status: 'ok',
op: 'wizard.flow',
});
sentryHub.getScope().setSpan(transaction);
const sentrySession = sentryHub.startSession();
sentryHub.captureSession();

try {
return await runWithAsyncContext(() => callback());
} catch (e) {
sentryHub.captureException('Error during wizard execution.');
transaction.setStatus('internal_error');
sentrySession.status = 'crashed';
throw e;
} finally {
transaction.finish();
sentryHub.endSession();
await sentryClient.flush(3000);
}
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);
}
},
);
}

function createSentryInstance(enabled: boolean, integration: string) {
Expand Down Expand Up @@ -92,5 +97,5 @@ function createSentryInstance(enabled: boolean, integration: string) {
}

export function traceStep<T>(step: string, callback: () => T): T {
return trace({ name: step, op: 'wizard.step' }, () => callback());
return startSpan({ name: step, op: 'wizard.step' }, () => callback());
}
62 changes: 31 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,14 @@
dependencies:
requireindex "~1.1.0"

"@sentry-internal/tracing@7.57.0":
version "7.57.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.57.0.tgz#cb761931b635f8f24c84be0eecfacb8516b20551"
integrity sha512-tpViyDd8AhQGYYhI94xi2aaDopXOPfL2Apwrtb3qirWkomIQ2K86W1mPmkce+B0cFOnW2Dxv/ZTFKz6ghjK75A==
dependencies:
"@sentry/core" "7.57.0"
"@sentry/types" "7.57.0"
"@sentry/utils" "7.57.0"
"@sentry-internal/tracing@7.69.0":
version "7.69.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.69.0.tgz#8d8eb740b72967b6ba3fdc0a5173aa55331b7d35"
integrity sha512-4BgeWZUj9MO6IgfO93C9ocP3+AdngqujF/+zB2rFdUe+y9S6koDyUC7jr9Knds/0Ta72N/0D6PwhgSCpHK8s0Q==
dependencies:
"@sentry/core" "7.69.0"
"@sentry/types" "7.69.0"
"@sentry/utils" "7.69.0"
tslib "^2.4.1 || ^1.9.3"

"@sentry-internal/[email protected]":
Expand All @@ -774,40 +774,40 @@
progress "^2.0.3"
proxy-from-env "^1.1.0"

"@sentry/core@7.57.0":
version "7.57.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.57.0.tgz#65093d739c04f320a54395a21be955fcbe326acb"
integrity sha512-l014NudPH0vQlzybtXajPxYFfs9w762NoarjObC3gu76D1jzBBFzhdRelkGpDbSLNTIsKhEDDRpgAjBWJ9icfw==
"@sentry/core@7.69.0":
version "7.69.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.69.0.tgz#ebbe01df573f438f8613107020a4e18eb9adca4d"
integrity sha512-V6jvK2lS8bhqZDMFUtvwe2XvNstFQf5A+2LMKCNBOV/NN6eSAAd6THwEpginabjet9dHsNRmMk7WNKvrUfQhZw==
dependencies:
"@sentry/types" "7.57.0"
"@sentry/utils" "7.57.0"
"@sentry/types" "7.69.0"
"@sentry/utils" "7.69.0"
tslib "^2.4.1 || ^1.9.3"

"@sentry/node@^7.57.0":
version "7.57.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.57.0.tgz#31052f5988ed4496d7f3ff925240cf9b02d09941"
integrity sha512-63mjyUVM6sfJFVQ5TGVRVGUsoEfESl5ABzIW1W0s9gUiQPaG8SOdaQJglb2VNrkMYxnRHgD8Q9LUh/qcmUyPGw==
"@sentry/node@^7.69.0":
version "7.69.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.69.0.tgz#938200095a17f41a2445fec168df293db7c24836"
integrity sha512-T0NgPcmDQvEuz5hy6aEhXghTHHTWsiP3IWoeEAakDBHAXmtpT6lYFQZgb5AiEOt9F5KO/G/1yH3YYdpDAnKhPw==
dependencies:
"@sentry-internal/tracing" "7.57.0"
"@sentry/core" "7.57.0"
"@sentry/types" "7.57.0"
"@sentry/utils" "7.57.0"
"@sentry-internal/tracing" "7.69.0"
"@sentry/core" "7.69.0"
"@sentry/types" "7.69.0"
"@sentry/utils" "7.69.0"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^2.4.1 || ^1.9.3"

"@sentry/types@7.57.0":
version "7.57.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.57.0.tgz#4fdb80cbd49ba034dd8d9be0c0005a016d5db3ce"
integrity sha512-D7ifoUfxuVCUyktIr5Gc+jXUbtcUMmfHdTtTbf1XCZHua5mJceK9wtl3YCg3eq/HK2Ppd52BKnTzEcS5ZKQM+w==
"@sentry/types@7.69.0":
version "7.69.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.69.0.tgz#012b8d90d270a473cc2a5cf58a56870542739292"
integrity sha512-zPyCox0mzitzU6SIa1KIbNoJAInYDdUpdiA+PoUmMn2hFMH1llGU/cS7f4w/mAsssTlbtlBi72RMnWUCy578bw==

"@sentry/utils@7.57.0":
version "7.57.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.57.0.tgz#8253c6fcf35138b4c424234b8da1596e11b98ad8"
integrity sha512-YXrkMCiNklqkXctn4mKYkrzNCf/dfVcRUQrkXjeBC+PHXbcpPyaJgInNvztR7Skl8lE3JPGPN4v5XhLxK1bUUg==
"@sentry/utils@7.69.0":
version "7.69.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.69.0.tgz#b7594e4eb2a88b9b25298770b841dd3f81bd2aa4"
integrity sha512-4eBixe5Y+0EGVU95R4NxH3jkkjtkE4/CmSZD4In8SCkWGSauogePtq6hyiLsZuP1QHdpPb9Kt0+zYiBb2LouBA==
dependencies:
"@sentry/types" "7.57.0"
"@sentry/types" "7.69.0"
tslib "^2.4.1 || ^1.9.3"

"@sinclair/typebox@^0.25.16":
Expand Down

0 comments on commit e041bfa

Please sign in to comment.