Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
44616d8e
提交
44616d8e
authored
5月 21, 2019
作者:
sin
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
e0ce00f7
8240a0dc
显示空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
201 行增加
和
89 行删除
+201
-89
README.md
README.md
+23
-2
GlobalExceptionHandler.java
...er/common/framework/exception/GlobalExceptionHandler.java
+0
-58
pom.xml
common/mall-spring-boot/pom.xml
+13
-0
MetricsAutoConfiguration.java
...er/mall/spring/boot/metrics/MetricsAutoConfiguration.java
+24
-0
GlobalExceptionHandler.java
.../mall/spring/boot/web/handler/GlobalExceptionHandler.java
+9
-0
spring.factories
...-spring-boot/src/main/resources/META-INF/spring.factories
+2
-1
pom.xml
order/order-application/pom.xml
+9
-2
application.yaml
order/order-application/src/main/resources/application.yaml
+8
-0
pom.xml
pay/pay-application/pom.xml
+9
-2
application.yaml
pay/pay-application/src/main/resources/application.yaml
+8
-0
pom.xml
product/product-application/pom.xml
+10
-0
application.yaml
...t/product-application/src/main/resources/application.yaml
+9
-0
pom.xml
promotion/promotion-application/pom.xml
+10
-0
application.yaml
...promotion-application/src/main/resources/application.yaml
+9
-0
pom.xml
search/search-application/pom.xml
+10
-0
application.yaml
...ch/search-application/src/main/resources/application.yaml
+9
-0
pom.xml
system/system-application/pom.xml
+0
-5
MonitorConfiguration.java
...r/mall/admin/application/config/MonitorConfiguration.java
+0
-9
PassportController.java
...min/application/controller/admins/PassportController.java
+10
-0
application-test.yaml
...stem-application/src/main/resources/application-test.yaml
+7
-7
PageSmsSignBO.java
.../java/cn/iocoder/mall/admin/api/bo/sms/PageSmsSignBO.java
+1
-2
PageSmsTemplateBO.java
...a/cn/iocoder/mall/admin/api/bo/sms/PageSmsTemplateBO.java
+1
-1
pom.xml
user/user-application/pom.xml
+12
-0
application.yaml
user/user-application/src/main/resources/application.yaml
+8
-0
没有找到文件。
README.md
浏览文件 @
44616d8e
...
...
@@ -62,6 +62,12 @@
*
地址:http://skywalking-ui.shop.iocoder.cn:18099
*
管理员账号:admin / admin
**Grafana UI**
*
地址:http://grafana.shop.iocoder.cn:18099
*
演示账号:yudaoyuanma / yudaoyuanma
*
用于展示 Prometheus 收集的 Metrics 指标数据。
**Dubbo Admin**
*
地址:http://dubbo-admin.shop.iocoder.cn:18099
...
...
@@ -74,7 +80,8 @@
**Sentinel Console**
TODO
*
地址:http://sentinel.shop.iocoder.cn:18099
*
账号:sentinel / sentinel
**XXL-Job Console**
...
...
@@ -139,7 +146,6 @@ TODO 此处应有一个架构图的装逼 JPG 图。
|
[
Elasticsearch
](
https://www.elastic.co/cn/
)
| 分布式搜索引擎 | 6.7.1 |
|
[
Dubbo
](
http://dubbo.apache.org/
)
| 分布式 RPC 服务框架 | 2.7.1 |
|
[
RocketMQ
](
http://dubbo.apache.org/
)
| 消息中间件 | 4.3.2 |
|
[
SkyWalking
](
http://skywalking.apache.org/
)
| 分布式应用追踪系统 | 6.0.0 |
|
[
Seata
](
https://github.com/seata/seata
)
| 分布式事务中间件 | 0.5.1 |
|
[
Zookeeper
](
http://zookeeper.apache.org/
)
| 分布式系统协调 | 3.4.9 作为注册中心 |
|
[
XXL-Job
](
http://www.xuxueli.com/xxl-job/
)
| 分布式任务调度平台 | 2.0.1 |
...
...
@@ -170,6 +176,21 @@ TODO 此处应有一个架构图的装逼 JPG 图。
|
[
React
](
https://reactjs.org/
)
| JavaScript 框架 | 16.7.0 |
|
[
Ant Design
](
https://ant.design/docs/react/introduce-cn
)
| React UI 组件库 | 3.13.0 |
### 监控
一般来说,监控会有三种方式:
*
1、Tracing ,我们采用 Apache SkyWalking
*
2、Logging ,我们采用 ELK
*
3、Metrics ,我们采用 Prometheus
| 框架 | 说明 | 版本 |
| --- | --- | --- |
|
[
SkyWalking
](
http://skywalking.apache.org/
)
| 分布式应用追踪系统 | 6.0.0 |
|
[
Prometheus
](
https://prometheus.io/
)
| 服务监控体系 | 2.9.2 |
|
[
Alertmanager
](
https://prometheus.io/docs/alerting/alertmanager/
)
| 告警管理器 | 0.17.0 |
|
[
Grafana
](
https://grafana.com/
)
| 仪表盘和图形编辑器 | 0.17.0 |
### 其它
*
Jenkins 持续集成
...
...
common/common-framework/src/main/java/cn/iocoder/common/framework/exception/GlobalExceptionHandler.java
deleted
100644 → 0
浏览文件 @
e0ce00f7
package
cn
.
iocoder
.
common
.
framework
.
exception
;
import
cn.iocoder.common.framework.constant.SysErrorCodeEnum
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.MissingServletRequestParameterException
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.ConstraintViolationException
;
@ControllerAdvice
public
class
GlobalExceptionHandler
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
// 逻辑异常
@ResponseBody
@ExceptionHandler
(
value
=
ServiceException
.
class
)
public
CommonResult
serviceExceptionHandler
(
HttpServletRequest
req
,
ServiceException
ex
)
{
logger
.
debug
(
"[serviceExceptionHandler]"
,
ex
);
return
CommonResult
.
error
(
ex
.
getCode
(),
ex
.
getMessage
());
}
// Spring MVC 参数不正确
@ResponseBody
@ExceptionHandler
(
value
=
MissingServletRequestParameterException
.
class
)
public
CommonResult
missingServletRequestParameterExceptionHandler
(
HttpServletRequest
req
,
MissingServletRequestParameterException
ex
)
{
logger
.
warn
(
"[missingServletRequestParameterExceptionHandler]"
,
ex
);
return
CommonResult
.
error
(
SysErrorCodeEnum
.
MISSING_REQUEST_PARAM_ERROR
.
getCode
(),
SysErrorCodeEnum
.
MISSING_REQUEST_PARAM_ERROR
.
getMessage
()
+
":"
+
ex
.
getMessage
());
}
@ResponseBody
@ExceptionHandler
(
value
=
ConstraintViolationException
.
class
)
public
CommonResult
constraintViolationExceptionHandler
(
HttpServletRequest
req
,
ConstraintViolationException
ex
)
{
logger
.
info
(
"[constraintViolationExceptionHandler]"
,
ex
);
// TODO 芋艿,后续要想一个更好的方式。
// 拼接详细报错
StringBuilder
detailMessage
=
new
StringBuilder
(
"\n\n详细错误如下:"
);
ex
.
getConstraintViolations
().
forEach
(
constraintViolation
->
detailMessage
.
append
(
"\n"
).
append
(
constraintViolation
.
getMessage
()));
return
CommonResult
.
error
(
SysErrorCodeEnum
.
VALIDATION_REQUEST_PARAM_ERROR
.
getCode
(),
SysErrorCodeEnum
.
VALIDATION_REQUEST_PARAM_ERROR
.
getMessage
()
+
detailMessage
.
toString
());
}
@ResponseBody
@ExceptionHandler
(
value
=
Exception
.
class
)
public
CommonResult
resultExceptionHandler
(
HttpServletRequest
req
,
Exception
e
)
{
logger
.
error
(
"[resultExceptionHandler]"
,
e
);
// 返回
return
CommonResult
.
error
(
SysErrorCodeEnum
.
SYS_ERROR
.
getCode
(),
SysErrorCodeEnum
.
SYS_ERROR
.
getMessage
());
}
// TODO 芋艿,应该还有其它的异常,需要进行翻译
}
common/mall-spring-boot/pom.xml
浏览文件 @
44616d8e
...
...
@@ -60,6 +60,19 @@
<optional>
true
</optional>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-actuator-autoconfigure
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
<optional>
true
</optional>
</dependency>
</dependencies>
</project>
common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/metrics/MetricsAutoConfiguration.java
0 → 100644
浏览文件 @
44616d8e
package
cn
.
iocoder
.
mall
.
spring
.
boot
.
metrics
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
@ConditionalOnClass
({
MeterRegistryCustomizer
.
class
})
@ConditionalOnProperty
(
prefix
=
"management.metrics"
,
value
=
"enable"
,
matchIfMissing
=
true
)
// 允许使用 management.metrics.enable=false 禁用 Metrics
public
class
MetricsAutoConfiguration
{
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
@Bean
MeterRegistryCustomizer
<
MeterRegistry
>
metricsCommonTags
()
{
return
registry
->
registry
.
config
().
commonTags
(
"application"
,
applicationName
);
}
}
common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/web/handler/GlobalExceptionHandler.java
浏览文件 @
44616d8e
...
...
@@ -10,6 +10,8 @@ import cn.iocoder.mall.admin.api.SystemLogService;
import
cn.iocoder.mall.admin.api.dto.systemlog.AccessLogAddDTO
;
import
cn.iocoder.mall.admin.api.dto.systemlog.ExceptionLogAddDTO
;
import
com.alibaba.fastjson.JSON
;
import
io.micrometer.core.instrument.Counter
;
import
io.micrometer.core.instrument.Metrics
;
import
org.apache.commons.lang3.exception.ExceptionUtils
;
import
org.apache.dubbo.config.annotation.Reference
;
import
org.slf4j.Logger
;
...
...
@@ -29,6 +31,11 @@ import java.util.Date;
@ControllerAdvice
public
class
GlobalExceptionHandler
{
/**
* 异常总数 Metrics
*/
private
static
final
Counter
EXCEPTION_COUNTER
=
Metrics
.
counter
(
"mall.exception.total"
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Value
(
"${spring.application.name}"
)
...
...
@@ -73,6 +80,8 @@ public class GlobalExceptionHandler {
// 插入异常日志
ExceptionLogAddDTO
exceptionLog
=
new
ExceptionLogAddDTO
();
try
{
// 增加异常计数 metrics
EXCEPTION_COUNTER
.
increment
();
// 初始化 exceptionLog
initExceptionLog
(
exceptionLog
,
req
,
e
);
// 执行插入 exceptionLog
...
...
common/mall-spring-boot/src/main/resources/META-INF/spring.factories
浏览文件 @
44616d8e
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.iocoder.mall.spring.boot.web.AdminMVCAutoConfiguration, \
cn.iocoder.mall.spring.boot.web.UserMVCAutoConfiguration, \
cn.iocoder.mall.spring.boot.swagger.SwaggerAutoConfiguration
cn.iocoder.mall.spring.boot.swagger.SwaggerAutoConfiguration, \
cn.iocoder.mall.spring.boot.metrics.MetricsAutoConfiguration
order/order-application/pom.xml
浏览文件 @
44616d8e
...
...
@@ -59,13 +59,20 @@
<groupId>
de.codecentric
</groupId>
<artifactId>
spring-boot-admin-starter-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
<!-- 测试相关 -->
...
...
order/order-application/src/main/resources/application.yaml
浏览文件 @
44616d8e
...
...
@@ -18,3 +18,11 @@ server:
swagger
:
enable
:
false
management
:
endpoints
:
web
:
exposure
:
include
:
health,info,env,metrics,prometheus
metrics
:
enabled
:
true
pay/pay-application/pom.xml
浏览文件 @
44616d8e
...
...
@@ -66,13 +66,20 @@
<groupId>
de.codecentric
</groupId>
<artifactId>
spring-boot-admin-starter-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
</dependencies>
...
...
pay/pay-application/src/main/resources/application.yaml
浏览文件 @
44616d8e
...
...
@@ -18,3 +18,11 @@ server:
swagger
:
enable
:
false
management
:
endpoints
:
web
:
exposure
:
include
:
health,info,env,metrics,prometheus
metrics
:
enabled
:
true
product/product-application/pom.xml
浏览文件 @
44616d8e
...
...
@@ -65,6 +65,16 @@
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
product/product-application/src/main/resources/application.yaml
浏览文件 @
44616d8e
...
...
@@ -18,3 +18,12 @@ server:
swagger
:
enable
:
false
management
:
endpoints
:
web
:
exposure
:
include
:
health,info,env,metrics,prometheus
metrics
:
enabled
:
true
promotion/promotion-application/pom.xml
浏览文件 @
44616d8e
...
...
@@ -76,6 +76,16 @@
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
promotion/promotion-application/src/main/resources/application.yaml
浏览文件 @
44616d8e
...
...
@@ -18,3 +18,12 @@ server:
swagger
:
enable
:
false
management
:
endpoints
:
web
:
exposure
:
include
:
health,info,env,metrics,prometheus
metrics
:
enabled
:
true
search/search-application/pom.xml
浏览文件 @
44616d8e
...
...
@@ -65,6 +65,16 @@
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
search/search-application/src/main/resources/application.yaml
浏览文件 @
44616d8e
...
...
@@ -18,3 +18,12 @@ server:
swagger
:
enable
:
false
management
:
endpoints
:
web
:
exposure
:
include
:
health,info,env,metrics,prometheus
metrics
:
enabled
:
true
system/system-application/pom.xml
浏览文件 @
44616d8e
...
...
@@ -75,11 +75,6 @@
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.prometheus</groupId>-->
<!-- <artifactId>simpleclient_spring_boot</artifactId>-->
<!-- </dependency>-->
<!-- 测试相关 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
system/system-application/src/main/java/cn/iocoder/mall/admin/application/config/MonitorConfiguration.java
deleted
100644 → 0
浏览文件 @
e0ce00f7
package
cn
.
iocoder
.
mall
.
admin
.
application
.
config
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
//@EnablePrometheusEndpoint
//@EnableSpringBootMetricsCollector
public
class
MonitorConfiguration
{
}
system/system-application/src/main/java/cn/iocoder/mall/admin/application/controller/admins/PassportController.java
浏览文件 @
44616d8e
...
...
@@ -5,6 +5,8 @@ import cn.iocoder.mall.admin.api.AdminService;
import
cn.iocoder.mall.admin.api.OAuth2Service
;
import
cn.iocoder.mall.admin.api.bo.admin.AdminAuthenticationBO
;
import
cn.iocoder.mall.admin.api.dto.admin.AdminAuthenticationDTO
;
import
io.micrometer.core.instrument.Counter
;
import
io.micrometer.core.instrument.Metrics
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.dubbo.config.annotation.Reference
;
...
...
@@ -19,6 +21,11 @@ import static cn.iocoder.common.framework.vo.CommonResult.success;
@Api
(
"Admin Passport 模块"
)
public
class
PassportController
{
/**
* 登陆总数 Metrics
*/
private
static
final
Counter
METRICS_LOGIN_TOTAL
=
Metrics
.
counter
(
"mall.admin.passport.login.total"
);
@Reference
(
validation
=
"true"
,
version
=
"${dubbo.provider.OAuth2Service.version}"
)
private
OAuth2Service
oauth2Service
;
...
...
@@ -28,6 +35,9 @@ public class PassportController {
@PostMapping
(
"/login"
)
@ApiOperation
(
value
=
"手机号 + 密码登陆"
)
public
CommonResult
<
AdminAuthenticationBO
>
login
(
AdminAuthenticationDTO
adminAuthenticationDTO
)
{
// 增加计数
METRICS_LOGIN_TOTAL
.
increment
();
// 执行登陆
return
success
(
adminService
.
authentication
(
adminAuthenticationDTO
));
}
...
...
system/system-application/src/main/resources/application-test.yaml
浏览文件 @
44616d8e
...
...
@@ -6,13 +6,13 @@ spring:
url
:
http://127.0.0.1:18097
management
:
endpoints
:
web
:
exposure
:
include
:
"
*"
server
:
port
:
19083
# 配置独立端口。而该端口,不使用 nginx 对外暴露,从而不配置安全认证。也就是说,内网环境可访问,外网环境不可访问。当然,这么做的前提是,认为内网安全。
#
management:
#
endpoints:
#
web:
#
exposure:
#
include: "*"
#
server:
#
port: 19083 # 配置独立端口。而该端口,不使用 nginx 对外暴露,从而不配置安全认证。也就是说,内网环境可访问,外网环境不可访问。当然,这么做的前提是,认为内网安全。
swagger
:
enable
:
true
# 暂时不去掉
system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/sms/PageSmsSignBO.java
浏览文件 @
44616d8e
package
cn
.
iocoder
.
mall
.
admin
.
api
.
bo
.
sms
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
...
...
@@ -28,7 +27,7 @@ public class PageSmsSignBO {
@Data
@Accessors
(
chain
=
true
)
public
class
Sign
{
public
static
class
Sign
{
/**
* 编号
*/
...
...
system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/sms/PageSmsTemplateBO.java
浏览文件 @
44616d8e
...
...
@@ -25,7 +25,7 @@ public class PageSmsTemplateBO {
@Data
@Accessors
(
chain
=
true
)
public
class
Template
{
public
static
class
Template
{
/**
* 编号
*/
...
...
user/user-application/pom.xml
浏览文件 @
44616d8e
...
...
@@ -62,6 +62,18 @@
<artifactId>
swagger-bootstrap-ui
</artifactId>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
user/user-application/src/main/resources/application.yaml
浏览文件 @
44616d8e
...
...
@@ -18,3 +18,11 @@ server:
swagger
:
enable
:
false
management
:
endpoints
:
web
:
exposure
:
include
:
health,info,env,metrics,prometheus
metrics
:
enabled
:
true
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论