Search in sources :

Example 1 with InvocationStageTrace

use of org.apache.servicecomb.core.invocation.InvocationStageTrace 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 2 with InvocationStageTrace

use of org.apache.servicecomb.core.invocation.InvocationStageTrace in project java-chassis by ServiceComb.

the class ScheduleFilter method runInExecutor.

protected CompletableFuture<Response> runInExecutor(Invocation invocation, FilterNode next) {
    invocation.onExecuteStart();
    try {
        InvocationStageTrace trace = invocation.getInvocationStageTrace();
        trace.startServerFiltersRequest();
        invocation.onStartHandlersRequest();
        checkInQueueTimeout(invocation);
        return next.onFilter(invocation).whenComplete((response, throwable) -> whenComplete(invocation));
    } finally {
        invocation.onExecuteFinish();
    }
}
Also used : InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace)

Example 3 with InvocationStageTrace

use of org.apache.servicecomb.core.invocation.InvocationStageTrace in project java-chassis by ServiceComb.

the class SlowInvocationLogger method logSlowProducer.

private void logSlowProducer(Invocation invocation, Response response, OperationConfig operationConfig) {
    RestOperationMeta restOperationMeta = invocation.getOperationMeta().getExtData(RestConst.SWAGGER_REST_OPERATION);
    InvocationStageTrace stageTrace = invocation.getInvocationStageTrace();
    invocation.getTraceIdLogger().warn(LOGGER, "" + "slow({} ms) invocation, {}:\n" + "  http method: {}\n" + "  url        : {}\n" + "  client     : {}\n" + "  status code: {}\n" + "  total      : {} ms\n" + "    prepare                : {} ms\n" + "    threadPoolQueue        : {} ms\n" + "    server filters request : {} ms\n" + "    handlers request       : {} ms\n" + "    business execute       : {} ms\n" + "    handlers response      : {} ms\n" + "    server filters response: {} ms\n" + "    send response          : {} ms", operationConfig.getMsSlowInvocation(), invocation.getInvocationQualifiedName(), restOperationMeta.getHttpMethod(), restOperationMeta.getAbsolutePath(), collectClientAddress(invocation), response.getStatusCode(), formatTime(stageTrace.calcTotalTime()), formatTime(stageTrace.calcInvocationPrepareTime()), formatTime(stageTrace.calcThreadPoolQueueTime()), formatTime(stageTrace.calcServerFiltersRequestTime()), formatTime(stageTrace.calcHandlersRequestTime()), formatTime(stageTrace.calcBusinessTime()), formatTime(stageTrace.calcHandlersResponseTime()), formatTime(stageTrace.calcServerFiltersResponseTime()), formatTime(stageTrace.calcSendResponseTime()));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace)

Example 4 with InvocationStageTrace

use of org.apache.servicecomb.core.invocation.InvocationStageTrace in project java-chassis by ServiceComb.

the class SlowInvocationLogger method logSlowEdge.

