本文整理汇总了Java中io.undertow.server.handlers.MetricsHandler类的典型用法代码示例。如果您正苦于以下问题:Java MetricsHandler类的具体用法?Java MetricsHandler怎么用?Java MetricsHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricsHandler类属于io.undertow.server.handlers包,在下文中一共展示了MetricsHandler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: to
import io.undertow.server.handlers.MetricsHandler; //导入依赖的package包/类
public static RequestMXBean to(MetricsHandler handler) {
return new RequestMXBean() {
@Override
public void reset() {
handler.reset();
}
@Override
public RequestMetrics getMetrics() {
MetricResult result = handler.getMetrics();
return new RequestMetrics(result.getMetricsStartDate(),
result.getTotalRequestTime(),
result.getMaxRequestTime(), result.getMinRequestTime(),
result.getTotalRequests());
}
};
}
示例2: handleRequest
import io.undertow.server.handlers.MetricsHandler; //导入依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
ServletInfo servletInfo = context.getCurrentServlet().getManagedServlet().getServletInfo();
MetricsHandler handler = servletHandlers.get(servletInfo.getName());
if(handler != null) {
handler.handleRequest(exchange);
} else {
next.handleRequest(exchange);
}
}
示例3: MetricsChainHandler
import io.undertow.server.handlers.MetricsHandler; //导入依赖的package包/类
public MetricsChainHandler(HttpHandler next, MetricsCollector collector, Deployment deployment) {
this.next = next;
final Map<String, MetricsHandler> servletHandlers = new HashMap<>();
for(Map.Entry<String, ServletHandler> entry : deployment.getServlets().getServletHandlers().entrySet()) {
MetricsHandler handler = new MetricsHandler(next);
servletHandlers.put(entry.getKey(), handler);
collector.registerMetric(entry.getKey(), handler);
}
this.servletHandlers = Collections.unmodifiableMap(servletHandlers);
}
示例4: makeSharedHandlers
import io.undertow.server.handlers.MetricsHandler; //导入依赖的package包/类
@Override
protected HttpHandler makeSharedHandlers(App root, OptionMap config,
HttpHandler next) {
HttpHandler shared = super.makeSharedHandlers(root, config, next);
register(root, RequestMetrics.to(new MetricsHandler(shared)),
Arrays.asList("type", "Request", "name", "Global"));
return shared;
}
示例5: MonitoringHandler
import io.undertow.server.handlers.MetricsHandler; //导入依赖的package包/类
public MonitoringHandler(HttpHandler nextHandler) {
MetricsHandler mh = new MetricsHandler(nextHandler);
this.pathHandler = path(mh).addPath("/stats", exchange -> {
HightideExchange ex = HightideExchangeFactory.get(exchange);
HightideResponse resp = new HightideResponse();
resp.setReturnedObj(mh.getMetrics());
ex.setResponse(resp);
respond().handleRequest(exchange);
});
}
示例6: registerMetric
import io.undertow.server.handlers.MetricsHandler; //导入依赖的package包/类
void registerMetric(String servletName, MetricsHandler handler);