mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
fix: extend feature_toggle_update counter with details about action (#8202)
Ideally `feature_lifecycle_stage_entered{stage="archived"}` would allow me to see how many flags are archived per week. It seems like the numbers for this is a bit off, and wanted to extend our current `feature_toggle_update` counter with action details.
This commit is contained in:
parent
6f7170dc40
commit
01afe87302
@ -141,7 +141,7 @@ test('should collect metrics for updated toggles', async () => {
|
|||||||
|
|
||||||
const metrics = await prometheusRegister.metrics();
|
const metrics = await prometheusRegister.metrics();
|
||||||
expect(metrics).toMatch(
|
expect(metrics).toMatch(
|
||||||
/feature_toggle_update_total\{toggle="TestToggle",project="default",environment="default",environmentType="production"\} 1/,
|
/feature_toggle_update_total\{toggle="TestToggle",project="default",environment="default",environmentType="production",action="updated"\} 1/,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ test('should set environmentType when toggle is flipped', async () => {
|
|||||||
const metrics = await prometheusRegister.metrics();
|
const metrics = await prometheusRegister.metrics();
|
||||||
|
|
||||||
expect(metrics).toMatch(
|
expect(metrics).toMatch(
|
||||||
/feature_toggle_update_total\{toggle="TestToggle",project="default",environment="testEnvironment",environmentType="testType"\} 1/,
|
/feature_toggle_update_total\{toggle="TestToggle",project="default",environment="testEnvironment",environmentType="testType",action="updated"\} 1/,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -102,7 +102,13 @@ export default class MetricsMonitor {
|
|||||||
const featureFlagUpdateTotal = createCounter({
|
const featureFlagUpdateTotal = createCounter({
|
||||||
name: 'feature_toggle_update_total',
|
name: 'feature_toggle_update_total',
|
||||||
help: 'Number of times a toggle has been updated. Environment label would be "n/a" when it is not available, e.g. when a feature flag is created.',
|
help: 'Number of times a toggle has been updated. Environment label would be "n/a" when it is not available, e.g. when a feature flag is created.',
|
||||||
labelNames: ['toggle', 'project', 'environment', 'environmentType'],
|
labelNames: [
|
||||||
|
'toggle',
|
||||||
|
'project',
|
||||||
|
'environment',
|
||||||
|
'environmentType',
|
||||||
|
'action',
|
||||||
|
],
|
||||||
});
|
});
|
||||||
const featureFlagUsageTotal = createCounter({
|
const featureFlagUsageTotal = createCounter({
|
||||||
name: 'feature_toggle_usage_total',
|
name: 'feature_toggle_usage_total',
|
||||||
@ -782,6 +788,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment: 'n/a',
|
environment: 'n/a',
|
||||||
environmentType: 'n/a',
|
environmentType: 'n/a',
|
||||||
|
action: 'created',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
eventStore.on(FEATURE_VARIANTS_UPDATED, ({ featureName, project }) => {
|
eventStore.on(FEATURE_VARIANTS_UPDATED, ({ featureName, project }) => {
|
||||||
@ -790,6 +797,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment: 'n/a',
|
environment: 'n/a',
|
||||||
environmentType: 'n/a',
|
environmentType: 'n/a',
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
eventStore.on(FEATURE_METADATA_UPDATED, ({ featureName, project }) => {
|
eventStore.on(FEATURE_METADATA_UPDATED, ({ featureName, project }) => {
|
||||||
@ -798,6 +806,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment: 'n/a',
|
environment: 'n/a',
|
||||||
environmentType: 'n/a',
|
environmentType: 'n/a',
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
eventStore.on(FEATURE_UPDATED, ({ featureName, project }) => {
|
eventStore.on(FEATURE_UPDATED, ({ featureName, project }) => {
|
||||||
@ -806,6 +815,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment: 'default',
|
environment: 'default',
|
||||||
environmentType: 'production',
|
environmentType: 'production',
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
eventStore.on(
|
eventStore.on(
|
||||||
@ -820,6 +830,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment,
|
environment,
|
||||||
environmentType,
|
environmentType,
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -835,6 +846,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment,
|
environment,
|
||||||
environmentType,
|
environmentType,
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -850,6 +862,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment,
|
environment,
|
||||||
environmentType,
|
environmentType,
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -865,6 +878,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment,
|
environment,
|
||||||
environmentType,
|
environmentType,
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -880,6 +894,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment,
|
environment,
|
||||||
environmentType,
|
environmentType,
|
||||||
|
action: 'updated',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -889,6 +904,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment: 'n/a',
|
environment: 'n/a',
|
||||||
environmentType: 'n/a',
|
environmentType: 'n/a',
|
||||||
|
action: 'archived',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
eventStore.on(FEATURE_REVIVED, ({ featureName, project }) => {
|
eventStore.on(FEATURE_REVIVED, ({ featureName, project }) => {
|
||||||
@ -897,6 +913,7 @@ export default class MetricsMonitor {
|
|||||||
project,
|
project,
|
||||||
environment: 'n/a',
|
environment: 'n/a',
|
||||||
environmentType: 'n/a',
|
environmentType: 'n/a',
|
||||||
|
action: 'revived',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
eventStore.on(PROJECT_CREATED, () => {
|
eventStore.on(PROJECT_CREATED, () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user