Skip to content

Conversation

@1599-web
Copy link
Contributor

@1599-web 1599-web commented Aug 10, 2025

JFR 文件分析功能:前后端实现

本次 PR 实现了对 .jfr 文件的分析能力,包括前后端服务的完整集成。

模块说明

  • 后端模块arthas-jfr-backend

    • 使用 Spring Boot 实现 REST 服务
    • 支持 .jfr 文件上传、解析、火焰图等数据接口
    • 使用 JMC(Java Mission Control)依赖进行 JFR 分析
    • 本模块要求使用 JDK 17 编译
  • 前端模块arthas-jfr-frontend

    • 实现用户界面,用于上传 .jfr 文件并展示火焰图
    • 技术栈:React

参考项目

该Pr参考了以下优秀的开源项目:

相关 Issue

Closes #3014

@hengyunabc hengyunabc requested a review from Copilot August 29, 2025 16:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a complete JFR (Java Flight Recorder) file analysis feature with both frontend and backend components. The implementation provides JFR file upload, parsing, and flame graph visualization capabilities using Spring Boot backend and React frontend.

Key changes include:

  • Complete backend JFR analysis service with Spring Boot
  • React-based frontend with flame graph visualization
  • File upload/management system with comprehensive UI
  • Integration between frontend and backend modules

Reviewed Changes

Copilot reviewed 154 out of 158 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
pom.xml Adds new frontend and backend modules to main build
labs/arthas-jfr-frontend/ Complete React frontend application with TypeScript, flame graph components, and file management
labs/arthas-jfr-backend/ Spring Boot backend service for JFR file analysis and REST APIs
Frontend components Flame graph visualization, file upload/table, analysis views, and utility functions
Backend services JFR analysis service, file management, and REST controllers
Files not reviewed (1)
  • labs/arthas-jfr-frontend/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -0,0 +1,28 @@
{
"name": "arthas-fronted",
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package name contains a typo. 'fronted' should be 'frontend' to match the directory name and project purpose.

Suggested change
"name": "arthas-fronted",
"name": "arthas-frontend",
Copilot uses AI. Check for mistakes.
Comment on lines 1 to 7
// @ts-nocheck
// eslint-disable-next-line
/**
* 将JFR后端返回的line格式火焰图数据转换为树结构
* @param {Array} data - 形如[[0,1,2], 100]的数组,表示栈帧路径和权重
* @param {Object} symbolTable - {0: 'main', 1: 'foo', ...}
* @returns {Object} 递归树结构 { name, value, children }
*/
export function formatFlamegraph(data, symbolTable) {
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @ts-nocheck and eslint-disable-next-line at the top of files indicates unresolved type issues or code quality problems. These should be addressed rather than suppressed globally.

Suggested change
// @ts-nocheck
// eslint-disable-next-line
/**
* 将JFR后端返回的line格式火焰图数据转换为树结构
* @param {Array} data - 形如[[0,1,2], 100]的数组,表示栈帧路径和权重
* @param {Object} symbolTable - {0: 'main', 1: 'foo', ...}
* @returns {Object} 递归树结构 { name, value, children }
*/
export function formatFlamegraph(data, symbolTable) {
/**
* 将JFR后端返回的line格式火焰图数据转换为树结构
* @param {Array} data - 形如[[0,1,2], 100]的数组,表示栈帧路径和权重
* @param {Object} symbolTable - {0: 'main', 1: 'foo', ...}
* @returns {Object} 递归树结构 { name, value, children }
*/
// Type definitions
export interface FlamegraphNode {
name: string;
value: number;
children: FlamegraphNode[];
}
export type StackFrame = number[];
export type StackData = [StackFrame, number][];
export type SymbolTable = { [key: number]: string };
export function formatFlamegraph(
data: StackData,
symbolTable: SymbolTable
): FlamegraphNode {
Copilot uses AI. Check for mistakes.
const tb = value;
if (tb > 0) result = tb + 'TB ' + result;
if (result.length === 0) {
if (bytes == 0) return '0B';
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strict equality (===) instead of loose equality (==) for consistency and to avoid potential type coercion issues.

Suggested change
if (bytes == 0) return '0B';
if (bytes === 0) return '0B';
Copilot uses AI. Check for mistakes.
opacity: 0.7;
}

.dark-mode .flame-empty {
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are extra spaces in the selector '.dark-mode .flame-empty'. This should be '.dark-mode .flame-empty' for consistency with other selectors.

Suggested change
.dark-mode .flame-empty {
.dark-mode .flame-empty {
Copilot uses AI. Check for mistakes.
Comment on lines 1 to 2
// @ts-nocheck
// eslint-disable-next-line
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a critical component with @ts-nocheck disabled. Type safety should be properly implemented for flame graph rendering logic rather than bypassed.

Suggested change
// @ts-nocheck
// eslint-disable-next-line
Copilot uses AI. Check for mistakes.
};


export default Home; No newline at end of file
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file imports 'Home' from './Home' but exports it as default, while also defining a 'HomeComponent'. This creates confusion - the export should match the actual component being used.

Suggested change
export default Home;
export default HomeComponent;
Copilot uses AI. Check for mistakes.
Comment on lines +4 to +5
const api = axios.create({
baseURL: 'http://localhost:8200',
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The baseURL is hardcoded to localhost. This should be configurable through environment variables for different deployment environments.

Suggested change
const api = axios.create({
baseURL: 'http://localhost:8200',
// Use VITE_API_BASE_URL from environment variables, fallback to localhost for development
const api = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:8200',
Copilot uses AI. Check for mistakes.
Comment on lines 1 to 2
// @ts-nocheck
// eslint-disable-next-line
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File upload functionality should have proper TypeScript types enabled for better error catching and code reliability.

Copilot uses AI. Check for mistakes.
Comment on lines 1 to 2
// @ts-nocheck
// eslint-disable-next-line
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file table component handles important data operations and should have TypeScript checking enabled for type safety.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,27 @@
// @ts-nocheck
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main App component should have TypeScript checking enabled as it's the root component that defines the application structure.

Suggested change
// @ts-nocheck
Copilot uses AI. Check for mistakes.
@hengyunabc hengyunabc requested a review from Copilot September 8, 2025 14:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@RaymondLam1
Copy link
Collaborator

commit message 要保持统一,一般是 feat/test/fix + 说明

image
@RaymondLam1
Copy link
Collaborator

要写个 README,同时写上参考的其他项目地址

@RaymondLam1
Copy link
Collaborator

现在的标题“Feat/jfr analyzer”不规范,改成:"feat: jfr analyzer"

@1599-web 1599-web changed the title Feat/jfr analyzer feat: jfr analyzer Sep 22, 2025
@RaymondLam1
Copy link
Collaborator

@hengyunabc 我觉得基本可以合并进入 labs

@CLAassistant
Copy link

CLAassistant commented Oct 10, 2025

CLA assistant check
All committers have signed the CLA.

@hengyunabc hengyunabc merged commit 0d203b4 into alibaba:master Oct 10, 2025
13 of 14 checks passed
@hengyunabc hengyunabc added this to the 4.0.6 milestone Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants