我一直在玩spring-boot中的度量標準,並且在spring-cloud似乎改變行爲方式時遇到了一些困惑。春季引導指標與春季雲指標
具有致動器,並與單個控制器的簡單最小彈簧引導1.3.3.RELEASE應用:
@RestController
public class HelloController {
@Autowired
private CounterService counterService;
@RequestMapping("/hello")
public String sayHello(@RequestParam("name") String name) {
counterService.increment("counter.calls.hello");
return "Hello, " + name;
}
}
度量端點用於該應用具有
...
gauge.response.hello: 5,
gauge.response.metrics: 69,
gauge.response.star-star.favicon.ico: 2,
counter.status.200.star-star.favicon.ico: 4,
counter.status.200.metrics: 1,
counter.calls.hello: 5,
counter.status.200.hello: 5
其是如上述春季啓動文檔。我的自定義計數器(counter.calls.hello)按照預期的方式用作計數器。
現在,如果我增加了Spring的雲起動尤里卡(Brixton.RC1)到我的聚甲醛,不別人改變什麼,指標端點有
...
gauge.servo.counter.calls.hello: 1,
normalized.servo.rest.totaltime: 0,
normalized.servo.rest.count: 0,
gauge.servo.rest.min: 0,
gauge.servo.rest.max: 0,
gauge.servo.response.hello: 7,
gauge.servo.response.star-star.favicon.ico: 2,
正常MVC指標都沒有了。響應代碼信息在哪裏?我的自定義計數器報告爲gauge.servo.counter.calls.hello,但它不再用作計數器,即使我已經對HelloController進行了5次調用,它似乎也只顯示值1。一些調試和搜索讓我將計數器度量名稱更改爲meter.calls.hello,這導致度量響應中的counter.servo.calls.hello,並恢復計數器功能。
進一步閱讀表明春天雲默認伺服度量指標,並指出如果我使用Java 8,我應該使用觀衆。添加彈簧雲起動觀衆到我的POM,並回到「counter.calls.hello」作爲計數器的度量標準名稱,度量端點有
...
counter.calls.hello(): 3,
response.hello(): 7,
response.metrics(): 9,
response.star-star.favicon.ico(): 2,
這甚至更少內置信息有關休息端點,但我的自定義計數器似乎功能。
有關指標的Spring-cloud文檔似乎表明我應該使用ServoRegistry,無論是使用伺服還是旁觀者。觀衆指標部分的術語不同。櫃檯不按我期望的方式工作。如文檔中所述,當我使用ServoRegistry發佈一個簡單的計數器時,我會返回度量標準端點中的某種比率。
在伺服和/或旁觀者中,是否有一些額外的價值與Spring-Boot提供的內容有關? Spring-cloud文檔表明,有更多信息記錄在默認控制器指標中,但它們沒有顯示在/度量標準中。我應該排除ServoMetricsAutoConfiguration並使用spring-boot實現嗎?