-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67a961b
commit 0468798
Showing
37 changed files
with
1,016 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { withInitialFetch, ThreadDumpPage } from '@pinpoint-fe/ui'; | ||
import { getLayoutWithSideNavigation } from '@/components/Layout/LayoutWithSideNavigation'; | ||
|
||
export default withInitialFetch(() => getLayoutWithSideNavigation(<ThreadDumpPage />)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
web-frontend/src/main/v3/apps/web/src/routes/loader/threadDump.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { APP_PATH } from '@pinpoint-fe/constants'; | ||
import { getApplicationTypeAndName } from '@pinpoint-fe/utils'; | ||
import { LoaderFunctionArgs, redirect } from 'react-router-dom'; | ||
|
||
export const threadDumpRouteLoader = ({ params, request }: LoaderFunctionArgs) => { | ||
const application = getApplicationTypeAndName(params.application!); | ||
|
||
if (application?.applicationName && application.serviceType) { | ||
const redirectPath = `${APP_PATH.SERVER_MAP}/${params.application}`; | ||
const queryParam = Object.fromEntries(new URL(request.url).searchParams); | ||
const agentId = queryParam?.agentId as string; | ||
|
||
if (agentId) { | ||
return application; | ||
} else { | ||
return redirect(redirectPath); | ||
} | ||
} else { | ||
return redirect(APP_PATH.SERVER_MAP); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
web-frontend/src/main/v3/packages/constants/src/types/ActiveThreadDump.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
export namespace ActiveThreadDump { | ||
export interface Parameters { | ||
applicationName: string; | ||
agentId: string; | ||
threadName: string; | ||
localTraceId: number; | ||
} | ||
|
||
export interface Response { | ||
code: number; | ||
message: Message; | ||
} | ||
|
||
export interface Message { | ||
threadDumpData: ThreadDumpData[]; | ||
type: string; | ||
subType: string; | ||
version: string; | ||
} | ||
|
||
export interface ThreadDumpData { | ||
threadId: string; | ||
threadName: string; | ||
threadState: string; | ||
startTime: number; | ||
execTime: number; | ||
localTraceId: number; | ||
sampled: boolean; | ||
transactionId: string; | ||
entryPoint: string; | ||
detailMessage: string; | ||
} | ||
|
||
export interface ErrorResponse { | ||
timestamp: string; | ||
status: number; | ||
error: string; | ||
exception: string; | ||
trace: string; | ||
message: string; | ||
path: string; | ||
data: ErrorData; | ||
} | ||
|
||
export interface ErrorData { | ||
hostName: string; | ||
requestInfo: RequestInfo; | ||
} | ||
|
||
export interface RequestInfo { | ||
method: string; | ||
url: string; | ||
headers: Headers; | ||
parameters: Parameters; | ||
} | ||
|
||
export interface Headers { | ||
'sec-fetch-mode': string[]; | ||
referer: string[]; | ||
'sec-fetch-site': string[]; | ||
'accept-language': string[]; | ||
cookie: string[]; | ||
pragma: string[]; | ||
accept: string[]; | ||
'sec-ch-ua': string[]; | ||
'sec-ch-ua-mobile': string[]; | ||
'sec-ch-ua-platform': string[]; | ||
'cache-control': string[]; | ||
'accept-encoding': string[]; | ||
'user-agent': string[]; | ||
'sec-fetch-dest': string[]; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
web-frontend/src/main/v3/packages/constants/src/types/ActiveThreadLightDump.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
export namespace ActiveThreadLightDump { | ||
export interface Parameters { | ||
applicationName: string; | ||
agentId: string; | ||
} | ||
|
||
export interface Response { | ||
code: number; | ||
message: Message; | ||
} | ||
|
||
export interface Message { | ||
threadDumpData: ThreadDumpData[]; | ||
type: string; | ||
subType: string; | ||
version: string; | ||
} | ||
|
||
export interface ThreadDumpData { | ||
threadId: string; | ||
threadName: string; | ||
threadState: string; | ||
startTime: number; | ||
execTime: number; | ||
localTraceId: number; | ||
sampled: boolean; | ||
transactionId: string; | ||
entryPoint: string; | ||
detailMessage: string; | ||
} | ||
|
||
export interface ErrorResponse { | ||
timestamp: string; | ||
status: number; | ||
error: string; | ||
exception: string; | ||
trace: string; | ||
message: string; | ||
path: string; | ||
data: ErrorData; | ||
} | ||
|
||
export interface ErrorData { | ||
hostName: string; | ||
requestInfo: RequestInfo; | ||
} | ||
|
||
export interface RequestInfo { | ||
method: string; | ||
url: string; | ||
headers: Headers; | ||
parameters: Parameters; | ||
} | ||
|
||
export interface Headers { | ||
'sec-fetch-mode': string[]; | ||
referer: string[]; | ||
'sec-fetch-site': string[]; | ||
'accept-language': string[]; | ||
cookie: string[]; | ||
pragma: string[]; | ||
accept: string[]; | ||
'sec-ch-ua': string[]; | ||
'sec-ch-ua-mobile': string[]; | ||
'sec-ch-ua-platform': string[]; | ||
'cache-control': string[]; | ||
'accept-encoding': string[]; | ||
'user-agent': string[]; | ||
'sec-fetch-dest': string[]; | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
web-frontend/src/main/v3/packages/constants/src/types/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
web-frontend/src/main/v3/packages/hooks/src/api/useGetActiveThreadDump.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import useSWR from 'swr'; | ||
import { END_POINTS, ActiveThreadDump, ActiveThreadLightDump } from '@pinpoint-fe/constants'; | ||
import { swrConfigs } from './swrConfigs'; | ||
import { convertParamsToQueryString } from '@pinpoint-fe/utils'; | ||
import { useSearchParameters } from '../searchParameters'; | ||
|
||
const getQueryString = ( | ||
queryParams: Partial<ActiveThreadDump.Parameters> & Partial<ActiveThreadLightDump.ThreadDumpData>, | ||
) => { | ||
if ( | ||
queryParams?.agentId && | ||
queryParams?.applicationName && | ||
queryParams?.threadName && | ||
queryParams?.localTraceId | ||
) { | ||
return '?' + convertParamsToQueryString(queryParams); | ||
} | ||
|
||
return ''; | ||
}; | ||
|
||
export const useGetActiveThreadDump = (thread?: ActiveThreadLightDump.ThreadDumpData) => { | ||
const { searchParameters, application } = useSearchParameters(); | ||
const applicationName = application?.applicationName; | ||
const agentId = searchParameters?.agentId; | ||
|
||
const queryString = getQueryString({ | ||
applicationName, | ||
agentId, | ||
threadName: thread?.threadName, | ||
localTraceId: thread?.localTraceId, | ||
}); | ||
|
||
const { data, isLoading } = useSWR<ActiveThreadDump.Response>( | ||
queryString ? [`${END_POINTS.ACTIVE_THREAD_DUMP}${queryString}`] : null, | ||
swrConfigs, | ||
); | ||
|
||
return { data, isLoading }; | ||
}; |
31 changes: 31 additions & 0 deletions
31
web-frontend/src/main/v3/packages/hooks/src/api/useGetActiveThreadLightDump.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import useSWR from 'swr'; | ||
import { END_POINTS, ActiveThreadLightDump } from '@pinpoint-fe/constants'; | ||
import { swrConfigs } from './swrConfigs'; | ||
import { convertParamsToQueryString } from '@pinpoint-fe/utils'; | ||
import { useSearchParameters } from '../searchParameters'; | ||
|
||
const getQueryString = (queryParams: Partial<ActiveThreadLightDump.Parameters>) => { | ||
if (queryParams.agentId) { | ||
return '?' + convertParamsToQueryString(queryParams); | ||
} | ||
|
||
return ''; | ||
}; | ||
|
||
export const useGetActiveThreadLightDump = () => { | ||
const { searchParameters, application } = useSearchParameters(); | ||
const applicationName = application?.applicationName; | ||
const agentId = searchParameters?.agentId; | ||
|
||
const queryString = getQueryString({ | ||
applicationName, | ||
agentId, | ||
}); | ||
|
||
const { data, isLoading } = useSWR<ActiveThreadLightDump.Response>( | ||
queryString ? [`${END_POINTS.ACTIVE_THREAD_LIGHT_DUMP}${queryString}`] : null, | ||
swrConfigs, | ||
); | ||
|
||
return { data, isLoading }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
web-frontend/src/main/v3/packages/hooks/src/utility/useTabFocus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
|
||
export const useTabFocus = (delay = 3000) => { | ||
const [isTabFocused, setIsTabFocused] = React.useState(true); | ||
|
||
React.useEffect(() => { | ||
let timer: NodeJS.Timeout; | ||
|
||
const handleFocusChange = () => { | ||
if (!document.hidden) { | ||
setIsTabFocused(!document.hidden); | ||
clearTimeout(timer); | ||
} else { | ||
timer = setTimeout(() => setIsTabFocused(!document.hidden), delay); | ||
} | ||
}; | ||
|
||
handleFocusChange(); | ||
|
||
document.addEventListener('visibilitychange', handleFocusChange); | ||
|
||
return () => { | ||
document.removeEventListener('visibilitychange', handleFocusChange); | ||
clearTimeout(timer); | ||
}; | ||
}, [delay]); | ||
return isTabFocused; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.