private void logSlowEdge(Invocation invocation, Response response, OperationConfig operationConfig) {
    RestOperationMeta restOperationMeta = invocation.getOperationMeta().getExtData(RestConst.SWAGGER_REST_OPERATION);
    InvocationStageTrace stageTrace = invocation.getInvocationStageTrace();
    invocation.getTraceIdLogger().warn(LOGGER, "" + "slow({} ms) invocation, {}:\n" + "  http method: {}\n" + "  url        : {}\n" + "  server     : {}\n" + "  status code: {}\n" + "  total      : {} ms\n" + "    prepare                : {} ms\n" + "    threadPoolQueue        : {} ms\n" + "    server filters request : {} ms\n" + "    handlers request       : {} ms\n" + "    client filters request : {} ms\n" + "    send request           : {} ms\n" + "    get connection         : {} ms\n" + "    write to buf           : {} ms\n" + "    wait response          : {} ms\n" + "    wake consumer          : {} ms\n" + "    client filters response: {} ms\n" + "    handlers response      : {} ms\n" + "    server filters response: {} ms\n" + "    send response          : {} ms", operationConfig.getMsSlowInvocation(), invocation.getInvocationQualifiedName(), restOperationMeta.getHttpMethod(), restOperationMeta.getAbsolutePath(), collectTargetAddress(invocation), response.getStatusCode(), formatTime(stageTrace.calcTotalTime()), formatTime(stageTrace.calcInvocationPrepareTime()), formatTime(stageTrace.calcThreadPoolQueueTime()), formatTime(stageTrace.calcServerFiltersRequestTime()), formatTime(stageTrace.calcHandlersRequestTime()), formatTime(stageTrace.calcClientFiltersRequestTime()), formatTime(stageTrace.calcSendRequestTime()), formatTime(stageTrace.calcGetConnectionTime()), formatTime(stageTrace.calcWriteToBufferTime()), formatTime(stageTrace.calcReceiveResponseTime()), formatTime(stageTrace.calcWakeConsumer()), formatTime(stageTrace.calcClientFiltersResponseTime()), formatTime(stageTrace.calcHandlersResponseTime()), formatTime(stageTrace.calcServerFiltersResponseTime()), formatTime(stageTrace.calcSendResponseTime()));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace)

Example 5 with InvocationStageTrace

use of org.apache.servicecomb.core.invocation.InvocationStageTrace in project java-chassis by ServiceComb.

the class SlowInvocationLogger method logSlowConsumer.

private void logSlowConsumer(Invocation invocation, Response response, OperationConfig operationConfig) {
    RestOperationMeta restOperationMeta = invocation.getOperationMeta().getExtData(RestConst.SWAGGER_REST_OPERATION);
    InvocationStageTrace stageTrace = invocation.getInvocationStageTrace();
    invocation.getTraceIdLogger().warn(LOGGER, "" + "slow({} ms) invocation, {}:\n" + "  http method: {}\n" + "  url        : {}\n" + "  server     : {}\n" + "  status code: {}\n" + "  total      : {} ms\n" + "    prepare                : {} ms\n" + "    handlers request       : {} ms\n" + "    client filters request : {} ms\n" + "    send request           : {} ms\n" + "    get connection         : {} ms\n" + "    write to buf           : {} ms\n" + "    wait response          : {} ms\n" + "    wake consumer          : {} ms\n" + "    client filters response: {} ms\n" + "    handlers response      : {} ms", operationConfig.getMsSlowInvocation(), invocation.getInvocationQualifiedName(), restOperationMeta.getHttpMethod(), restOperationMeta.getAbsolutePath(), collectTargetAddress(invocation), response.getStatusCode(), formatTime(stageTrace.calcTotalTime()), formatTime(stageTrace.calcInvocationPrepareTime()), formatTime(stageTrace.calcHandlersRequestTime()), formatTime(stageTrace.calcClientFiltersRequestTime()), formatTime(stageTrace.calcSendRequestTime()), formatTime(stageTrace.calcGetConnectionTime()), formatTime(stageTrace.calcWriteToBufferTime()), formatTime(stageTrace.calcReceiveResponseTime()), formatTime(stageTrace.calcWakeConsumer()), formatTime(stageTrace.calcClientFiltersResponseTime()), formatTime(stageTrace.calcHandlersResponseTime()));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace)

Aggregations

InvocationStageTrace (org.apache.servicecomb.core.invocation.InvocationStageTrace)15 Invocation (org.apache.servicecomb.core.Invocation)4 InvocationFinishEvent (org.apache.servicecomb.core.event.InvocationFinishEvent)4 RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)3 ServerAccessLogEvent (org.apache.servicecomb.core.event.ServerAccessLogEvent)3 Before (org.junit.Before)3 Test (org.junit.Test)2 SimpleDateFormat (java.text.SimpleDateFormat)1 TimeoutException (java.util.concurrent.TimeoutException)1 Expectations (mockit.Expectations)1 MockUp (mockit.MockUp)1 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)1 CommonExceptionData (org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData)1 InvocationException (org.apache.servicecomb.swagger.invocation.exception.InvocationException)1