【发布时间】:2021-10-19 22:53:20
【问题描述】:
最近我们的 12+ 微服务在不同端口的 AWS 服务器中运行。 有些项目是 api 基础,有些项目是消费者基础,所以最近我在 All this Project 中配置了哨兵,我们使用相同的 DNS 和不同的 EVN,例如`
此 API 项目
- 项目:API
类似的配置
sentry.dns=exmpale1
application.enviroment=PROD_API
这是消费者基础项目
- 项目:返回 类似的配置
sentry.dns=exmpale1
application.enviroment=PROD_BACK
- 项目:结束
类似的配置
sentry.dns=exmpale1
application.enviroment=PROD_OUT
- 项目:在
类似的配置
sentry.dns=exmpale1
application.enviroment=PROD_IN
所有项目都使用相同的配置 Java 类
@Configuration
public class SentryConfiguration {
Logger logger = LoggerFactory.getLogger(SentryConfiguration.class);
@Value("${sentry.dsn:null}")
private String dsn;
@Value("${application.environment:local}")
private String environment;
@EventListener
public void onApplicationEvent(ContextRefreshedEvent event) {
if (!"null".equalsIgnoreCase(dsn)) {
SentryClient sentryClient = Sentry.init(dsn);
sentryClient.setEnvironment(environment);
logger.info("Sentry Configured for BACK");
}
}
}
【问题讨论】:
标签: java spring spring-boot sentry