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);
}
}
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();
}
}
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);
}
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);
}
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;
}
Aggregations