Spring Project Tree

A framework that shows the chain of method calls

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

cn.yueshutong
ArtifactId

ArtifactId

tree-spring-boot-starter
Last Version

Last Version

1.0.0.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

Spring Project Tree
A framework that shows the chain of method calls
Project URL

Project URL

https://github.com/yueshutong/Spring-Project-Tree
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

https://github.com/yueshutong/Spring-Project-Tree.git

Download tree-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/cn.yueshutong/tree-spring-boot-starter/ -->
<dependency>
    <groupId>cn.yueshutong</groupId>
    <artifactId>tree-spring-boot-starter</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/cn.yueshutong/tree-spring-boot-starter/
implementation 'cn.yueshutong:tree-spring-boot-starter:1.0.0.RELEASE'
// https://jarcasting.com/artifacts/cn.yueshutong/tree-spring-boot-starter/
implementation ("cn.yueshutong:tree-spring-boot-starter:1.0.0.RELEASE")
'cn.yueshutong:tree-spring-boot-starter:jar:1.0.0.RELEASE'
<dependency org="cn.yueshutong" name="tree-spring-boot-starter" rev="1.0.0.RELEASE">
  <artifact name="tree-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.yueshutong', module='tree-spring-boot-starter', version='1.0.0.RELEASE')
)
libraryDependencies += "cn.yueshutong" % "tree-spring-boot-starter" % "1.0.0.RELEASE"
[cn.yueshutong/tree-spring-boot-starter "1.0.0.RELEASE"]

Dependencies

compile (1)

Group / Artifact Type Version
commons-io : commons-io jar 2.5

provided (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar 1.5.10.RELEASE
org.springframework.boot : spring-boot-starter-aop jar 1.5.10.RELEASE

Project Modules

There are no modules declared in this project.

很多新人进入一家新公司后,最头疼的就是如何快速了解公司的业务和项目架构。

因为文档很少,没有文档,或者是文档严重落伍, 根本没法看;如果你碰到一个特别热心的老员工,事无巨细地给你讲,随时在你身边答疑解惑, 那简直是天大的好运气, 现实是大家都很忙,没人给你讲解。

很快就要深入项目做开发了,怎么办呢?

我在加入新公司后,就遇到了悲催的情况。于是,我就做了这款可视化流程分析插件!帮助更多入职新人快速熟悉业务。

Maven依赖

直接在pom.xml引入依赖!

<dependency>
  <groupId>com.github.onblog</groupId>
  <artifactId>project-tree-spring-boot-starter</artifactId>
  <version>2.0.0.RELEASE</version>
</dependency>

但前提是你已经引入如下依赖:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-aop</artifactId>
</dependency>

Spring Boot Starter

如果你的项目是Spring Boot,那么使用会非常简单,只需要一个注解即可。

@EnableProjectTree(value = "")注解参数为pointcut表达式,完整代码如下:

@SpringBootApplication
@EnableProjectTree("execution(* com.example.springboot.demo..*(..))")
public class SpringbootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }

}

Project Tree不仅增加了对分布式接口的监控,还增加了pointcut表示式。

访问ProjectTree

启动你的项目,首先访问你项目的某个接口,使其执行被监控的方法。然后访问localhost:8080/tree/project.html查看网页。

接口说明

接口 说明
/tree/project.html 返回完整调用链视图
/tree/project.html?all=1 返回全部方法视图
/projecttree/all JSON形式的返回结果
/projecttree/{methodId} 对某一方法的JSON结果

注意事项

使用Shiro、Spring Securit等安全框架时,需要注意对此URL的权限控制。

另外,方法调用链分析并不会监控自身对自身的方法调用,因为this.method()并不是调用的代理对象的method()方法。

源码亮点

1.如何降低对主流程的性能消耗?

使用多线程实现异步非阻塞模型。

2.为什么使用单例线程池?

只有一个线程的线程池实际是队列+单线程,一个一个的执行任务,完全符合本框架的使需求,多则出错。

3.为什么数据保存到内存?

基于内存的数据读写,基于方法调用链分析进行选择性保存,占用内存极小。理论上说,从接口开始,有多少流程分支,就有多少条数据记录。

4.如何实现方法调用分析?

基于栈数据结构设计算法。

5.如何解决多线程环境对算法的影响?

通过ThreadId加Stack自定义数据结构“线程栈”实现线程隔离。

About

Email:[email protected]

如果帮助到你了,请不吝赞赏!谢谢!

Versions

Version
1.0.0.RELEASE