[TOC]
# koTime介紹
項目性能分析工具,追蹤方法調用鏈路快速定位性能瓶頸,我們采用koTime。
koTime開源地址:[https://gitee.com/huoyo/ko-time](https://gitee.com/huoyo/ko-time)
# koTime特點
* 實時監聽方法,
* 統計運行時長web展示方法調用鏈路,瓶頸可視化追蹤
# springboot-pom整合
## 引入依賴pom
```
<dependency>
<groupId>cn.langpy</groupId>
<artifactId>ko-time</artifactId>
<version>2.0.9</version>
</dependency>
```
## 配置application
```
ko-time:
pointcut: execution(public * com.qingfeng..*.*(..))
```
其他配置參數
```
ko-time.enable=true # 是否開啟koTime,默認開啟,當為false時,關閉koTime
ko-time.log-enable=false # 是否開啟控制輸出,默認false
ko-time.log-language=chinese # 控制臺輸出語言(english/chinese)默認chinese
ko-time.threshold=800.0 # 時間閾值,用于前端展示,大于閾值顯示紅色,小于閾值顯示綠色,默認800
ko-time.context-path=http://localhost:80 # 前端頁面調用接口的上下文環境,無法自動獲取時可手動配置,一般情況切記不要配置 v2.0.1開始支持
ko-time.exception-enable=true # 是否開啟異常檢測,默認為false,開啟后會對方法內部拋出的異常進行統計 v2.0.0開始支持
ko-time.auth-enable=true # 是否開啟認證,默認為false,開啟后需要登錄才能訪問調用鏈路 v2.0.2開始支持
ko-time.user-name=xxxx # 登錄用戶 v2.0.2開始支持
ko-time.password=xxxx # 登錄密碼 v2.0.2開始支持
ko-time.param-analyse=true #是否開啟入參組合分析 默認開啟 v2.0.8開始支持 雙擊方法節點即可看到效果
```
## 使用說明介紹
注意:
1.引入了上面的依賴和配置以后,確認項目中是否有aop相關的包,koTime使用了@Aspect注解,未引入的自行引入,如aspectj或者spring-boot-starter-aop
2.做完前面的步驟,koTime的集成已經完畢,無需進行其他配置
3.如果后臺有權限認證,需要放開/koTime和/koTime/\*\*
* 啟動項目訪問 /koTime 路徑即可
* 如果僅僅只是想統計某個方法,在方法上加上@ComputeTime即可,控制臺會輸出耗時
如果項目自定義的contextpath,訪問如http://localhost:8080/xxx服務/koTime
如:application.properties中定義了server.servlet.context-path=/myservice,那么訪問路徑為http://localhost:8080/myservice/koTime如果頁面能正常顯示,但是無法獲取方法鏈路,可配置ko-time.context-path=http://localhost:8080/myservice
## 運行訪問
### 1.接口調用統計
根據顏色判斷需要優化的接口數,紅色為待優化,綠色為正常

### 2.接口列表總覽
在列表中會顯示該接口的運行耗時,如果為綠色則無需優化,如果為紅色,需要詳細查看問題所在

### 3.調用詳情
點開接口時,會顯示該接口的調用鏈路以及運行時長,紅色節點即為需要優化的節點

# springboot-源碼整合
## 多模塊拆分
項目模塊化,將原來的項目拆成多模塊,效果如下:

### 創建根模塊-qingfeng
pom主要配置如下:
```
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/>
</parent>
<groupId>com.qingfeng</groupId>
<artifactId>qingfeng</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>qingfeng-admin</module>
<module>qingfeng-common</module>
<module>qingfeng-kotime</module>
</modules>
```
### 創建主模塊-qingfeng-admin
```
<parent>
<groupId>com.qingfeng</groupId>
<artifactId>qingfeng</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>qingfeng-admin</artifactId>
<name>qingfeng-admin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.qingfeng</groupId>
<artifactId>qingfeng-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.qingfeng</groupId>
<artifactId>qingfeng-kotime</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
```

### 創建公共模塊-qingfeng-common
```
<parent>
<groupId>com.qingfeng</groupId>
<artifactId>qingfeng</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>qingfeng-common</artifactId>
<name>qingfeng-common</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
</dependencies>
```

### 創建鏈路模塊-qingfeng-kotime
pom不導入任何模塊。
```
<groupId>com.qingfeng</groupId>
<artifactId>qingfeng-kotime</artifactId>
<version>1.0-SNAPSHOT</version>
<name>qingfeng-kotime</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
```

## kotime源碼整合
### 源碼下載
源碼下載:[https://gitee.com/huoyo/ko-time](https://gitee.com/huoyo/ko-time)

### 源碼拷貝
將下面src/main下面的java和resources文件拷貝到-qingfeng-kotime模塊下的src/main下面。如下圖:


### 拷貝pom依賴
將源碼中的pom文件的依賴,拷貝到qingfeng-kotime下的pom文件。


### 項目運行
整合完成,啟動下面后,訪問:[http://127.0.0.1:8090/koTime](http://127.0.0.1:8090/koTime)

至此,項目整合完畢。
- 青鋒項目介紹
- 系統框架介紹
- 搭建開發環境
- 涵蓋技術
- 構建后臺框架
- springboot項目構建
- mvnw介紹
- 整合mybatis-plus
- mybatisplus知識點
- SQL日志打印工具p6spy
- mybatis-plus分頁
- mybatis-plus多數據源使用
- mybatis-plus樂觀鎖
- springboot全局異常
- 整合攔截器/過濾器
- 實現業務功能模塊
- 數據結構設計
- 框架完善-工具類-注釋、驗證
- 業務模塊實現介紹
- 整合springsecurity權限控制
- Spring-Security-OAuth2簡介
- springboot整合springsecurity
- springsecurity實現訪問權限控制
- 整合登錄圖形驗證碼
- springboot整合Sentinel-實現驗證碼限流
- 架構權限功能說明
- 菜單、功能權限的講解
- 數據權限的講解
- Quartz動態定時器整合
- 整合quartz動態定時器
- quartz動態定時案例介紹
- 代碼生成器
- freemarker模板引擎常用語法
- 代碼生成器功能設計
- 代碼生成器實現方式
- Vue前端教程
- 快速開始
- 項目組成介紹
- layouts布局組件介紹
- 動態鎖屏介紹
- IndexedDB 瀏覽器數據庫-參考
- Axios基礎知識
- Axios請求的封裝
- 靜態路由和菜單
- 動態路由和權限控制
- 功能權限與指令
- 系統登錄和token刷新
- Vuex狀態管理使用說明
- Vue3之setup講解及使用
- 架構功能拓展
- 整合swagger接口文檔
- 接口授權簽名認證
- 集成prometheus+Grafana監控
- 請求調用鏈路追蹤