1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-18 00:19:49 +01:00

git status

This commit is contained in:
sjaanus 2025-03-12 11:03:54 +02:00
parent eca36eeb5c
commit c09afa3e99
No known key found for this signature in database
GPG Key ID: 20E007C0248BA7FF
2 changed files with 25 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import EventEmitter from 'events';
import type { IEventStore } from './types/stores/event-store';
import { createTestConfig } from '../test/config/test-config';
import {
CLIENT_REGISTERED,
DB_TIME,
EXCEEDS_LIMIT,
FUNCTION_TIME,
@ -287,6 +288,21 @@ test('Should collect metrics for client sdk versions', async () => {
);
});
test('Should register intervals when client registered', async () => {
eventBus.emit(CLIENT_REGISTERED, {
appName: 'unleash-client-node',
environment: 'development',
interval: '15',
});
const metrics = await prometheusRegister.getSingleMetricAsString(
'client_registration_total',
);
expect(metrics).toMatch(
/client_registration_total{appName=\"unleash-client-node\",environment=\"development\",interval=\"15\"} 1/,
);
});
test('Should not collect client sdk version if sdkVersion is of wrong format or non-existent', async () => {
eventStore.emit(CLIENT_REGISTER, { sdkVersion: 'unleash-client-rust' });
eventStore.emit(CLIENT_REGISTER, {});

View File

@ -172,7 +172,7 @@ export function registerPrometheusMetrics(
const clientRegistrationTotal = createCounter({
name: 'client_registration_total',
help: 'Number of times a an application have registered',
labelNames: ['appName', 'environment'],
labelNames: ['appName', 'environment', 'interval'],
});
dbMetrics.registerGaugeDbMetric({
@ -812,9 +812,14 @@ export function registerPrometheusMetrics(
clientDeltaMemory.reset();
clientDeltaMemory.set(event.memory);
});
eventBus.on(events.CLIENT_REGISTERED, ({ appName, environment }) => {
clientRegistrationTotal.labels({ appName, environment }).inc();
});
eventBus.on(
events.CLIENT_REGISTERED,
({ appName, environment, interval }) => {
clientRegistrationTotal
.labels({ appName, environment, interval })
.inc();
},
);
events.onMetricEvent(
eventBus,