我使用spring-boot.1.3.0
,它提供了将自定义metrics
存储在内存中的功能,如下所示:
@Service
public class MyService {
private CounterService counterService;
private GaugeService gaucheService;
@Autowired
public MyService(CounterService counterService) {
this.counterService = counterService;
}
public void exampleMethod() {
this.counterService.increment("services.system.myservice.invoked");
}
}
问题:如何以编程方式从CounterService
和GaugeService
读取计算值?
答案 0 :(得分:5)
df1 <- structure(list(max1 = c("x9", "x5"), max2 = c("x8",
"x3"), max3 = c("x7",
"x4"), max4 = c("x6", "x6"), max5 = c("x10", "x10"),
max6 = c("x5",
"x1"), max7 = c("x4", "x7"), max8 = c("x2", "x2"),
max9 = c("x1",
"x8"), max10 = c("x3", "x9")), .Names = c("max1", "max2",
"max3",
"max4", "max5", "max6", "max7", "max8", "max9", "max10"),
class = "data.frame", row.names = c(NA, -2L))
lvls <- unique(unlist(df1))
lvls2 <- c("abc", "vb", "ab", "fg", "cf", "qw", "cd",
"zx", "gh", "er")
答案 1 :(得分:2)
Javadoc显示reset
方法:http://docs.spring.io/autorepo/docs/spring-boot/1.3.0.RELEASE/api/org/springframework/boot/actuate/metrics/CounterService.html
答案 2 :(得分:0)
@membersound的答案有效,但我认为最好使用
@Autowired
private MetricReader metricReader;
代替
@Autowired
private BufferMetricReader metrics;