Search in sources :

Example 11 with TraceRoot

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

the class DefaultTransactionIdEncoderTest method testCompressedTransactionId.

@Test
public void testCompressedTransactionId() {
    TraceRoot traceRoot = getRootTraceId();
    TraceId traceId = traceRoot.getTraceId();
    ByteBuffer encodeTxId = transactionIdEncoder.encodeTransactionId(traceId);
    byte[] transactionId = Arrays.copyOf(encodeTxId.array(), encodeTxId.remaining());
    TransactionId parsedTxId = TransactionIdUtils.parseTransactionId(transactionId, DEFAULT_AGENT_ID);
    logger.debug("transactionId:{}", parsedTxId);
    Assert.assertEquals(DEFAULT_AGENT_ID, parsedTxId.getAgentId());
    Assert.assertEquals(parsedTxId.getAgentStartTime(), agentStartTime);
    Assert.assertEquals(parsedTxId.getTransactionSequence(), transactionId2);
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) ByteBuffer(java.nio.ByteBuffer) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId) Test(org.junit.Test)

Example 12 with TraceRoot

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

the class SpanPostProcessorTest method postProcess1.

@Test
public void postProcess1() {
    SpanProcessor<TSpan, TSpanChunk> spanChunkPostProcessor = new SpanProcessorV1();
    TraceRoot internalTraceId = newInternalTraceId();
    TSpanChunk tSpanChunk = new TSpanChunk();
    try {
        SpanChunk spanChunk = new DefaultSpanChunk(internalTraceId, new ArrayList<SpanEvent>());
        spanChunkPostProcessor.postProcess(spanChunk, tSpanChunk);
        Assert.fail();
    } catch (Exception ignored) {
    }
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) Test(org.junit.Test)

Example 13 with TraceRoot

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

the class SpanEventTest method testMarkStartTime.

@Test
public void testMarkStartTime() {
    final DefaultTraceId traceId = new DefaultTraceId("agentId", 0, 0);
    TraceRoot traceRoot = new DefaultTraceRoot(traceId, "agentId", System.currentTimeMillis(), 0);
    Span span = new Span(traceRoot);
    span.markBeforeTime();
    span.setElapsedTime((int) (span.getStartTime() + 10));
    logger.debug("span:{}", span);
    final SpanEvent spanEvent = new SpanEvent();
    long currentTime = System.currentTimeMillis();
    spanEvent.setStartTime(currentTime);
    spanEvent.setElapsedTime(10);
    logger.debug("spanEvent:{}", spanEvent);
    span.setSpanEventList(Arrays.asList(spanEvent));
    TSpan tSpan = new TSpan();
    TSpanEvent tSpanEvent = new TSpanEvent();
    tSpan.addToSpanEventList(tSpanEvent);
    compressorV1.preProcess(span, tSpan);
    compressorV1.postProcess(span, tSpan);
    Assert.assertEquals("startTime", span.getStartTime() + tSpanEvent.getStartElapsed(), spanEvent.getStartTime());
    Assert.assertEquals("endTime", span.getStartTime() + tSpanEvent.getStartElapsed() + spanEvent.getElapsedTime(), spanEvent.getAfterTime());
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 14 with TraceRoot

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

the class OrderedSpanRecorder method insertSpan.

private void insertSpan(Span span) {
    long startTime = span.getStartTime();
    TraceRoot traceRoot = span.getTraceRoot();
    Item<SpanType> item = new Item<SpanType>(span, startTime, traceRoot, ROOT_SEQUENCE);
    insertItem(item);
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Example 15 with TraceRoot

use of com.navercorp.pinpoint.profiler.context.id.TraceRoot 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)

Aggregations

TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)36 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)17 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)16 Test (org.junit.Test)13 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)12 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)10 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)9 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)7 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)7 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)6 Span (com.navercorp.pinpoint.profiler.context.Span)6 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)6 WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)6 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)6 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)5 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)5 ByteBuffer (java.nio.ByteBuffer)5 TraceSampler (com.navercorp.pinpoint.bootstrap.sampler.TraceSampler)4 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)4 ActiveTraceHandle (com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle)4