Search in sources :

Example 31 with SpanRecorder

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

the class DefaultBaseTraceFactory method continueTraceObject.

// continue to trace the request that has been determined to be sampled on previous nodes
@Override
public Trace continueTraceObject(final TraceId traceId) {
    // TODO need to modify how to bind a datasender
    // always set true because the decision of sampling has been  made on previous nodes
    // TODO need to consider as a target to sample in case Trace object has a sampling flag (true) marked on previous node.
    // Check max throughput(permits per seconds)
    final TraceSampler.State state = traceSampler.isContinueSampled();
    if (state.isSampled()) {
        final TraceRoot traceRoot = traceRootFactory.continueTraceRoot(traceId, state.nextId());
        final Span span = spanFactory.newSpan(traceRoot);
        final SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory(traceRoot);
        final Storage storage = storageFactory.createStorage(spanChunkFactory);
        final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
        final boolean samplingEnable = true;
        final SpanRecorder spanRecorder = recorderFactory.newSpanRecorder(span, traceId.isRoot(), samplingEnable);
        final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot);
        final ActiveTraceHandle handle = registerActiveTrace(traceRoot);
        final DefaultTrace trace = new DefaultTrace(span, callStack, storage, samplingEnable, spanRecorder, wrappedSpanEventRecorder, handle);
        return trace;
    } else {
        return newDisableTrace(state.nextId());
    }
}
Also used : TraceSampler(com.navercorp.pinpoint.bootstrap.sampler.TraceSampler) ActiveTraceHandle(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Example 32 with SpanRecorder

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

the class DefaultBaseTraceFactory method continueAsyncContextTraceObject.

// internal async trace.
@Override
public Trace continueAsyncContextTraceObject(TraceRoot traceRoot, LocalAsyncId localAsyncId, boolean canSampled) {
    if (canSampled) {
        final SpanChunkFactory spanChunkFactory = new AsyncSpanChunkFactory(traceRoot, localAsyncId);
        final Storage storage = storageFactory.createStorage(spanChunkFactory);
        final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
        final boolean samplingEnable = true;
        final SpanRecorder spanRecorder = recorderFactory.newTraceRootSpanRecorder(traceRoot, samplingEnable);
        final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot);
        final Trace asyncTrace = new AsyncChildTrace(traceRoot, callStack, storage, samplingEnable, spanRecorder, wrappedSpanEventRecorder, localAsyncId);
        return asyncTrace;
    } else {
        return new DisableAsyncChildTrace(traceRoot, localAsyncId);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)

Example 33 with SpanRecorder

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

the class DefaultBaseTraceFactory method newAsyncTraceObject.

// entry point async trace.
@InterfaceAudience.LimitedPrivate("vert.x")
@Override
public Trace newAsyncTraceObject() {
    final TraceSampler.State state = traceSampler.isNewSampled();
    final boolean sampling = state.isSampled();
    if (sampling) {
        final TraceRoot traceRoot = traceRootFactory.newTraceRoot(state.nextId());
        final Span span = spanFactory.newSpan(traceRoot);
        final SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory(traceRoot);
        final Storage storage = storageFactory.createStorage(spanChunkFactory);
        final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
        final ActiveTraceHandle handle = registerActiveTrace(traceRoot);
        final SpanAsyncStateListener asyncStateListener = new SpanAsyncStateListener(span, storageFactory);
        final AsyncState asyncState = new ListenableAsyncState(asyncStateListener, handle);
        final TraceId traceId = traceRoot.getTraceId();
        final SpanRecorder spanRecorder = recorderFactory.newSpanRecorder(span, traceId.isRoot(), sampling);
        final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot, asyncState);
        final DefaultTrace trace = new DefaultTrace(span, callStack, storage, sampling, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
        final AsyncTrace asyncTrace = new AsyncTrace(traceRoot, trace, asyncState);
        return asyncTrace;
    } else {
        return newDisableTrace(state.nextId());
    }
}
Also used : TraceSampler(com.navercorp.pinpoint.bootstrap.sampler.TraceSampler) ActiveTraceHandle(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Example 34 with SpanRecorder

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

the class DefaultBaseTraceFactory method newTraceObject.

@Override
public Trace newTraceObject() {
    // TODO need to modify how to inject a datasender
    final TraceSampler.State state = traceSampler.isNewSampled();
    final boolean sampling = state.isSampled();
    if (sampling) {
        final TraceRoot traceRoot = traceRootFactory.newTraceRoot(state.nextId());
        final Span span = spanFactory.newSpan(traceRoot);
        final SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory(traceRoot);
        final Storage storage = storageFactory.createStorage(spanChunkFactory);
        final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
        final TraceId traceId = traceRoot.getTraceId();
        final SpanRecorder spanRecorder = recorderFactory.newSpanRecorder(span, traceId.isRoot(), sampling);
        final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot);
        final ActiveTraceHandle handle = registerActiveTrace(traceRoot);
        final DefaultTrace trace = new DefaultTrace(span, callStack, storage, sampling, spanRecorder, wrappedSpanEventRecorder, handle);
        return trace;
    } else {
        return newDisableTrace(state.nextId());
    }
}
Also used : TraceSampler(com.navercorp.pinpoint.bootstrap.sampler.TraceSampler) ActiveTraceHandle(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Example 35 with SpanRecorder

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

the class DirectivesInterceptor method createTrace.

private Trace createTrace(final HttpRequest request) {
    if (request == null) {
        return null;
    }
    final String requestUri = String.valueOf(request.getUri());
    if (requestUri != null && excludeUrlFilter.filter(requestUri)) {
        // skip request.
        if (isTrace) {
            logger.trace("filter requestURI:{}", requestUri);
        }
        return null;
    }
    HttpMethod method = request.method();
    if (method != null && excludeHttpMethodFilter.filter(method.value())) {
        // skip request.
        if (isTrace) {
            logger.trace("filter http method:{}", method.value());
        }
        return null;
    }
    final boolean sampling = samplingEnable(request);
    if (!sampling) {
        final Trace trace = traceContext.disableSampling();
        if (isDebug) {
            logger.debug("Remote call sampling flag found. skip trace requestUrl:{}", requestUri);
        }
        return trace;
    }
    final TraceId traceId = populateTraceIdFromRequest(request);
    if (traceId != null) {
        final Trace trace = traceContext.continueAsyncTraceObject(traceId);
        if (trace.canSampled()) {
            final SpanRecorder recorder = trace.getSpanRecorder();
            recordRootSpan(recorder, request);
            if (isDebug) {
                logger.debug("TraceID exist. continue trace. traceId:{}, requestUrl:{}", traceId, requestUri);
            }
        } else {
            if (isDebug) {
                logger.debug("TraceID exist. camSampled is false. skip trace. traceId:{}, requestUrl:{}", traceId, requestUri);
            }
        }
        return trace;
    } else {
        final Trace trace = traceContext.newAsyncTraceObject();
        if (trace.canSampled()) {
            final SpanRecorder recorder = trace.getSpanRecorder();
            recordRootSpan(recorder, request);
        } else {
            if (isDebug) {
                logger.debug("Sampling is disabled");
            }
        }
        return trace;
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) HttpMethod(akka.http.javadsl.model.HttpMethod)

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