Search in sources :

Example 1 with TraceScope

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

the class SpanAsyncEventSimpleAroundInterceptor method createAsyncTrace.

private Trace createAsyncTrace(AsyncTraceId asyncTraceId) {
    final Trace trace = traceContext.continueAsyncTraceObject(asyncTraceId, asyncTraceId.getAsyncId(), asyncTraceId.getSpanStartTime());
    if (trace == null) {
        if (logger.isWarnEnabled()) {
            logger.warn("Failed to continue async trace. 'result is null'");
        }
        return null;
    }
    if (isDebug) {
        logger.debug("Continue async trace {}, id={}", trace, asyncTraceId);
    }
    // add async scope.
    TraceScope oldScope = trace.addScope(ASYNC_TRACE_SCOPE);
    if (oldScope != null) {
        if (logger.isWarnEnabled()) {
            logger.warn("Duplicated async trace scope={}.", oldScope.getName());
        }
        // delete corrupted trace.
        deleteAsyncTrace(trace);
        return null;
    }
    // first block.
    final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
    recorder.recordServiceType(ServiceType.ASYNC);
    recorder.recordApi(asyncMethodDescriptor);
    return trace;
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) TraceScope(com.navercorp.pinpoint.bootstrap.context.scope.TraceScope)

Example 2 with TraceScope

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

the class UserIncludeMethodInterceptor method createUserIncludeTrace.

private Trace createUserIncludeTrace() {
    final Trace trace = traceContext.newTraceObject();
    if (isDebug) {
        logger.debug("New user include trace {} and sampled {}", trace, trace.canSampled());
    }
    // add user scope.
    TraceScope oldScope = trace.addScope(SCOPE_NAME);
    if (oldScope != null) {
        // delete corrupted trace.
        if (logger.isInfoEnabled()) {
            logger.info("Duplicated user include trace scope={}.", oldScope.getName());
        }
        deleteUserIncludeTrace(trace);
        return null;
    }
    if (trace.canSampled()) {
        // record root span.
        final SpanRecorder recorder = trace.getSpanRecorder();
        recorder.recordServiceType(ServiceType.STAND_ALONE);
        recorder.recordApi(USER_INCLUDE_METHOD_DESCRIPTOR);
    }
    return trace;
}
Also used : TraceScope(com.navercorp.pinpoint.bootstrap.context.scope.TraceScope)

Aggregations

TraceScope (com.navercorp.pinpoint.bootstrap.context.scope.TraceScope)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1