1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

fix: version should be part of ui-config (#616)

This commit is contained in:
Ivar Conradi Østhus 2020-08-03 13:34:10 +02:00 committed by GitHub
parent e42337e523
commit 1bb0d03855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 29 deletions

View File

@ -8,21 +8,16 @@ const {
FEATURE_ARCHIVED,
FEATURE_REVIVED,
} = require('./event-type');
const { version } = require('./routes/api-def');
const THREE_HOURS = 3 * 60 * 60 * 1000;
exports.startMonitoring = (
enable,
eventBus,
eventStore,
clientMetricsStore,
featureToggleStore,
) => {
if (!enable) {
exports.startMonitoring = ({ serverMetrics, eventBus, stores, version }) => {
if (!serverMetrics) {
return;
}
const { eventStore, clientMetricsStore, featureToggleStore } = stores;
client.collectDefaultMetrics();
const requestDuration = new client.Summary({

View File

@ -15,13 +15,17 @@ test.before(() => {
const featureToggleStore = {
count: () => 123,
};
startMonitoring(
true,
const config = {
serverMetrics: true,
eventBus,
eventStore,
clientMetricsStore,
featureToggleStore,
);
stores: {
eventStore,
clientMetricsStore,
featureToggleStore,
},
version: '3.4.1',
};
startMonitoring(config);
});
test('should collect metrics for requests', t => {

View File

@ -5,6 +5,7 @@ const parseDbUrl = require('parse-database-url');
const merge = require('deepmerge');
const { publicFolder } = require('unleash-frontend');
const { defaultLogProvider, validateLogProvider } = require('./logger');
const version = require('./util/version');
const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
@ -54,6 +55,7 @@ function defaultOptions() {
start: true,
keepAliveTimeout: 60 * 1000,
headersTimeout: 61 * 1000,
version,
};
}

View File

@ -1,5 +1,5 @@
{
"version": 2,
"version": 3,
"links": {
"feature-toggles": {
"uri": "/api/admin/features"

View File

@ -5,7 +5,7 @@ const Controller = require('../controller');
class ConfigController extends Controller {
constructor(config) {
super(config);
this.uiConfig = config.ui;
this.uiConfig = { ...config.ui, version: config.version };
this.get('/', this.getUIConfig);
}

View File

@ -1,11 +1,8 @@
'use strict';
// export module version
require('pkginfo')(module, 'version');
const { version } = module.exports;
const clientApiDef = require('./client-api/api-def.json');
const adminApiDef = require('./admin-api/api-def.json');
const version = require('../util/version');
const apiDef = {
name: 'unleash-server',

View File

@ -1,5 +1,5 @@
{
"version": 2,
"version": 3,
"links": {
"feature-toggles": {
"uri": "/api/client/features"

View File

@ -31,13 +31,7 @@ async function createApp(options) {
};
const app = getApp(config);
startMonitoring(
options.serverMetrics,
eventBus,
stores.eventStore,
stores.clientMetricsStore,
stores.featureToggleStore,
);
startMonitoring(config);
if (typeof config.eventHook === 'function') {
addEventHook(config.eventHook, stores.eventStore);

7
lib/util/version.js Normal file
View File

@ -0,0 +1,7 @@
'use strict';
// export module version
require('pkginfo')(module, 'version');
const { version } = module.exports;
module.exports = version;