Search in sources :

Example 11 with InvocationStageTrace

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

the class DurationSecondItemTest 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(1000_000L);
    accessLogEvent = new ServerAccessLogEvent();
    accessLogEvent.setMilliStartTime(1L);
    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 12 with InvocationStageTrace

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

the class TestInvocationFinishEvent method construct.

@Test
public void construct(@Mocked Invocation invocation, @Mocked Response response) {
    InvocationStageTrace stageTrace = new InvocationStageTrace(invocation);
    long time = 123;
    new MockUp<System>() {

        @Mock
        long nanoTime() {
            return time;
        }
    };
    new Expectations() {

        {
            invocation.getInvocationStageTrace();
            result = stageTrace;
        }
    };
    stageTrace.finish();
    event = new InvocationFinishEvent(invocation, response);
    Assert.assertEquals(time, event.getNanoCurrent());
    Assert.assertSame(invocation, event.getInvocation());
    Assert.assertSame(response, event.getResponse());
}
Also used : Expectations(mockit.Expectations) MockUp(mockit.MockUp) InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace) Test(org.junit.Test)

Example 13 with InvocationStageTrace

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

the class ProducerInvocationMeter method onInvocationFinish.

@Override
public void onInvocationFinish(InvocationFinishEvent event) {
    super.onInvocationFinish(event);
    InvocationStageTrace invocationStageTrace = event.getInvocation().getInvocationStageTrace();
    executorQueueTimer.record((long) invocationStageTrace.calcThreadPoolQueueTime());
    executionTimer.record((long) invocationStageTrace.calcBusinessTime());
    serverFiltersRequestTimer.record((long) invocationStageTrace.calcServerFiltersRequestTime());
    serverFiltersResponseTimer.record((long) invocationStageTrace.calcServerFiltersResponseTime());
    sendResponseTimer.record((long) invocationStageTrace.calcSendResponseTime());
}
Also used : InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace)

Example 14 with InvocationStageTrace

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

the class AbstractInvocationMeter method onInvocationFinish.

public void onInvocationFinish(InvocationFinishEvent event) {
    lastUpdated = registry.clock().wallTime();
    InvocationStageTrace stageTrace = event.getInvocation().getInvocationStageTrace();
    latencyDistributionMeter.record((long) stageTrace.calcTotalTime());
    totalTimer.record((long) stageTrace.calcTotalTime());
    handlersRequestTimer.record((long) stageTrace.calcHandlersRequestTime());
    handlersResponseTimer.record((long) stageTrace.calcHandlersResponseTime());
    prepareTimer.record((long) stageTrace.calcInvocationPrepareTime());
}
Also used : InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace)

Example 15 with InvocationStageTrace

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

the class ConsumerInvocationMeter method onInvocationFinish.

@Override
public void onInvocationFinish(InvocationFinishEvent event) {
    super.onInvocationFinish(event);
    InvocationStageTrace invocationStageTrace = event.getInvocation().getInvocationStageTrace();
    clientFiltersRequestTimer.record((long) invocationStageTrace.calcClientFiltersRequestTime());
    consumerSendRequestTimer.record((long) invocationStageTrace.calcSendRequestTime());
    consumerGetConnectionTimer.record((long) invocationStageTrace.calcGetConnectionTime());
    consumerWriteToBufTimer.record((long) invocationStageTrace.calcWriteToBufferTime());
    consumerWaitResponseTimer.record((long) invocationStageTrace.calcReceiveResponseTime());
    consumerWakeConsumerTimer.record((long) invocationStageTrace.calcWakeConsumer());
    clientFiltersResponseTimer.record((long) invocationStageTrace.calcClientFiltersResponseTime());
}
Also used : 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