diff --git a/frontend/src/component/admin/menu/AdminMenu.tsx b/frontend/src/component/admin/menu/AdminMenu.tsx index 84fcfb1523..35026a0bf8 100644 --- a/frontend/src/component/admin/menu/AdminMenu.tsx +++ b/frontend/src/component/admin/menu/AdminMenu.tsx @@ -15,7 +15,7 @@ function AdminMenu() { const { uiConfig, isEnterprise } = useUiConfig(); const { pathname } = useLocation(); const { isBilling } = useInstanceStatus(); - const { flags } = uiConfig; + const { flags, networkViewEnabled } = uiConfig; const activeTab = pathname.split('/')[2]; @@ -99,7 +99,7 @@ function AdminMenu() { } /> - {flags.networkView && ( + {networkViewEnabled && ( , - { - getLogger, - prometheusApi, - server, - }: Pick, + { getLogger }: Pick, bulkInterval = secondsToMilliseconds(5), announcementInterval = minutesToMilliseconds(5), ) { @@ -81,8 +72,6 @@ export default class ClientInstanceService { this.clientApplicationsStore = clientApplicationsStore; this.clientInstanceStore = clientInstanceStore; this.eventStore = eventStore; - this.prometheusApi = prometheusApi; - this.serverOption = server; this.logger = getLogger( '/services/client-metrics/client-instance-service.ts', ); @@ -220,39 +209,6 @@ export default class ClientInstanceService { await this.clientApplicationsStore.upsert(applicationData); } - private toEpoch(d: Date) { - return (d.getTime() - d.getMilliseconds()) / 1000; - } - - async getRPS(hoursToQuery: number, limit = 10): Promise { - if (!this.prometheusApi) { - this.logger.warn('Prometheus not configured'); - return; - } - const timeoutSeconds = 5; - const basePath = this.serverOption.baseUriPath.replace(/\/$/, ''); - const pathQuery = `${basePath}/api/.*`; - const step = '5m'; - const rpsQuery = `topk(${limit}, irate (http_request_duration_milliseconds_count{path=~"${pathQuery}"} [${step}]))`; - const query = `sum by(appName, endpoint) (label_replace(${rpsQuery}, "endpoint", "$1", "path", "${basePath}(/api/(?:client/)?[^/\*]*).*"))`; - const end = new Date(); - const start = new Date(); - start.setHours(end.getHours() - hoursToQuery); - - const params = `timeout=${timeoutSeconds}s&start=${this.toEpoch( - start, - )}&end=${this.toEpoch(end)}&step=${step}&query=${encodeURI(query)}`; - const url = `${this.prometheusApi}/api/v1/query_range?${params}`; - let metrics; - const response = await fetch(url); - if (response.ok) { - metrics = await response.json(); - } else { - throw new Error(response.statusText); - } - return metrics; - } - async removeInstancesOlderThanTwoDays(): Promise { return this.clientInstanceStore.removeInstancesOlderThanTwoDays(); } diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 4a45579f03..fa596480ff 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -30,10 +30,6 @@ const flags = { process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES, false, ), - networkView: parseEnvVarBoolean( - process.env.UNLEASH_EXPERIMENTAL_NETWORK_VIEW, - false, - ), maintenance: parseEnvVarBoolean( process.env.UNLEASH_EXPERIMENTAL_MAINTENANCE, false, diff --git a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap index 64a8fdbdf5..4bb2ce059b 100644 --- a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap +++ b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap @@ -3705,6 +3705,9 @@ Stats are divided into current and previous **windows**. "name": { "type": "string", }, + "networkViewEnabled": { + "type": "boolean", + }, "segmentValuesLimit": { "type": "number", },