Java Code Examples for io.undertow.server.HttpServerExchange#getRequestStartTime()
The following examples show how to use
io.undertow.server.HttpServerExchange#getRequestStartTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResponseTimeAttribute.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String readAttribute(HttpServerExchange exchange) { long requestStartTime = exchange.getRequestStartTime(); if(requestStartTime == -1) { return null; } final long nanos; Long first = exchange.getAttachment(FIRST_RESPONSE_TIME_NANOS); if(first != null) { nanos = first; } else { nanos = System.nanoTime() - requestStartTime; if(exchange.isResponseComplete()) { //save the response time so it is consistent exchange.putAttachment(FIRST_RESPONSE_TIME_NANOS, nanos); } } if(timeUnit == TimeUnit.SECONDS) { StringBuilder buf = new StringBuilder(); long milis = TimeUnit.MILLISECONDS.convert(nanos, TimeUnit.NANOSECONDS); buf.append(Long.toString(milis / 1000)); buf.append('.'); int remains = (int) (milis % 1000); buf.append(Long.toString(remains / 100)); remains = remains % 100; buf.append(Long.toString(remains / 10)); buf.append(Long.toString(remains % 10)); return buf.toString(); } else { return String.valueOf(timeUnit.convert(nanos, TimeUnit.NANOSECONDS)); } }
Example 2
Source File: DatawaveAuthenticationMechanism.java From datawave with Apache License 2.0 | 5 votes |
private void addTimingRequestHeaders(HttpServerExchange exchange) { long requestStartTime = exchange.getRequestStartTime(); long loginTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - requestStartTime); HeaderMap headers = exchange.getRequestHeaders(); headers.add(HEADER_START_TIME, requestStartTime); headers.add(HEADER_LOGIN_TIME, loginTime); }
Example 3
Source File: ResponseTimeAttribute.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String readAttribute(HttpServerExchange exchange) { long requestStartTime = exchange.getRequestStartTime(); if(requestStartTime == -1) { return null; } final long nanos; Long first = exchange.getAttachment(FIRST_RESPONSE_TIME_NANOS); if(first != null) { nanos = first; } else { nanos = System.nanoTime() - requestStartTime; if(exchange.isResponseComplete()) { //save the response time so it is consistent exchange.putAttachment(FIRST_RESPONSE_TIME_NANOS, nanos); } } if(timeUnit == TimeUnit.SECONDS) { StringBuilder buf = new StringBuilder(); long milis = TimeUnit.MILLISECONDS.convert(nanos, TimeUnit.NANOSECONDS); buf.append(Long.toString(milis / 1000)); buf.append('.'); int remains = (int) (milis % 1000); buf.append(Long.toString(remains / 100)); remains = remains % 100; buf.append(Long.toString(remains / 10)); buf.append(Long.toString(remains % 10)); return buf.toString(); } else { return String.valueOf(timeUnit.convert(nanos, TimeUnit.NANOSECONDS)); } }