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:
parent
c619cb9ec5
commit
02876a1c08
5
src/lib/features/metrics/impact/impact-register.ts
Normal file
5
src/lib/features/metrics/impact/impact-register.ts
Normal 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();
|
@ -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) {
|
||||
|
@ -60,6 +60,7 @@ export type IFlagKey =
|
||||
| 'lastSeenBulkQuery'
|
||||
| 'lifecycleMetrics'
|
||||
| 'customMetrics'
|
||||
| 'impactMetrics'
|
||||
| 'createFlagDialogCache'
|
||||
| 'improvedJsonDiff'
|
||||
| 'changeRequestApproverEmails';
|
||||
|
Loading…
Reference in New Issue
Block a user