Skip to content

Commit 2eafd2c

Browse files
author
yaomingyang
committed
新增埋点扩展点,发布新版本
1 parent c7edac7 commit 2eafd2c

File tree

32 files changed

+257
-285
lines changed

32 files changed

+257
-285
lines changed

README.md

Lines changed: 157 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -58,114 +58,115 @@ git push origin --tags
5858
其它tag操作参考:[tag操作指南](https://blog.csdn.net/Emily/article/details/78839295?ops_request_misc=%7B%22request%5Fid%22%3A%22158685673019724835840750%22%2C%22scm%22%3A%2220140713.130056874..%22%7D&request_id=158685673019724835840750&biz_id=0&utm_source=distribute.pc_search_result.none-task-blog-blog_SOOPENSEARCH-1)
5959

6060
------
61-
### 自研框架-emily(艾米莉)配置
62-
```java
63-
#设置开启用户请求日志拦截器模式,默认:true
64-
spring.emily.api-log.enable=true
65-
#设置开启日志debug模式,默认:false
66-
spring.emily.api-log.debug=false
67-
#是否开启抛出的异常拦截,默认:true
68-
spring.emily.exception.enable=true
69-
#是否开启json转换器配置,默认:true
70-
spring.emily.jackson2.converter.enable=true
71-
72-
#设置开启返回结果包装,默认:true
73-
spring.emily.return-value.enable=true
74-
#设置https配置开关,默认false
75-
spring.emily.https.enable=false
76-
#RedisTemplate组件开关,默认:false
77-
spring.emily.redis.enable=false
78-
#限流组件开关,默认:false
79-
spring.emily.rate-limit.enable=true
80-
#防止重复提交组件开关,默认:false
81-
spring.emily.idempotent.enable=false
82-
83-
#RestTemplate组件
84-
#Http RestTemplate组件开关,默认true
85-
spring.emily.http-client.enable=true
86-
#Http RestTemplate拦截器开关,记录请求响应日志,默认true
87-
spring.emily.http-client.enable-interceptor=true
88-
#http连接读取超时时间,默认5000毫秒
89-
spring.emily.http-client.read-time-out=5000
90-
#http连接连接超时时间,默认10000毫秒
91-
spring.emily.http-client.connect-time-out=10000
61+
#### 数据库多数据源组件
9262

93-
#RestTemplate组件-Spring Cloud客户端负载均衡
94-
#Http RestTemplate组件开关,默认true
95-
spring.emily.cloud.http-client-loadbalancer.enable=true
96-
#Http RestTemplate拦截器开关,记录请求响应日志,默认true
97-
spring.emily.cloud.http-client-loadbalancer.enable-interceptor=true
98-
#http连接读取超时时间,默认1000毫秒
99-
spring.emily.cloud.http-client-loadbalancer.read-time-out=1000
100-
#http连接连接超时时间,默认1000毫秒
101-
spring.emily.cloud.http-client-loadbalancer.connect-time-out=1000
102-
103-
##API路由设置
104-
#是否开启所有接口的前缀prefix,默认前面添加api
105-
spring.emily.web.path.enable-all-prefix=true
106-
#自定义添加前缀,默认api
107-
spring.emily.web.path.prefix=api
108-
#区分大小写,默认false
109-
spring.emily.web.path.case-sensitive=false
110-
#是否缓存匹配规则,默认null等于true
111-
spring.emily.web.path.cache-patterns=true
112-
#是否去除前后空格,默认false
113-
spring.emily.web.path.trim-tokens=false
114-
#设置URL末尾是否支持斜杠,默认true,如/a/b/有效,/a/b也有效
115-
spring.emily.web.path.use-trailing-slash-match=true
116-
#忽略URL前缀控制器设置,默认空
117-
spring.emily.web.path.ignore-controller-url-prefix=
118-
119-
##跨域设置
120-
#开启跨域设置,默认false
121-
spring.emily.web.cors.enable=false
122-
#设置允许哪些源来访问,多个源用逗号分开
123-
spring.emily.web.cors.allowed-origins=
124-
#允许HTTP请求方法
125-
spring.emily.web.cors.allowed-methods=GET,POST
126-
#设置用户可以拿到的字段
127-
spring.emily.web.cors.allowed-headers=
128-
#设置浏览器是否应该发送凭据cookie
129-
spring.emily.web.cors.allow-credentials=true
130-
#设置响应HEAD,默认无任何设置,不可以使用*
131-
spring.emily.web.cors.exposed-headers=
132-
#设置多长时间内不需要发送预检验请求,可以缓存该结果,默认1800
133-
spring.emily.web.cors.max-age=1800
63+
- 扩展点提供DataSourceCustomizer接口,AOP会根据拦截器的优先级判定使用优先级最高的拦截器
64+
- 属性配置示例
13465

66+
```properties
13567
#是否开启数据源组件, 默认:true
13668
spring.emily.datasource.enabled=true
69+
#是否拦截超类或者接口中的方法,默认:true
70+
spring.emily.datasource.check-inherited=true
13771
#默认数据源配置,默认:default
13872
spring.emily.datasource.default-config=default
13973
#驱动名称
14074
spring.emily.datasource.config.default.driver-class-name=oracle.jdbc.OracleDriver
14175
#配置url
142-
spring.emily.datasource.config.default.url=jdbc:oracle:thin:@1x.1x.8x.1x:1521:xxx
76+
spring.emily.datasource.config.default.url=jdbc:oracle:thin:@xx.xx.xx.xx:1521:qw
14377
#用户名
144-
spring.emily.datasource.config.default.username=xx
78+
spring.emily.datasource.config.default.username=root
14579
#用户密码
146-
spring.emily.datasource.config.default.password=xx
80+
spring.emily.datasource.config.default.password=123456
14781
#数据库连接池类型
14882
spring.emily.datasource.config.default.db-type=com.alibaba.druid.pool.DruidDataSource
14983

84+
spring.emily.datasource.config.slave.driver-class-name=oracle.jdbc.OracleDriver
85+
spring.emily.datasource.config.slave.url=jdbc:oracle:thin:@x.x.x.x:we
86+
spring.emily.datasource.config.slave.username=root
87+
spring.emily.datasource.config.slave.password=123
88+
spring.emily.datasource.config.slave.db-type=com.alibaba.druid.pool.DruidDataSource
89+
```
90+
91+
#### Mybatis埋点组件
92+
93+
- 扩展点MybatisCustomizer,AOP根据拦截器的优先级判定使用优先级最高的拦截器
94+
- 属性配置:
95+
96+
```properties
15097
#是否开启mybatis拦截组件, 默认:true
15198
spring.emily.mybatis.enabled=true
152-
#是否还要检查超类或者接口,默认:false
153-
spring.emily.mybatis.check-inherited=false
99+
#是否拦截超类或者接口中的方法,默认:true
100+
spring.emily.mybatis.check-class-inherited=true
101+
```
102+
103+
104+
105+
#### Redis多数据源组件
106+
107+
- 属性配置
108+
109+
```properties
110+
# 是否开启Redis多数据源配置,默认:true
111+
spring.emily.redis.enabled=true
112+
# Redis监控是否开启,默认:false
113+
spring.emily.redis.monitor-enabled=false
114+
# Redis监控固定间隔时间,默认:30s
115+
spring.emily.redis.monitor-fire-rate=10s
116+
# 是否开启连接校验,默认:false
117+
spring.emily.redis.validate-connection=false
118+
# 是否开启共享本地物理连接,默认:true
119+
spring.emily.redis.share-native-connection=true
120+
121+
spring.emily.redis.config.default.client-type=lettuce
122+
spring.emily.redis.config.default.database=15
123+
spring.emily.redis.config.default.password=test12345
124+
spring.emily.redis.config.default.sentinel.master=xxx
125+
spring.emily.redis.config.default.sentinel.nodes=x.x.x.x:26380,x.x.x.x:26381,xx.x.x.x:26382
126+
# 读取超时时间
127+
spring.emily.redis.config.default.timeout=3000
128+
# 连接超时时间
129+
spring.emily.redis.config.default.connect-timeout=PT3S
130+
spring.emily.redis.config.default.lettuce.pool.enabled=true
131+
spring.emily.redis.config.default.lettuce.pool.max-active=8
132+
spring.emily.redis.config.default.lettuce.pool.max-idle=8
133+
#
134+
spring.emily.redis.config.default.lettuce.pool.min-idle=4
135+
spring.emily.redis.config.default.lettuce.pool.max-wait=-1
136+
# 每隔多少时间空闲线程驱逐器关闭多余的空闲连接,且保持最少空闲连接可用,同时min-idle要大于0
137+
spring.emily.redis.config.default.lettuce.pool.time-between-eviction-runs=PT0.1S
138+
139+
spring.emily.redis.config.test.client-type=lettuce
140+
spring.emily.redis.config.test.database=15
141+
spring.emily.redis.config.test.password=xx
142+
spring.emily.redis.config.test.sentinel.master=xx
143+
spring.emily.redis.config.test.sentinel.nodes=x.x.x.x:26379,x.x.x.x:26379,x.x.x.x:26379
144+
spring.emily.redis.config.test.timeout=300
145+
spring.emily.redis.config.test.lettuce.pool.max-active=8
146+
spring.emily.redis.config.test.lettuce.pool.max-idle=8
147+
spring.emily.redis.config.test.lettuce.pool.min-idle=0
148+
spring.emily.redis.config.test.lettuce.pool.max-wait=-1
149+
```
150+
151+
#### logback日志组件
152+
153+
- 属性配置
154154

155+
```properties
155156
#日志组件
156-
#启动日志访问组件,默认false
157+
#启动日志访问组件,默认:true
157158
spring.emily.logback.enabled=true
158159

159160
#日志文件存放路径,默认是:./logs
160-
spring.emily.logback.appender.file-path=./logs
161+
spring.emily.logback.appender.path=./logs
161162
#如果是 true,日志被追加到文件结尾,如果是 false,清空现存文件,默认是true
162163
spring.emily.logback.appender.append=true
163164
#如果是 true,日志会被安全的写入文件,即使其他的FileAppender也在向此文件做写入操作,效率低,默认是 false|Support multiple-JVM writing to the same log file
164165
spring.emily.logback.appender.prudent=false
165166
#设置是否将输出流刷新,确保日志信息不丢失,默认:true
166167
spring.emily.logback.appender.immediate-flush=true
167168
#是否报告内部状态信息,默认;false
168-
spring.emily.logback.appender.report-state=true
169+
spring.emily.logback.appender.report-state=false
169170

170171
#是否开启基于文件大小和时间的SizeAndTimeBasedRollingPolicy归档策略
171172
#默认是基于TimeBasedRollingPolicy的时间归档策略,默认false
@@ -179,7 +180,7 @@ spring.emily.logback.appender.rolling-policy.total-size-cap=5GB
179180
#设置重启服务后是否清除历史日志文件,默认:false
180181
spring.emily.logback.appender.rolling-policy.clean-history-on-start=true
181182

182-
#是否开启异步记录Appender默认false
183+
#是否开启异步记录Appender,默认:false
183184
spring.emily.logback.appender.async.enabled=false
184185
#队列的最大容量,默认为 256
185186
spring.emily.logback.appender.async.queue-size=256
@@ -193,14 +194,16 @@ spring.emily.logback.appender.async.max-flush-time=1000
193194
# 在队列满的时候 appender 会阻塞而不是丢弃信息。设置为 true,appender 不会阻塞你的应用而会将消息丢弃,默认为 false
194195
spring.emily.logback.appender.async.never-block=false
195196

196-
#日志级别,即该等级之上才会输出,ERROR > WARN > INFO > DEBUG > TRACE >ALL, 默认:DEBUG
197+
#日志级别,即该等级之上才会输出,ERROR > WARN > INFO > DEBUG > TRACE >ALL, 默认:INFO
197198
spring.emily.logback.root.level=info
198199
#通用日志输出格式,默认:[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%-36.36logger{36}:%-4.4line] : %msg%n
199200
spring.emily.logback.root.pattern=[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%-36.36logger{36}:%-4.4line] : %msg%n
200-
#基础日志文件路径
201+
#基础日志文件路径,默认:""
201202
spring.emily.logback.root.file-path=base
203+
#是否将日志信息输出到控制台,默认:true
204+
spring.emily.logback.root.console=true
202205

203-
#日志级别,即该等级之上才会输出,ERROR > WARN > INFO > DEBUG > TRACE >ALL, 默认:DEBUG
206+
#日志级别,即该等级之上才会输出,ERROR > WARN > INFO > DEBUG > TRACE >ALL, 默认:INFO
204207
spring.emily.logback.group.level=info
205208
#模块日志输出格式,默认:%msg%n
206209
spring.emily.logback.group.pattern=[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%-36.36logger{36}:%-4.4line] : %msg%n
@@ -210,13 +213,81 @@ spring.emily.logback.group.console=true
210213
#日志级别,即该等级之上才会输出,ERROR > WARN > INFO > DEBUG > TRACE >ALL, 默认:DEBUG
211214
spring.emily.logback.module.level=info
212215
#模块日志输出格式,默认:%msg%n
213-
spring.emily.logback.module.pattern=[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%-36.36logger{36}:%-4.4line] : %msg%n
216+
spring.emily.logback.module.pattern=%msg%n
214217
#是否将模块日志输出到控制台,默认:false
215218
spring.emily.logback.module.console=true
219+
```
220+
221+
#### RestTemplate请求组件
222+
223+
- 扩展点HttpClientCustomizer,AOP根据拦截器的优先级判定使用优先级最高者
224+
- 属性配置
225+
226+
```properties
227+
#Http RestTemplate组件开关,默认true
228+
spring.emily.http-client.enabled=true
229+
#Http RestTemplate拦截器开关,记录请求响应日志,默认true
230+
spring.emily.http-client.interceptor=true
231+
#http连接读取超时时间,默认5000毫秒
232+
spring.emily.http-client.read-time-out=1000
233+
#http连接连接超时时间,默认10000毫秒
234+
spring.emily.http-client.connect-time-out=1000
235+
```
236+
237+
#### Feign组件
238+
239+
- 扩展点FeignLoggerCustomizer,AOP根据拦截器的优先级判定使用优先级最高者
240+
241+
- 属性配置
242+
243+
```properties
244+
spring.emily.feign.logger.enabled=true
245+
```
246+
247+
#### API路由设置组件
248+
249+
```properties
250+
#是否开启所有接口的前缀prefix,默认前面添加api
251+
spring.emily.web.path.enable-all-prefix=true
252+
#自定义添加前缀,默认api
253+
spring.emily.web.path.prefix=api
254+
#区分大小写,默认false
255+
spring.emily.web.path.case-sensitive=false
256+
#是否缓存匹配规则,默认null等于true
257+
spring.emily.web.path.cache-patterns=true
258+
#是否去除前后空格,默认false
259+
spring.emily.web.path.trim-tokens=false
260+
#设置URL末尾是否支持斜杠,默认true,如/a/b/有效,/a/b也有效
261+
spring.emily.web.path.use-trailing-slash-match=true
262+
#忽略URL前缀控制器设置,默认空
263+
spring.emily.web.path.exclude=
264+
```
265+
266+
#### API跨域组件
267+
268+
```properties
269+
#开启跨域设置,默认false
270+
spring.emily.web.cors.enable=false
271+
#设置允许哪些源来访问,多个源用逗号分开
272+
spring.emily.web.cors.allowed-origins=
273+
#允许HTTP请求方法
274+
spring.emily.web.cors.allowed-methods=GET,POST
275+
#设置用户可以拿到的字段
276+
spring.emily.web.cors.allowed-headers=
277+
#设置浏览器是否应该发送凭据cookie
278+
spring.emily.web.cors.allow-credentials=true
279+
#设置响应HEAD,默认无任何设置,不可以使用*号
280+
spring.emily.web.cors.exposed-headers=
281+
#设置多长时间内不需要发送预检验请求,可以缓存该结果,默认1800秒
282+
spring.emily.web.cors.max-age=1800
283+
```
284+
285+
```
286+
216287
217288
```
218289

219-
##### consul服务查询、删除接口
290+
consul服务查询、删除接口
220291

221292
- 查询服务接口Get
222293

emily-spring-boot-actuator/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-parent</artifactId>
77
<groupId>com.emily.infrastructure</groupId>
8-
<version>4.0.6</version>
8+
<version>4.0.7</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -14,7 +14,7 @@
1414
<dependency>
1515
<groupId>com.emily.infrastructure</groupId>
1616
<artifactId>emily-spring-boot-core</artifactId>
17-
<version>4.0.6</version>
17+
<version>4.0.7</version>
1818
</dependency>
1919
<dependency>
2020
<groupId>org.springframework.boot</groupId>

emily-spring-boot-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-parent</artifactId>
77
<groupId>com.emily.infrastructure</groupId>
8-
<version>4.0.6</version>
8+
<version>4.0.7</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

emily-spring-boot-common/src/main/java/com/emily/infrastructure/common/constant/AopOrderInfo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public class AopOrderInfo {
2121
/**
2222
* Mybatis日志漆面
2323
*/
24-
public static final int MYBATIS = 899;
24+
public static final int MYBATIS = 850;
25+
/**
26+
* MYBATIS拦截器
27+
*/
28+
public static final int MYBATIS_INTERCEPTOR = 852;
2529
/**
2630
* 数据源切面
2731
*/

emily-spring-boot-core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-parent</artifactId>
77
<groupId>com.emily.infrastructure</groupId>
8-
<version>4.0.6</version>
8+
<version>4.0.7</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -15,12 +15,12 @@
1515
<dependency>
1616
<groupId>com.emily.infrastructure</groupId>
1717
<artifactId>emily-spring-boot-common</artifactId>
18-
<version>4.0.6</version>
18+
<version>4.0.7</version>
1919
</dependency>
2020
<dependency>
2121
<groupId>com.emily.infrastructure</groupId>
2222
<artifactId>emily-spring-boot-logback</artifactId>
23-
<version>4.0.6</version>
23+
<version>4.0.7</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>org.springframework.boot</groupId>

emily-spring-boot-datasource/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-parent</artifactId>
77
<groupId>com.emily.infrastructure</groupId>
8-
<version>4.0.6</version>
8+
<version>4.0.7</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -14,7 +14,7 @@
1414
<dependency>
1515
<groupId>com.emily.infrastructure</groupId>
1616
<artifactId>emily-spring-boot-core</artifactId>
17-
<version>4.0.6</version>
17+
<version>4.0.7</version>
1818
</dependency>
1919
<dependency>
2020
<groupId>org.springframework.boot</groupId>

emily-spring-boot-datasource/src/main/java/com/emily/infrastructure/datasource/interceptor/DataSourceCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.lang.reflect.Method;
77

88
/**
9-
* @Description: 多数据源统一拦截器父接口,其实现了Ordered接口,AOP切面会根据优先级顺序启用优先级最高的拦截器
9+
* @Description: 多数据源埋点接口DataSourceCustomizer,AOP切面会根据优先级选择优先级最高的拦截器
1010
* @Author: Emily
1111
* @create: 2022/2/11
1212
*/

0 commit comments

Comments
 (0)