forked from j62/ctbrec
debug statistics page
This commit is contained in:
parent
a003f84e70
commit
5bc8a6fdf9
|
@ -37,6 +37,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
|
||||
@Slf4j
|
||||
public abstract class HttpClient {
|
||||
@Getter
|
||||
private static final ConnectionPool GLOBAL_HTTP_CONN_POOL = new ConnectionPool(10, 2, TimeUnit.MINUTES);
|
||||
|
||||
@Getter
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ctbrec.recorder.server;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.io.HttpClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONObject;
|
||||
|
@ -24,6 +25,7 @@ public class DebugServlet extends AbstractCtbrecServlet {
|
|||
public static final String BASE_URL = "/debug";
|
||||
|
||||
private static final Pattern URL_PATTERN_DEBUG_STACK = Pattern.compile(BASE_URL + "/stack(/.*?)");
|
||||
private static final Pattern URL_PATTERN_DEBUG_STATS = Pattern.compile(BASE_URL + "/stats");
|
||||
|
||||
public DebugServlet()
|
||||
{}
|
||||
|
@ -57,9 +59,18 @@ public class DebugServlet extends AbstractCtbrecServlet {
|
|||
}
|
||||
});
|
||||
|
||||
log.debug("Stacks Request {} - {}", threadUrl, stacks);
|
||||
log.debug("Stacks Request {}", threadUrl);
|
||||
resp.setContentType("text/plain");
|
||||
sendResponse(resp, SC_OK, box.text);
|
||||
} else if ((m = URL_PATTERN_DEBUG_STATS.matcher(requestURI)).matches()) {
|
||||
String text = "";
|
||||
text += String.format("GLOBAL_HTTP_CONN_POOL: connectionCount=%d, idleConnectionCount=%d\n",
|
||||
HttpClient.getGLOBAL_HTTP_CONN_POOL().connectionCount(),
|
||||
HttpClient.getGLOBAL_HTTP_CONN_POOL().idleConnectionCount());
|
||||
|
||||
log.debug("Stats Request");
|
||||
resp.setContentType("text/plain");
|
||||
sendResponse(resp, SC_OK, text);
|
||||
} else
|
||||
sendResponse(resp, SC_NOT_FOUND, "");
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue