【发布时间】:2019-07-11 18:27:12
【问题描述】:
我正在使用 spring boot 执行器来监控我的微服务的运行状况。我还需要服务器当前时间戳。 info/ 只返回构建的时间戳。相反,我想要服务器当前的时间戳。
【问题讨论】:
-
“当前时间戳”是什么意思?服务器的系统时间?
-
是的。我的意思是服务器时间
我正在使用 spring boot 执行器来监控我的微服务的运行状况。我还需要服务器当前时间戳。 info/ 只返回构建的时间戳。相反,我想要服务器当前的时间戳。
【问题讨论】:
您可以通过提供额外的InfoContributor 来简单地添加您需要的值。
@Component
public class TimeInfoContributor implements InfoContributor {
@Override
public void contribute(Info.Builder builder) {
// Calculate your desired timeValue here.
builder.withDetail("time", timeValue);
}
}
【讨论】: