[英]Does servo monito annotation works out of the box?
I have write a method like that: 我写了这样的方法:
@Scheduled(fixedDelay = 10_000)
@Monitor(name = "componentMonitor", type = DataSourceType.COUNTER)
public int method() {
log.info("ping");
return RandomUtils.nextInt();
}
It is invocated and ping
appears in console, but componentMonitor
do not appears into /metrics
this metric is not send to org.springframework.boot.actuate.autoconfigure.ExportMetricReader
. 它被启动,并且
ping
出现在控制台中,但是componentMonitor
没有出现在/metrics
该度量未发送到org.springframework.boot.actuate.autoconfigure.ExportMetricReader
。 So how configurated servo/spectacor to make @Monitor
annotations work? 那么如何配置伺服/ spectacor使
@Monitor
注释起作用?
Note 注意
Reporting other metric via com.netflix.spectator.api.Registry
works. 通过
com.netflix.spectator.api.Registry
报告其他指标的工作原理。 So generally metric reporting and servo itself work. 因此,通常,指标报告和伺服器本身都可以工作。
No, it doesn't. 不,不是。 I think you can use
Monitors.newObjectMonitor(id, object)
to get it to work. 我认为您可以使用
Monitors.newObjectMonitor(id, object)
使其正常工作。 There is no aspect or anything to auto-create the Monitor
. 没有方面或任何内容可以自动创建
Monitor
。
It's my understanding that you need to register a MonitorRegistryMetricPoller for the @Monitor to work: 据我了解,您需要注册一个MonitorRegistryMetricPoller才能使@Monitor起作用:
private void schedule(MetricPoller poller, List<MetricObserver> observers) {
final PollRunnable task = new PollRunnable(poller, BasicMetricFilter.MATCH_ALL,
true, observers);
PollScheduler.getInstance().addPoller(task, 1, TimeUnit.MINUTES);
}
private void initMetricsPublishing() {
final List<MetricObserver> observers = new ArrayList<>();
final AmazonCloudWatchClient cloudWatchClient =
new AmazonCloudWatchClient(awsCredentials);
cloudWatchClient.setEndpoint(String.format("monitoring.%s.amazonaws.com", REGION));
AwsTaggingCloudWatchMetricObserver cloudWatchMetricObserver = new AwsTaggingCloudWatchMetricObserver("cloudwatch",
"Nomp", cloudWatchClient);
observers.add(cloudWatchMetricObserver);
PollScheduler.getInstance().start();
schedule(new MonitorRegistryMetricPoller(), observers); // <--- this
schedule(new JvmMetricPoller(), observers);
schedule(new TomcatPoller(), observers);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.