use of com.navercorp.pinpoint.profiler.context.Annotation in project pinpoint by naver.
the class GrpcSpanMessageConverter method buildPSpanEvent.
@VisibleForTesting
public PSpanEvent.Builder buildPSpanEvent(SpanEvent spanEvent) {
final PSpanEvent.Builder pSpanEvent = getSpanEventBuilder();
// tSpanEvent.setStartElapsed(spanEvent.getStartElapsed());
if (spanEvent.getElapsedTime() != 0) {
pSpanEvent.setEndElapsed(spanEvent.getElapsedTime());
}
pSpanEvent.setSequence(spanEvent.getSequence());
// tSpanEvent.setRpc(spanEvent.getRpc());
pSpanEvent.setServiceType(spanEvent.getServiceType());
// tSpanEvent.setAnnotations();
if (spanEvent.getDepth() != -1) {
pSpanEvent.setDepth(spanEvent.getDepth());
}
pSpanEvent.setApiId(spanEvent.getApiId());
final IntStringValue exceptionInfo = spanEvent.getExceptionInfo();
if (exceptionInfo != null) {
PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
pSpanEvent.setExceptionInfo(pIntStringValue);
}
final PNextEvent nextEvent = buildNextEvent(spanEvent);
if (nextEvent != null) {
pSpanEvent.setNextEvent(nextEvent);
}
final AsyncId asyncIdObject = spanEvent.getAsyncIdObject();
if (asyncIdObject != null) {
pSpanEvent.setAsyncEvent(asyncIdObject.getAsyncId());
}
final List<Annotation<?>> annotations = spanEvent.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
final List<PAnnotation> pAnnotations = buildPAnnotation(annotations);
pSpanEvent.addAllAnnotation(pAnnotations);
}
return pSpanEvent;
}
use of com.navercorp.pinpoint.profiler.context.Annotation in project pinpoint by naver.
the class GrpcSpanMessageConverter method buildPSpan.
@VisibleForTesting
PSpan buildPSpan(Span span) {
final PSpan.Builder pSpan = PSpan.newBuilder();
pSpan.setVersion(SpanVersion.TRACE_V2);
pSpan.setApplicationServiceType(applicationServiceType);
final TraceRoot traceRoot = span.getTraceRoot();
final TraceId traceId = traceRoot.getTraceId();
final PTransactionId transactionId = newTransactionId(traceId);
pSpan.setTransactionId(transactionId);
pSpan.setSpanId(traceId.getSpanId());
pSpan.setParentSpanId(traceId.getParentSpanId());
pSpan.setStartTime(span.getStartTime());
pSpan.setElapsed(span.getElapsedTime());
pSpan.setServiceType(span.getServiceType());
PAcceptEvent pAcceptEvent = newAcceptEvent(span);
pSpan.setAcceptEvent(pAcceptEvent);
pSpan.setFlag(traceId.getFlags());
Shared shared = span.getTraceRoot().getShared();
pSpan.setErr(shared.getErrorCode());
pSpan.setApiId(span.getApiId());
final IntStringValue exceptionInfo = span.getExceptionInfo();
if (exceptionInfo != null) {
PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
pSpan.setExceptionInfo(pIntStringValue);
}
pSpan.setLoggingTransactionInfo(shared.getLoggingInfo());
final List<Annotation<?>> annotations = span.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
final List<PAnnotation> tAnnotations = buildPAnnotation(annotations);
pSpan.addAllAnnotation(tAnnotations);
}
this.spanProcessor.preProcess(span, pSpan);
final List<SpanEvent> spanEventList = span.getSpanEventList();
if (CollectionUtils.hasLength(spanEventList)) {
final List<PSpanEvent> pSpanEvents = buildPSpanEventList(spanEventList);
pSpan.addAllSpanEvent(pSpanEvents);
}
this.spanProcessor.postProcess(span, pSpan);
return pSpan.build();
}
use of com.navercorp.pinpoint.profiler.context.Annotation in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method verifySpan.
private void verifySpan(final ResolvedExpectedTrace expected, ActualTrace actual) {
if (!expected.type.equals(actual.getType())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + " InstanceType", expected.type.getSimpleName(), actual.getType().getName());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.serviceType.getCode(), actual.getServiceType())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".serviceType", expected.serviceType.getCode(), actual.getServiceType());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.apiId, actual.getApiId())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".apiId", expected.apiId, actual.getApiId());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.rpc, actual.getRpc())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".rpc", expected.rpc, actual.getRpc());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.endPoint, actual.getEndPoint())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".endPoint", expected.endPoint, actual.getEndPoint());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.remoteAddr, actual.getRemoteAddr())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".remoteAddr", expected.remoteAddr, actual.getRemoteAddr());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.destinationId, actual.getDestinationId())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".destinationId", expected.destinationId, actual.getDestinationId());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(getAsyncId(expected), actual.getAsyncId())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".asyncId", expected.localAsyncId, actual.getAsyncId());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (expected.exception != null) {
final IntStringValue actualExceptionInfo = actual.getExceptionInfo();
if (actualExceptionInfo != null) {
String actualExceptionClassName = this.handler.getTcpDataSender().getString(actualExceptionInfo.getIntValue());
String actualExceptionMessage = actualExceptionInfo.getStringValue();
verifyException(expected.exception, actualExceptionClassName, actualExceptionMessage);
} else {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".exception", expected.exception.getClass().getName(), null);
builder.throwAssertionError();
}
}
List<Annotation<?>> actualAnnotations = actual.getAnnotations();
final int expectedLen = ArrayUtils.getLength(expected.annotations);
final int actualLen = CollectionUtils.nullSafeSize(actualAnnotations);
if (actualLen != expectedLen) {
AssertionErrorBuilder builder = new AssertionErrorBuilder("Annotation.length", expectedLen, actualLen);
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
for (int i = 0; i < expectedLen; i++) {
annotationCompare(i, expected, actual, actualAnnotations.get(i));
}
}
use of com.navercorp.pinpoint.profiler.context.Annotation in project pinpoint by naver.
the class SpanThriftMessageConverter method buildTSpanEvent.
@VisibleForTesting
TSpanEvent buildTSpanEvent(SpanEvent spanEvent) {
final TSpanEvent tSpanEvent = new TSpanEvent();
// tSpanEvent.setStartElapsed(spanEvent.getStartElapsed());
if (spanEvent.getElapsedTime() != 0) {
tSpanEvent.setEndElapsed(spanEvent.getElapsedTime());
}
tSpanEvent.setSequence((short) spanEvent.getSequence());
// tSpanEvent.setRpc(spanEvent.getRpc());
tSpanEvent.setServiceType(spanEvent.getServiceType());
tSpanEvent.setEndPoint(spanEvent.getEndPoint());
// tSpanEvent.setAnnotations();
if (spanEvent.getDepth() != -1) {
tSpanEvent.setDepth(spanEvent.getDepth());
}
if (spanEvent.getNextSpanId() != -1) {
tSpanEvent.setNextSpanId(spanEvent.getNextSpanId());
}
tSpanEvent.setDestinationId(spanEvent.getDestinationId());
tSpanEvent.setApiId(spanEvent.getApiId());
final IntStringValue exceptionInfo = spanEvent.getExceptionInfo();
if (exceptionInfo != null) {
TIntStringValue tIntStringValue = buildTIntStringValue(exceptionInfo);
tSpanEvent.setExceptionInfo(tIntStringValue);
}
final AsyncId asyncIdObject = spanEvent.getAsyncIdObject();
if (asyncIdObject != null) {
tSpanEvent.setNextAsyncId(asyncIdObject.getAsyncId());
}
final List<Annotation<?>> annotations = spanEvent.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
final List<TAnnotation> tAnnotations = buildTAnnotation(annotations);
tSpanEvent.setAnnotations(tAnnotations);
}
return tSpanEvent;
}
use of com.navercorp.pinpoint.profiler.context.Annotation in project pinpoint by naver.
the class SpanThriftMessageConverter method buildTSpan.
@VisibleForTesting
TSpan buildTSpan(Span span) {
final TSpan tSpan = new TSpan();
// tSpan.setVersion(span.getVersion());
tSpan.setApplicationName(applicationName);
tSpan.setAgentId(agentId);
tSpan.setAgentStartTime(agentStartTime);
tSpan.setApplicationServiceType(applicationServiceType);
final TraceRoot traceRoot = span.getTraceRoot();
final TraceId traceId = traceRoot.getTraceId();
final ByteBuffer transactionId = transactionIdEncoder.encodeTransactionId(traceId);
tSpan.setTransactionId(transactionId);
tSpan.setSpanId(traceId.getSpanId());
tSpan.setParentSpanId(traceId.getParentSpanId());
tSpan.setStartTime(span.getStartTime());
tSpan.setElapsed(span.getElapsedTime());
tSpan.setServiceType(span.getServiceType());
tSpan.setRemoteAddr(span.getRemoteAddr());
final Shared shared = traceRoot.getShared();
tSpan.setRpc(shared.getRpcName());
tSpan.setEndPoint(shared.getEndPoint());
tSpan.setFlag(traceId.getFlags());
tSpan.setErr(shared.getErrorCode());
tSpan.setParentApplicationName(span.getParentApplicationName());
tSpan.setParentApplicationType(span.getParentApplicationType());
tSpan.setAcceptorHost(span.getAcceptorHost());
tSpan.setApiId(span.getApiId());
final IntStringValue exceptionInfo = span.getExceptionInfo();
if (exceptionInfo != null) {
TIntStringValue tIntStringValue = buildTIntStringValue(exceptionInfo);
tSpan.setExceptionInfo(tIntStringValue);
}
tSpan.setLoggingTransactionInfo(shared.getLoggingInfo());
final List<Annotation<?>> annotations = span.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
final List<TAnnotation> tAnnotations = buildTAnnotation(annotations);
tSpan.setAnnotations(tAnnotations);
}
spanPostProcessor.preProcess(span, tSpan);
final List<SpanEvent> spanEventList = span.getSpanEventList();
if (CollectionUtils.hasLength(spanEventList)) {
final List<TSpanEvent> tSpanEvents = buildTSpanEventList(spanEventList);
tSpan.setSpanEventList(tSpanEvents);
}
spanPostProcessor.postProcess(span, tSpan);
return tSpan;
}
Aggregations