根据 spring 配置文件设置哨兵属性

Setting Sentry-attributes based on spring profile

有什么方法可以根据当前Spring配置文件为哨兵属性设置不同的值吗?

当前属性位于 sentry.properties 文件中...

不幸的是,将其命名为 application.properties 方法 (application-profilename.properties) 是行不通的。因为无法识别 sentry-profilename.properties 文件中的更改。

理想情况是:

sentry.properties (base information)
sentry-dev.properties (environment attribute = dev)
sentry-prod.properties (environment attribute = prod)

好的,我们将系统变量SENTRY_ENVIRONMENT定义为devprod(基于当前的部署管道)。

所以这解决了我们的问题,我们在 sentry.io 概述中得到了想要的结果!

"You can override the location of the properties file by using either the sentry.properties.file Java System Property or the SENTRY_PROPERTIES_FILE System Environment Variable." 这是来自“https://docs.sentry.io/clients/java/config/#configuration