簡體   English   中英

如何使用彈簧啟動執行器分別捕獲給定REST端點的GET,POST和PUT方法的度量

[英]How to capture metrics Separately for GET,POST and PUT method for given REST Endpoint using spring boot actuators

如何使用彈簧啟動執行器分別捕獲給定REST端點的GET,POST和PUT方法的度量。

防爆
默認情況下,我們得到:-“ gauge.response.customer”:631,我需要

  1. “ gauge.response.customer.GET”:631,或“ gauge.response.GET.customer”:631,
  2. “ gauge.response.customer.POST”:1631,或“ gauge.response.POST.customer”:1631

提前致謝

嗯,我不認為您可以像這樣分解端點。 但是,我知道執行器非常靈活,您可以向該端點添加新指標。 看來您主要對計數器感興趣,所以我建議您使用Spring引導所提供的CounterService。

private CounterService counterService;

@Autowired
public MyClassName(CounterService counterService) {
    this.counterService = counterService;
}

@RequestMapping(method=RequestMethod.POST)
public String myPostMethod(Object obj) {
    counterService.increment("mycontroller.post.method");
    //...
    return "myPostMethod";
}

@RequestMapping(method=RequestMethod.GET)
public String myGetMethod() {
    counterService.increment("mycontroller.get.method");
    //...
    return "myGetMethod";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM