Skip to content

Commit

Permalink
DBZ-6757: Fixes to the connector metrics (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
indraraj authored Jan 9, 2024
1 parent a9f7108 commit a058bc7
Show file tree
Hide file tree
Showing 9 changed files with 339 additions and 40 deletions.
36 changes: 24 additions & 12 deletions src/app/apis/connector/connector.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ export class ConnectorService extends BaseService {
);
return this.httpGet<any>(endpoint);
}

public getConnectorMetrics(baseHref: string, connectorType: string, connectorName: string): Promise<any> {
this.logger?.info(
"[ConnectorService] Getting the Connector metrics:" + connectorName ,
);
const endpoint: string = this.endpoint(
"debezium/:connectorType/connectors/:connectorName/metrics",
baseHref,
{ connectorType, connectorName },
);
return this.httpGet<any>(endpoint);
}


/**
Expand Down Expand Up @@ -385,19 +397,19 @@ export class ConnectorService extends BaseService {
/**
* Get the available connector metrics for the supplied clusterId and connector name
*/
public getConnectorMetrics(
clusterId: number,
connectorName: string
): Promise<any[]> {
this.logger?.info("[ConnectorService] Getting the connector metrics.");
// public getConnectorMetrics(
// clusterId: number,
// connectorName: string
// ): Promise<any[]> {
// this.logger?.info("[ConnectorService] Getting the connector metrics.");

const endpoint: string = this.endpoint(
"/connectors/:clusterId/:connectorName/metrics",
"",
{ clusterId, connectorName }
);
return this.httpGet<any[]>(endpoint);
}
// const endpoint: string = this.endpoint(
// "/connectors/:clusterId/:connectorName/metrics",
// "",
// { clusterId, connectorName }
// );
// return this.httpGet<any[]>(endpoint);
// }

/**
* Get the Connector config
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/ConnectorStatusComponent.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.connector-status_task-status-text .pf-v5-c-helper-text__item{
/* text-align: center; */
display: grid !important;
}
29 changes: 27 additions & 2 deletions src/app/components/ConnectorStatusComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,70 @@
import { Label } from "@patternfly/react-core";
import { getTaskStatus } from "@app/utils";
import { HelperText, HelperTextItem, Label } from "@patternfly/react-core";
import {
CheckCircleIcon,
ExclamationCircleIcon,
ExclamationTriangleIcon,
PauseCircleIcon,
} from "@patternfly/react-icons";
import React from "react";
import './ConnectorStatusComponent.css'

interface ConnectorStatusComponentProps {
status: string;
task?: boolean;
}

type variantType =
| "success"
| "warning"
| "error"
| "default"
| "indeterminate"
| undefined;

export const ConnectorStatusComponent: React.FC<
ConnectorStatusComponentProps
> = ({ status }) => {
> = ({ status, task }) => {
let labelColor = undefined;
let variant = undefined as variantType;
let icon: React.ReactNode;

switch (status) {
case "RUNNING":
labelColor = "green";
variant = "success";
icon = <CheckCircleIcon />;
break;
case "STOPPED":
labelColor = "orange";
variant = "warning";
icon = <ExclamationTriangleIcon />;
break;
case "PAUSED":
variant = "warning";
labelColor = "blue";
icon = <PauseCircleIcon />;
break;
case "FAILED":
case "DESTROYED":
labelColor = "red";
variant = "error";
icon = <ExclamationCircleIcon />;
break;
default:
labelColor = "blue";
variant = "success";
break;
}

if (task)
return (
<HelperText className="connector-status_task-status-text">
<HelperTextItem variant={variant} hasIcon>
{status}
</HelperTextItem>
</HelperText>
);
return (
<Label
color={
Expand Down
3 changes: 2 additions & 1 deletion src/app/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './usePostWithReturnApi';
export * from './useFetchApi';
export * from './usePostWithReturnApi';
export * from './usePostWithReturnApi';
export * from './useFetchApiMultiVariableApi';
58 changes: 58 additions & 0 deletions src/app/hooks/useFetchApiMultiVariableApi.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useEffect, useState } from "react";
import { FetchApiResult } from "./useFetchApi";

function useFetchApiMultiVariableApi<T>(
url: string | null,
api: any,
serviceRef: any,
multiVariable: any,
pollingInterval?: number
): FetchApiResult<T> {
const [data, setData] = useState<T | null>(null);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [error, setError] = useState<Error | null>(null);

useEffect(() => {
let ignore = false;

const fetchData = async () => {
try {
const apiCall = api.bind(serviceRef);
const response = await apiCall(url, ...multiVariable);
setData(response);
setIsLoading(false);
} catch (error) {
setIsLoading(false);
setError(error as Error);

console.error("Error fetching data:", error);
}
};

if (url) {
fetchData();
}

if (pollingInterval) {
const intervalId = setInterval(() => {
if (!ignore) {
fetchData();
}
}, pollingInterval);

return () => {
clearInterval(intervalId);
ignore = true;
};
}

return () => {
ignore = true;
};

}, [api, serviceRef, url, pollingInterval]);

return { data, isLoading, error };
}

export default useFetchApiMultiVariableApi;
4 changes: 0 additions & 4 deletions src/app/pages/connectorDetails/ConnectorDetails.css

This file was deleted.

Loading

0 comments on commit a058bc7

Please sign in to comment.