Skip to content

fix: remove trace polling #1915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@ export function QueryResultViewer({
<CancelQueryButton queryId={queryId} tenantName={tenantName} />
</React.Fragment>
) : null}
{data?.traceId && isExecute ? (
<TraceButton traceId={data.traceId} isTraceReady={result.isTraceReady} />
) : null}
{data?.traceId && isExecute ? <TraceButton traceId={data.traceId} /> : null}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,25 @@
import React from 'react';

import {ArrowUpRightFromSquare} from '@gravity-ui/icons';
import {Button} from '@gravity-ui/uikit';

import {useClusterBaseInfo} from '../../../../../../store/reducers/cluster/cluster';
import {traceApi} from '../../../../../../store/reducers/trace';
import {replaceParams} from '../../../utils/replaceParams';
import i18n from '../../i18n';

interface TraceUrlButtonProps {
traceId: string;
isTraceReady?: true;
}

export function TraceButton({traceId, isTraceReady}: TraceUrlButtonProps) {
const {traceCheck, traceView} = useClusterBaseInfo();
export function TraceButton({traceId}: TraceUrlButtonProps) {
const {traceView} = useClusterBaseInfo();

const checkTraceUrl = traceCheck?.url ? replaceParams(traceCheck.url, {traceId}) : '';
const traceUrl = traceView?.url ? replaceParams(traceView.url, {traceId}) : '';

const [checkTrace, {isLoading, isUninitialized}] = traceApi.useLazyCheckTraceQuery();

React.useEffect(() => {
let checkTraceMutation: {abort: () => void} | null;
if (checkTraceUrl && !isTraceReady) {
checkTraceMutation = checkTrace({url: checkTraceUrl});
}

return () => checkTraceMutation?.abort();
}, [checkTrace, checkTraceUrl, isTraceReady]);

if (!traceUrl || (isUninitialized && !isTraceReady)) {
if (!traceUrl) {
return null;
}

return (
<Button
view={isLoading ? 'flat-secondary' : 'flat-info'}
loading={isLoading}
href={traceUrl}
target="_blank"
>
<Button view={'flat-info'} href={traceUrl} target="_blank">
{i18n('trace')}
<Button.Icon>
<ArrowUpRightFromSquare />
Expand Down
3 changes: 0 additions & 3 deletions src/services/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {PDiskAPI} from './pdisk';
import {SchemeAPI} from './scheme';
import {StorageAPI} from './storage';
import {TabletsAPI} from './tablets';
import {TraceAPI} from './trace';
import {VDiskAPI} from './vdisk';
import {ViewerAPI} from './viewer';

Expand All @@ -18,7 +17,6 @@ export class YdbEmbeddedAPI {
scheme: SchemeAPI;
storage: StorageAPI;
tablets: TabletsAPI;
trace: TraceAPI;
vdisk: VDiskAPI;
viewer: ViewerAPI;
meta?: MetaAPI;
Expand All @@ -33,7 +31,6 @@ export class YdbEmbeddedAPI {
this.scheme = new SchemeAPI({config});
this.storage = new StorageAPI({config});
this.tablets = new TabletsAPI({config});
this.trace = new TraceAPI({config});
this.vdisk = new VDiskAPI({config});
this.viewer = new ViewerAPI({config});
}
Expand Down
42 changes: 0 additions & 42 deletions src/services/api/trace.ts

This file was deleted.

11 changes: 2 additions & 9 deletions src/services/parsers/parseMetaCluster.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import {traceCheckSchema, traceViewSchema} from '../../types/api/trace';
import {traceViewSchema} from '../../types/api/trace';

export function parseTraceFields({
traceCheck,
traceView,
}: {
traceCheck?: string;
traceView?: string;
}) {
export function parseTraceFields({traceView}: {traceView?: string}) {
try {
return {
traceCheck: traceCheck ? traceCheckSchema.parse(JSON.parse(traceCheck)) : undefined,
traceView: traceView ? traceViewSchema.parse(JSON.parse(traceView)) : undefined,
};
} catch (e) {
Expand Down
10 changes: 2 additions & 8 deletions src/store/reducers/cluster/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,11 @@ export function useClusterBaseInfo() {

const {currentData} = clusterApi.useGetClusterBaseInfoQuery(clusterName ?? skipToken);

const {
solomon: monitoring,
name,
trace_check: traceCheck,
trace_view: traceView,
...data
} = currentData || {};
const {solomon: monitoring, name, trace_view: traceView, ...data} = currentData || {};

return {
...data,
...parseTraceFields({traceCheck, traceView}),
...parseTraceFields({traceView}),
name: name ?? clusterName ?? undefined,
monitoring,
};
Expand Down
6 changes: 0 additions & 6 deletions src/store/reducers/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ const slice = createSlice({
changeUserInput: (state, action: PayloadAction<{input: string}>) => {
state.input = action.payload.input;
},
setQueryTraceReady: (state) => {
if (state.result) {
state.result.isTraceReady = true;
}
},
setQueryResult: (state, action: PayloadAction<QueryResult | undefined>) => {
state.result = action.payload;
},
Expand Down Expand Up @@ -143,7 +138,6 @@ const slice = createSlice({
export default slice.reducer;
export const {
changeUserInput,
setQueryTraceReady,
setQueryResult,
saveQueryToHistory,
updateQueryInHistory,
Expand Down
3 changes: 1 addition & 2 deletions src/store/reducers/query/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ export interface QueryResult {
type: QueryAction;
data?: PreparedQueryData;
error?: unknown;
isTraceReady?: true;
queryId: string;
isLoading: boolean;
}

export interface QueryState {
input: string;
result?: QueryResult & {isTraceReady?: boolean};
result?: QueryResult;
history: {
queries: QueryInHistory[];
currentIndex: number;
Expand Down
24 changes: 0 additions & 24 deletions src/store/reducers/trace.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/types/api/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export interface MetaBaseClusterInfo {
balancer?: string;
service?: string;
trace_view?: string;
trace_check?: string;
use_embedded_ui?: boolean;
}

Expand Down
6 changes: 0 additions & 6 deletions src/types/api/trace.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {z} from 'zod';

export const traceCheckSchema = z.object({
url: z.string().url(),
});

export type TTraceCheck = z.infer<typeof traceCheckSchema>;

export const traceViewSchema = z.object({
url: z.string().url(),
});
Expand Down
Loading