From e5127395713c5cde6f2dc8d9ee16f6d5dd356198 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Wed, 2 Oct 2024 15:49:15 +0300 Subject: [PATCH] feat: add logging for lifecycle prom metrics (#8341) --- .../feature-lifecycle/feature-lifecycle-service.ts | 9 +++++++++ src/lib/metrics.ts | 3 +++ src/lib/types/experimental.ts | 7 ++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib/features/feature-lifecycle/feature-lifecycle-service.ts b/src/lib/features/feature-lifecycle/feature-lifecycle-service.ts index dd0f8d8865..2d05c58089 100644 --- a/src/lib/features/feature-lifecycle/feature-lifecycle-service.ts +++ b/src/lib/features/feature-lifecycle/feature-lifecycle-service.ts @@ -132,8 +132,17 @@ export class FeatureLifecycleService { } private recordStagesEntered(newlyEnteredStages: NewStage[]) { + if (this.flagResolver.isEnabled('trackLifecycleMetrics')) { + this.logger.info( + 'recordStagesEntered parameter', + newlyEnteredStages, + ); + } newlyEnteredStages.forEach(({ stage, feature }) => { this.eventBus.emit(STAGE_ENTERED, { stage, feature }); + if (this.flagResolver.isEnabled('trackLifecycleMetrics')) { + this.logger.info('STAGE_ENTERED emitted', { stage, feature }); + } }); } diff --git a/src/lib/metrics.ts b/src/lib/metrics.ts index d724fb44ab..25c1ab8557 100644 --- a/src/lib/metrics.ts +++ b/src/lib/metrics.ts @@ -453,6 +453,9 @@ export default class MetricsMonitor { eventBus.on( events.STAGE_ENTERED, (entered: { stage: string; feature: string }) => { + if (flagResolver.isEnabled('trackLifecycleMetrics')) { + logger.info('STAGE_ENTERED listened', entered); + } featureLifecycleStageEnteredCounter.increment({ stage: entered.stage, }); diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 9df11056bc..ad6994d28a 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -60,7 +60,8 @@ export type IFlagKey = | 'onboardingUI' | 'projectRoleAssignment' | 'eventTimeline' - | 'personalDashboardUI'; + | 'personalDashboardUI' + | 'trackLifecycleMetrics'; export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>; @@ -297,6 +298,10 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_PERSONAL_DASHBOARD_UI, false, ), + trackLifecycleMetrics: parseEnvVarBoolean( + process.env.UNLEASH_EXPERIMENTAL_TRACK_LIFECYCLE_METRICS, + false, + ), }; export const defaultExperimentalOptions: IExperimentalOptions = {