From b14177d29998a9606c5a059e7952494b84236c34 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 15 Sep 2023 14:47:37 +0200 Subject: [PATCH 1/5] ref(telemetry): Add progress tag --- src/telemetry.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/telemetry.ts b/src/telemetry.ts index c63bf7db..44d1c19e 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -6,6 +6,7 @@ import { makeNodeTransport, NodeClient, runWithAsyncContext, + setTag, startSpan, } from '@sentry/node'; import packageJson from '../package.json'; @@ -27,6 +28,8 @@ export async function withTelemetry( const sentrySession = sentryHub.startSession(); sentryHub.captureSession(); + updateProgress('start'); + try { return await startSpan( { @@ -34,7 +37,11 @@ export async function withTelemetry( status: 'ok', op: 'wizard.flow', }, - async () => runWithAsyncContext(callback), + async () => { + const res = await runWithAsyncContext(callback); + updateProgress('done'); + return res; + }, ); } catch (e) { sentryHub.captureException('Error during wizard execution.'); @@ -91,5 +98,10 @@ function createSentryInstance(enabled: boolean, integration: string) { } export function traceStep(step: string, callback: () => T): T { + updateProgress(step); return startSpan({ name: step, op: 'wizard.step' }, () => callback()); } + +export function updateProgress(step: string) { + setTag('progress', step); +} From 816d3f08d133180ebf65520287b5d09f44e999aa Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 15 Sep 2023 14:51:29 +0200 Subject: [PATCH 2/5] cleanup --- src/telemetry.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/telemetry.ts b/src/telemetry.ts index 44d1c19e..68e26709 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -28,8 +28,6 @@ export async function withTelemetry( const sentrySession = sentryHub.startSession(); sentryHub.captureSession(); - updateProgress('start'); - try { return await startSpan( { @@ -38,8 +36,10 @@ export async function withTelemetry( op: 'wizard.flow', }, async () => { + updateProgress('start'); const res = await runWithAsyncContext(callback); updateProgress('done'); + return res; }, ); From 958a5a13ddc344d24f97d14b7e9136ca6191df53 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 15 Sep 2023 15:00:05 +0200 Subject: [PATCH 3/5] counter --- src/telemetry.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/telemetry.ts b/src/telemetry.ts index 68e26709..3bded239 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -1,5 +1,6 @@ import { defaultStackParser, + getCurrentHub, Hub, Integrations, makeMain, @@ -38,7 +39,7 @@ export async function withTelemetry( async () => { updateProgress('start'); const res = await runWithAsyncContext(callback); - updateProgress('done'); + updateProgress('finished'); return res; }, @@ -102,6 +103,7 @@ export function traceStep(step: string, callback: () => T): T { return startSpan({ name: step, op: 'wizard.step' }, () => callback()); } +let stepCounter = -1; export function updateProgress(step: string) { - setTag('progress', step); + setTag('progress', `${++stepCounter}-${step}`); } From 8eac149f971a1c965c22f4c019fd71e7c338d5ac Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 15 Sep 2023 15:40:33 +0200 Subject: [PATCH 4/5] lint --- src/telemetry.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/telemetry.ts b/src/telemetry.ts index 3bded239..c44e27e2 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -1,6 +1,5 @@ import { defaultStackParser, - getCurrentHub, Hub, Integrations, makeMain, From 1ca01e5121ce063fba64650198b54a7444f5ee6c Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 18 Sep 2023 14:49:57 +0200 Subject: [PATCH 5/5] remove counter --- src/telemetry.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/telemetry.ts b/src/telemetry.ts index c44e27e2..c1895008 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -102,7 +102,6 @@ export function traceStep(step: string, callback: () => T): T { return startSpan({ name: step, op: 'wizard.step' }, () => callback()); } -let stepCounter = -1; export function updateProgress(step: string) { - setTag('progress', `${++stepCounter}-${step}`); + setTag('progress', step); }