Skip to content

Commit

Permalink
feat: pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw committed Dec 2, 2024
1 parent 8fd8f7d commit 3d7fbfb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/definitions/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const integrationDefs = {
category: ["healthMonitoring"],
supportsSearch: false,
},
getDashDot: {
dashDot: {
name: "Dash.",
secretKinds: [[]],
category: ["healthMonitoring"],
Expand Down
8 changes: 0 additions & 8 deletions packages/integrations/src/base/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 5 additions & 7 deletions packages/integrations/src/dashdot/dashdot-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { HealthMonitoring } from "../types";

export class DashDotIntegration extends Integration {
public async testConnectionAsync(): Promise<void> {
const response = await fetch(this.appendPathToUrlWithEndingSlash(this.integration.url, "info"));
const response = await fetch(this.url("/info"));
await response.json();
}

Expand All @@ -25,8 +25,6 @@ export class DashDotIntegration extends Integration {
const channel = createChannelEventHistory<CpuLoadApi[]>(`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),
Expand Down Expand Up @@ -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,
Expand All @@ -76,7 +74,7 @@ export class DashDotIntegration extends Integration {

private async getCurrentCpuLoadAsync() {
const channel = createChannelEventHistory<CpuLoadApi[]>(`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 {
Expand All @@ -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,
Expand Down
1 change: 0 additions & 1 deletion packages/redis/src/lib/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export const createChannelEventHistory = <TData>(channelName: string, maxElement
if (length <= maxElements) {
return;
}
logger.warn(`Trimming from ${length - maxElements} to ${length}`);
await getSetClient.ltrim(channelName, length - maxElements, length);
};

Expand Down

0 comments on commit 3d7fbfb

Please sign in to comment.