mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
git status
This commit is contained in:
parent
eca36eeb5c
commit
c09afa3e99
@ -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, {});
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user