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

feat: expose impact metrics (#10151)

This commit is contained in:
Mateusz Kwasniewski 2025-06-17 14:17:46 +02:00 committed by GitHub
parent c619cb9ec5
commit 02876a1c08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import { Registry } from 'prom-client';
// Deliberately keep it separate from the global instance metrics register
// It is a singleton that everyone participating in the impact metrics can import
export const impactRegister = new Registry();

View File

@ -2,6 +2,7 @@ import { writeHeapSnapshot } from 'v8';
import { tmpdir } from 'os';
import { join } from 'path';
import { register as prometheusRegister } from 'prom-client';
import { impactRegister } from '../features/metrics/impact/impact-register.js';
import Controller from './controller.js';
import type { IUnleashConfig } from '../types/option.js';
import type { IFlagResolver } from '../types/index.js';
@ -41,6 +42,16 @@ class BackstageController extends Controller {
res.end(metricsOutput);
});
if (this.flagResolver.isEnabled('impactMetrics')) {
this.get('/impact/metrics', async (req, res) => {
res.set('Content-Type', impactRegister.contentType);
const metricsOutput = await impactRegister.metrics();
res.end(metricsOutput);
});
}
}
if (config.server.enableHeapSnapshotEnpoint) {

View File

@ -60,6 +60,7 @@ export type IFlagKey =
| 'lastSeenBulkQuery'
| 'lifecycleMetrics'
| 'customMetrics'
| 'impactMetrics'
| 'createFlagDialogCache'
| 'improvedJsonDiff'
| 'changeRequestApproverEmails';