1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: collect prometheus data about archived features (#6728)

This commit is contained in:
Jaanus Sellin 2024-03-28 13:40:30 +02:00 committed by GitHub
parent 5b325568d1
commit d3847fd8ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 0 deletions

View File

@ -39,6 +39,7 @@ export interface InstanceStats {
serviceAccounts: number;
apiTokens: Map<string, number>;
featureToggles: number;
archivedFeatureToggles: number;
projects: ProjectModeCount[];
contextFields: number;
roles: number;
@ -192,6 +193,12 @@ export class InstanceStatsService {
});
}
getArchivedToggleCount(): Promise<number> {
return this.featureToggleStore.count({
archived: true,
});
}
async hasOIDC(): Promise<boolean> {
const settings = await this.settingStore.get<{ enabled: boolean }>(
'unleash.enterprise.auth.oidc',
@ -215,6 +222,7 @@ export class InstanceStatsService {
const versionInfo = await this.versionService.getVersionInfo();
const [
featureToggles,
archivedFeatureToggles,
users,
serviceAccounts,
apiTokens,
@ -237,6 +245,7 @@ export class InstanceStatsService {
previousDayMetricsBucketsCount,
] = await Promise.all([
this.getToggleCount(),
this.getArchivedToggleCount(),
this.userStore.count(),
this.userStore.countServiceAccounts(),
this.apiTokenStore.countByType(),
@ -269,6 +278,7 @@ export class InstanceStatsService {
apiTokens,
activeUsers,
featureToggles,
archivedFeatureToggles,
projects,
contextFields,
roles,

View File

@ -190,6 +190,11 @@ test('should collect metrics for feature toggle size', async () => {
expect(metrics).toMatch(/feature_toggles_total\{version="(.*)"\} 0/);
});
test('should collect metrics for archived feature toggle size', async () => {
const metrics = await prometheusRegister.metrics();
expect(metrics).toMatch(/feature_toggles_archived_total 0/);
});
test('should collect metrics for total client apps', async () => {
await statsService.refreshAppCountSnapshot();
const metrics = await prometheusRegister.metrics();

View File

@ -108,6 +108,11 @@ export default class MetricsMonitor {
help: 'Number of feature toggles',
labelNames: ['version'],
});
const featureTogglesArchivedTotal = createGauge({
name: 'feature_toggles_archived_total',
help: 'Number of archived feature toggles',
});
const usersTotal = createGauge({
name: 'users_total',
help: 'Number of users',
@ -262,6 +267,9 @@ export default class MetricsMonitor {
.labels({ version })
.set(stats.featureToggles);
featureTogglesArchivedTotal.reset();
featureTogglesArchivedTotal.set(stats.archivedFeatureToggles);
usersTotal.reset();
usersTotal.set(stats.users);

View File

@ -94,6 +94,7 @@ class InstanceAdminController extends Controller {
featureExports: 0,
featureImports: 0,
featureToggles: 29,
archivedFeatureToggles: 10,
groups: 3,
instanceId: 'ed3861ae-78f9-4e8c-8e57-b57efc15f82b',
projects: 4,