Skip to content

Commit

Permalink
feat: add logging for lifecycle prom metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus committed Oct 2, 2024
1 parent b975919 commit 9111369
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
});
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
7 changes: 6 additions & 1 deletion src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export type IFlagKey =
| 'onboardingUI'
| 'projectRoleAssignment'
| 'eventTimeline'
| 'personalDashboardUI';
| 'personalDashboardUI'
| 'trackLifecycleMetrics';

export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;

Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 9111369

Please sign in to comment.