Search in sources :

Example 6 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyTrace.

@Override
public void verifyTrace(ExpectedTrace... expectations) {
    if (ArrayUtils.isEmpty(expectations)) {
        throw new IllegalArgumentException("No expectations");
    }
    for (ExpectedTrace expected : expectations) {
        ResolvedExpectedTrace resolved = resolveExpectedTrace(expected, null);
        final Item<SpanType> actualItem = popItem();
        if (actualItem == null) {
            AssertionErrorBuilder builder = new AssertionErrorBuilder("actualItem is null", resolved, "null");
            builder.throwAssertionError();
        }
        final SpanType actual = actualItem.getValue();
        ActualTrace wrapped = ActualTraceFactory.wrap(actual);
        verifySpan(resolved, wrapped);
        verifyAsyncTraces(expected, wrapped);
    }
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) ActualTrace(com.navercorp.pinpoint.test.wrapper.ActualTrace)

Example 7 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyIsLoggingTransactionInfo.

@Override
public void verifyIsLoggingTransactionInfo(LoggingInfo loggingInfo) {
    final Item<SpanType> item = popItem();
    if (item == null) {
        throw new AssertionError("Expected a Span isLoggingTransactionInfo value with [" + loggingInfo.getName() + "]" + " but loggingTransactionInfo value invalid.");
    }
    final TraceRoot traceRoot = item.getTraceRoot();
    final byte loggingTransactionInfo = traceRoot.getShared().getLoggingInfo();
    if (loggingTransactionInfo != loggingInfo.getCode()) {
        LoggingInfo code = LoggingInfo.searchByCode(loggingTransactionInfo);
        String codeName = getCodeName(code);
        AssertionErrorBuilder builder = new AssertionErrorBuilder("Span.isLoggingTransactionInfo value", loggingInfo.getName(), codeName);
        builder.setComparison(loggingInfo.getName(), codeName);
        builder.throwAssertionError();
    }
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) LoggingInfo(com.navercorp.pinpoint.common.trace.LoggingInfo)

Example 8 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyDiscreteTraceBlock.

public void verifyDiscreteTraceBlock(ExpectedTrace[] expectations, Integer asyncId) {
    if (ArrayUtils.isEmpty(expectations)) {
        throw new IllegalArgumentException("No expectations");
    }
    ExpectedTrace expected = expectations[0];
    ResolvedExpectedTrace resolved = resolveExpectedTrace(expected, asyncId);
    int i = 0;
    Iterator<SpanType> iterator = this.handler.getOrderedSpanRecorder().iterator();
    while (iterator.hasNext()) {
        final SpanType next = iterator.next();
        ActualTrace actual = ActualTraceFactory.wrap(next);
        try {
            verifySpan(resolved, actual);
        } catch (AssertionError e) {
            continue;
        }
        iterator.remove();
        verifyAsyncTraces(expected, actual);
        if (++i == expectations.length) {
            return;
        }
        expected = expectations[i];
        resolved = resolveExpectedTrace(expected, asyncId);
    }
    throw new AssertionError("Failed to match " + i + "th expectation: " + resolved);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) ActualTrace(com.navercorp.pinpoint.test.wrapper.ActualTrace)

Example 9 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class BasePinpointTest method setup.

public void setup(TestContext testContext) {
    DefaultApplicationContext mockApplicationContext = testContext.getDefaultApplicationContext();
    DataSender<SpanType> spanDataSender = mockApplicationContext.getSpanDataSender();
    if (spanDataSender instanceof ListenableDataSender) {
        ListenableDataSender<SpanType> listenableDataSender = (ListenableDataSender<SpanType>) spanDataSender;
        final TBaseRecorder<SpanType> tBaseRecord = new TBaseRecorder<>();
        listenableDataSender.setListener(new ListenableDataSender.Listener<SpanType>() {

            @Override
            public boolean handleSend(SpanType data) {
                return tBaseRecord.add(data);
            }
        });
        setTBaseRecorder(tBaseRecord);
    }
    ServerMetaDataRegistryService serverMetaDataRegistryService = mockApplicationContext.getServerMetaDataRegistryService();
    this.setServerMetaDataRegistryService(serverMetaDataRegistryService);
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) TBaseRecorder(com.navercorp.pinpoint.test.TBaseRecorder) ServerMetaDataRegistryService(com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService) ListenableDataSender(com.navercorp.pinpoint.test.ListenableDataSender)

Example 10 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class BasePinpointTest method getCurrentSpanEvents.

protected List<SpanEvent> getCurrentSpanEvents() {
    List<SpanEvent> spanEvents = new ArrayList<>();
    for (SpanType value : this.tBaseRecorder) {
        if (value instanceof SpanChunk) {
            final SpanChunk spanChunk = (SpanChunk) value;
            for (SpanEvent tSpanEvent : spanChunk.getSpanEventList()) {
                SpanEvent spanEvent = tSpanEvent;
                spanEvents.add(spanEvent);
            }
        }
    }
    return spanEvents;
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) ArrayList(java.util.ArrayList)

Aggregations

SpanType (com.navercorp.pinpoint.profiler.context.SpanType)15 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)5 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)5 Span (com.navercorp.pinpoint.profiler.context.Span)4 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)3 DefaultAsyncSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk)3 DefaultLocalAsyncId (com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId)3 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)3 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)3 ActualTrace (com.navercorp.pinpoint.test.wrapper.ActualTrace)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 Test (org.junit.Test)3 TypeLiteral (com.google.inject.TypeLiteral)2 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)2 ServerMetaDataRegistryService (com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService)2 MetaDataType (com.navercorp.pinpoint.profiler.metadata.MetaDataType)2