import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.HealthEndpoint;
import org.springframework.boot.actuate.endpoint.InfoEndpoint;
import org.springframework.boot.actuate.endpoint.MetricsEndpoint;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
public class StatisticsController {
private final HealthEndpoint health;
private final InfoEndpoint info;
private final MetricsEndpoint metrics;
private final Map<String, Object> statistics = new HashMap<>();
@Autowired
public StatisticsController(HealthEndpoint health, InfoEndpoint info, MetricsEndpoint metrics) {
this.health = health;
this.info = info;
this.metrics = metrics;
}
@GetMapping("/manage/statistics")
public Map<String, Object> statistics() {
statistics.put("health", health.invoke());
statistics.put("info", info.invoke());
statistics.put("metrics", metrics.invoke());
return statistics;
}
}