2016-06-01 1 views
0

メトリックを取得する方法スプリングブートアクチュエータを使用して特定のRESTエンドポイントに対してGET、POSTおよびPUTメソッドを個別に実行する方法。デフォルトでメトリックを取得する方法スプリングブートアクチュエータを使用して、特定のRESTエンドポイントのGET、POST、およびPUTメソッドとは別に


我々が得る: - "gauge.response.customer":631、 私は

  1. "gauge.response.customer.GET" 必要があります:631、OR「gauge.responseを.GET.customer ":631、
  2. "gauge.response.customer.POST":1631、OR "gauge.response.POST.customer":事前に1631の

おかげ

答えて

0

ええと私はあなたがそのようなエンドポイントを壊すことはできないとは思わない。しかし、私はアクチュエータが非常に柔軟で、そのエンドポイントに新しいメトリックを追加できることを知っています。主にカウンターに興味があるようですので、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"; 
} 
関連する問題