From 3d7fbfb3ceb50b7633f7ddcaa126a8e759536449 Mon Sep 17 00:00:00 2001 From: Manuel <30572287+manuel-rw@users.noreply.github.com> Date: Sun, 1 Dec 2024 13:30:08 +0100 Subject: [PATCH] feat: pr feedback --- packages/definitions/src/integration.ts | 2 +- packages/integrations/src/base/integration.ts | 8 -------- .../integrations/src/dashdot/dashdot-integration.ts | 12 +++++------- packages/redis/src/lib/channel.ts | 1 - 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/packages/definitions/src/integration.ts b/packages/definitions/src/integration.ts index a02c292c59..8c9645be94 100644 --- a/packages/definitions/src/integration.ts +++ b/packages/definitions/src/integration.ts @@ -144,7 +144,7 @@ export const integrationDefs = { category: ["healthMonitoring"], supportsSearch: false, }, - getDashDot: { + dashDot: { name: "Dash.", secretKinds: [[]], category: ["healthMonitoring"], diff --git a/packages/integrations/src/base/integration.ts b/packages/integrations/src/base/integration.ts index c0730197f5..c9c9534437 100644 --- a/packages/integrations/src/base/integration.ts +++ b/packages/integrations/src/base/integration.ts @@ -92,14 +92,6 @@ export abstract class Integration { await handleResponseAsync?.(response); } - - protected appendPathToUrlWithEndingSlash(basename: string, path: string) { - if (basename.endsWith("/")) { - return `${basename}${path}`; - } - - return `${basename}/${path}`; - } } export interface TestConnectionError { diff --git a/packages/integrations/src/dashdot/dashdot-integration.ts b/packages/integrations/src/dashdot/dashdot-integration.ts index abea3b4720..27e605d890 100644 --- a/packages/integrations/src/dashdot/dashdot-integration.ts +++ b/packages/integrations/src/dashdot/dashdot-integration.ts @@ -12,7 +12,7 @@ import type { HealthMonitoring } from "../types"; export class DashDotIntegration extends Integration { public async testConnectionAsync(): Promise { - const response = await fetch(this.appendPathToUrlWithEndingSlash(this.integration.url, "info")); + const response = await fetch(this.url("/info")); await response.json(); } @@ -25,8 +25,6 @@ export class DashDotIntegration extends Integration { const channel = createChannelEventHistory(`integration:${this.integration.id}:history:cpu`, 100); const history = await channel.getSliceUntilTimeAsync(dayjs().subtract(15, "minutes").toDate()); - // logger.info(JSON.stringify(history)); - logger.info( JSON.stringify({ "1min": this.getAverageOfCpu(history[0]).toFixed(2), @@ -62,7 +60,7 @@ export class DashDotIntegration extends Integration { } private async getInfoAsync() { - const infoResponse = await fetch(this.appendPathToUrlWithEndingSlash(this.integration.url, "info")); + const infoResponse = await fetch(this.url("/info")); const serverInfo = (await infoResponse.json()) as InternalServerInfo; return { maxAvailableMemoryBytes: serverInfo.ram.size, @@ -76,7 +74,7 @@ export class DashDotIntegration extends Integration { private async getCurrentCpuLoadAsync() { const channel = createChannelEventHistory(`integration:${this.integration.id}:history:cpu`, 100); - const cpu = await fetch(this.appendPathToUrlWithEndingSlash(this.integration.url, "load/cpu")); + const cpu = await fetch(this.url("/load/cpu")); const data = (await cpu.json()) as CpuLoadApi[]; await channel.pushAsync(data); return { @@ -98,12 +96,12 @@ export class DashDotIntegration extends Integration { } private async getCurrentStorageLoadAsync() { - const storageLoad = await fetch(this.appendPathToUrlWithEndingSlash(this.integration.url, "load/storage")); + const storageLoad = await fetch(this.url("/load/storage")); return (await storageLoad.json()) as number[]; } private async getCurrentMemoryLoadAsync() { - const memoryLoad = await fetch(this.appendPathToUrlWithEndingSlash(this.integration.url, "load/ram")); + const memoryLoad = await fetch(this.url("/load/ram")); const data = (await memoryLoad.json()) as MemoryLoadApi; return { loadInBytes: data.load, diff --git a/packages/redis/src/lib/channel.ts b/packages/redis/src/lib/channel.ts index c15cb4f3cf..68664a2d79 100644 --- a/packages/redis/src/lib/channel.ts +++ b/packages/redis/src/lib/channel.ts @@ -193,7 +193,6 @@ export const createChannelEventHistory = (channelName: string, maxElement if (length <= maxElements) { return; } - logger.warn(`Trimming from ${length - maxElements} to ${length}`); await getSetClient.ltrim(channelName, length - maxElements, length); };