Search in sources :

Example 1 with HttpMethod

use of akka.http.javadsl.model.HttpMethod 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

HttpMethod (akka.http.javadsl.model.HttpMethod)1 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1