Search in sources :

Example 11 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class SpanSimpleAroundInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    final Trace trace = traceContext.currentRawTraceObject();
    if (trace == null) {
        return;
    }
    // TODO STATDISABLE this logic was added to disable statistics tracing
    if (!trace.canSampled()) {
        traceContext.removeTraceObject();
        return;
    }
    // ------------------------------------------------------
    try {
        final SpanRecorder recorder = trace.getSpanRecorder();
        doInAfterTrace(recorder, target, args, result, throwable);
    } catch (Throwable th) {
        if (logger.isWarnEnabled()) {
            logger.warn("AFTER. Caused:{}", th.getMessage(), th);
        }
    } finally {
        traceContext.removeTraceObject();
        deleteTrace(trace, target, args, result, throwable);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder)

Example 12 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class ServletRequestListener method createTrace.

private Trace createTrace(REQ request) {
    final String requestURI = requestAdaptor.getRpcName(request);
    if (this.excludeUrlFilter.filter(requestURI)) {
        if (isTrace) {
            logger.trace("Filter requestURI={}", requestURI);
        }
        return null;
    }
    final Trace trace = this.requestTraceReader.read(request);
    if (trace.canSampled()) {
        final SpanRecorder recorder = trace.getSpanRecorder();
        // record root span
        recorder.recordServiceType(this.serviceType);
        recorder.recordApi(SERVLET_SYNC_METHOD_DESCRIPTOR);
        this.serverRequestRecorder.record(recorder, request);
        // record proxy HTTP header.
        this.proxyRequestRecorder.record(recorder, request);
    }
    return trace;
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder)

Example 13 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class ServerConnectionHandleRequestInterceptor method createTrace.

private Trace createTrace(final HttpServerRequest request) {
    final String requestURI = request.path();
    if (requestURI != null && excludeUrlFilter.filter(requestURI)) {
        // skip request.
        if (isTrace) {
            logger.trace("filter requestURI:{}", requestURI);
        }
        return null;
    }
    final Trace trace = this.requestTraceReader.read(request);
    if (trace.canSampled()) {
        final SpanRecorder recorder = trace.getSpanRecorder();
        // root
        recorder.recordServiceType(VertxConstants.VERTX_HTTP_SERVER);
        recorder.recordApi(VERTX_HTTP_SERVER_METHOD_DESCRIPTOR);
        this.serverRequestRecorder.record(recorder, request);
        // record proxy HTTP header.
        this.proxyRequestRecorder.record(recorder, request);
    }
    if (!initScope(trace)) {
        // invalid scope.
        deleteTrace(trace);
        return null;
    }
    return trace;
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder)

Example 14 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class DefaultTraceTest method newTrace.

private Trace newTrace(final int maxCallStackDepth) {
    when(traceRoot.getShared()).thenReturn(shared);
    TraceId traceId = new DefaultTraceId(agentId, agentStartTime, 0);
    when(traceRoot.getTraceId()).thenReturn(traceId);
    CallStackFactory<SpanEvent> callStackFactory = new CallStackFactoryV1(maxCallStackDepth, -1);
    CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
    SpanFactory spanFactory = new DefaultSpanFactory();
    Storage storage = mock(Storage.class);
    final Span span = spanFactory.newSpan(traceRoot);
    final boolean root = span.getTraceRoot().getTraceId().isRoot();
    final SpanRecorder spanRecorder = new DefaultSpanRecorder(span, root, true, stringMetaDataService, sqlMetaDataService, errorHandler);
    final WrappedSpanEventRecorder wrappedSpanEventRecorder = new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler);
    return new DefaultTrace(span, callStack, storage, true, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)

Example 15 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class DisableTraceTest method testSpanRecorder.

@Test
public void testSpanRecorder() {
    Trace trace = newTrace();
    Trace childTrace = newChildTrace();
    SpanRecorder spanRecorder = trace.getSpanRecorder();
    SpanRecorder childSpanRecorder = childTrace.getSpanRecorder();
    Assert.assertNull(spanRecorder);
    Assert.assertNull(childSpanRecorder);
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Test(org.junit.Test)

Aggregations

SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)38 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)23 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)10 Test (org.junit.Test)10 WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)8 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)8 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)6 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)4 TraceSampler (com.navercorp.pinpoint.bootstrap.sampler.TraceSampler)4 ActiveTraceHandle (com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle)4 DefaultSpanRecorder (com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)4 Span (com.navercorp.pinpoint.profiler.context.Span)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 AsyncState (com.navercorp.pinpoint.bootstrap.context.AsyncState)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)2 ListenableAsyncState (com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState)2 AMQP (com.rabbitmq.client.AMQP)2 AMQConnection (com.rabbitmq.client.impl.AMQConnection)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2