Search in sources :

Example 6 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class HttpStatusItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    routingContext = Mockito.mock(RoutingContext.class);
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    response = Mockito.mock(Response.class);
    serverResponse = Mockito.mock(HttpServerResponse.class);
    accessLogEvent = new ServerAccessLogEvent();
    accessLogEvent.setRoutingContext(routingContext);
    strBuilder = new StringBuilder();
}
Also used : HttpServerResponse(io.vertx.core.http.HttpServerResponse) Response(org.apache.servicecomb.swagger.invocation.Response) RoutingContext(io.vertx.ext.web.RoutingContext) InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) HttpServerResponse(io.vertx.core.http.HttpServerResponse) Before(org.junit.Before)

Example 7 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class PlainTextItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    accessLogEvent = new ServerAccessLogEvent();
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    strBuilder = new StringBuilder();
}
Also used : ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) Before(org.junit.Before)

Example 8 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class CookieItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    mockContext = Mockito.mock(RoutingContext.class);
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    invocation = Mockito.mock(Invocation.class);
    restClientRequest = Mockito.mock(RestClientRequestImpl.class);
    accessLogEvent = new ServerAccessLogEvent();
    strBuilder = new StringBuilder();
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) Invocation(org.apache.servicecomb.core.Invocation) RestClientRequestImpl(org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl) Before(org.junit.Before)

Example 9 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class DurationMillisecondItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    invocation = Mockito.mock(Invocation.class);
    invocationStageTrace = Mockito.mock(InvocationStageTrace.class);
    when(finishEvent.getInvocation()).thenReturn(invocation);
    when(invocation.getInvocationStageTrace()).thenReturn(invocationStageTrace);
    when(invocationStageTrace.getStartSend()).thenReturn(0L);
    when(invocationStageTrace.getFinish()).thenReturn(1000_000L);
    accessLogEvent = new ServerAccessLogEvent();
    accessLogEvent.setMilliStartTime(1L);
    accessLogEvent.setMilliEndTime(2L);
    strBuilder = new StringBuilder();
}
Also used : InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) Invocation(org.apache.servicecomb.core.Invocation) InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace) Before(org.junit.Before)

Example 10 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class RestServerVerticle method mountAccessLogHandler.

private void mountAccessLogHandler(Router mainRouter) {
    if (!AccessLogConfig.INSTANCE.isServerLogEnabled()) {
        return;
    }
    LOGGER.info("access log enabled, pattern = {}", AccessLogConfig.INSTANCE.getServerLogPattern());
    mainRouter.route().handler(context -> {
        ServerAccessLogEvent accessLogEvent = new ServerAccessLogEvent().setRoutingContext(context).setMilliStartTime(System.currentTimeMillis()).setLocalAddress(LocalHostAccessItem.getLocalAddress(context));
        context.response().endHandler(event -> EventManager.post(accessLogEvent.setMilliEndTime(System.currentTimeMillis())));
        context.next();
    });
}
Also used : ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent)

Aggregations

ServerAccessLogEvent (org.apache.servicecomb.core.event.ServerAccessLogEvent)48 Before (org.junit.Before)44 InvocationFinishEvent (org.apache.servicecomb.core.event.InvocationFinishEvent)42 RoutingContext (io.vertx.ext.web.RoutingContext)36 Invocation (org.apache.servicecomb.core.Invocation)34 HttpServerRequest (io.vertx.core.http.HttpServerRequest)20 RestClientRequestImpl (org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl)16 HttpClientRequest (io.vertx.core.http.HttpClientRequest)14 Endpoint (org.apache.servicecomb.core.Endpoint)10 HashMap (java.util.HashMap)8 URIEndpointObject (org.apache.servicecomb.foundation.common.net.URIEndpointObject)8 HttpServerResponse (io.vertx.core.http.HttpServerResponse)6 SocketAddress (io.vertx.core.net.SocketAddress)6 InvocationStageTrace (org.apache.servicecomb.core.invocation.InvocationStageTrace)6 HttpConnection (io.vertx.core.http.HttpConnection)4 Response (org.apache.servicecomb.swagger.invocation.Response)4 Swagger (io.swagger.models.Swagger)2 MultiMap (io.vertx.core.MultiMap)2 HeadersMultiMap (io.vertx.core.http.impl.headers.HeadersMultiMap)2 SimpleDateFormat (java.text.SimpleDateFormat)2