Example usage for java.lang Short toString

List of usage examples for java.lang Short toString

Introduction

In this page you can find the example usage for java.lang Short toString.

Prototype

public static String toString(short s) 

Source Link

Document

Returns a new String object representing the specified short .

Usage

From source file:com.navercorp.pinpoint.plugin.httpclient4.interceptor.DefaultClientExchangeHandlerImplStartMethodInterceptor.java

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, "", methodDescriptor.getMethodName(), "", args);
    }/*from   w ww  .j  a  v a  2s.  c  om*/

    final Trace trace = traceContext.currentRawTraceObject();
    if (trace == null) {
        return;
    }

    final HttpRequest httpRequest = getHttpRequest(target);
    final boolean sampling = trace.canSampled();
    if (!sampling) {
        if (isDebug) {
            logger.debug("set Sampling flag=false");
        }
        if (httpRequest != null) {
            httpRequest.setHeader(Header.HTTP_SAMPLED.toString(), SamplingFlagUtils.SAMPLING_RATE_FALSE);
        }
        return;
    }

    SpanEventRecorder recorder = trace.traceBlockBegin();

    // set remote trace
    final TraceId nextId = trace.getTraceId().getNextTraceId();
    recorder.recordNextSpanId(nextId.getSpanId());
    recorder.recordServiceType(HttpClient4Constants.HTTP_CLIENT_4);

    if (httpRequest != null) {
        httpRequest.setHeader(Header.HTTP_TRACE_ID.toString(), nextId.getTransactionId());
        httpRequest.setHeader(Header.HTTP_SPAN_ID.toString(), String.valueOf(nextId.getSpanId()));

        httpRequest.setHeader(Header.HTTP_PARENT_SPAN_ID.toString(), String.valueOf(nextId.getParentSpanId()));

        httpRequest.setHeader(Header.HTTP_FLAGS.toString(), String.valueOf(nextId.getFlags()));
        httpRequest.setHeader(Header.HTTP_PARENT_APPLICATION_NAME.toString(),
                traceContext.getApplicationName());
        httpRequest.setHeader(Header.HTTP_PARENT_APPLICATION_TYPE.toString(),
                Short.toString(traceContext.getServerTypeCode()));
        final NameIntValuePair<String> host = getHost(target);
        if (host != null) {
            final String endpoint = getEndpoint(host.getName(), host.getValue());
            logger.debug("Get host {}", endpoint);
            httpRequest.setHeader(Header.HTTP_HOST.toString(), endpoint);
        }
    }

    try {
        if (isAsynchronousInvocation(target, args)) {
            // set asynchronous trace
            final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
            recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
            // check type isAsynchronousInvocation()
            ((AsyncTraceIdAccessor) ((ResultFutureGetter) target)._$PINPOINT$_getResultFuture())
                    ._$PINPOINT$_setAsyncTraceId(asyncTraceId);
            if (isDebug) {
                logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
            }
        }
    } catch (Throwable t) {
        logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
    }
}

From source file:com.navercorp.pinpoint.plugin.httpclient3.interceptor.ExecuteInterceptor.java

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }/* ww w.  j av  a2 s. co  m*/

    final Trace trace = traceContext.currentRawTraceObject();
    if (trace == null) {
        return;
    }

    final HttpMethod httpMethod = getHttpMethod(args);
    final boolean sampling = trace.canSampled();
    if (!sampling) {
        if (isDebug) {
            logger.debug("set Sampling flag=false");
        }
        if (httpMethod != null) {
            httpMethod.setRequestHeader(Header.HTTP_SAMPLED.toString(), SamplingFlagUtils.SAMPLING_RATE_FALSE);
        }

        return;
    }

    trace.traceBlockBegin();
    trace.markBeforeTime();

    TraceId nextId = trace.getTraceId().getNextTraceId();
    trace.recordNextSpanId(nextId.getSpanId());
    trace.recordServiceType(ServiceType.HTTP_CLIENT);

    if (httpMethod != null) {
        httpMethod.setRequestHeader(Header.HTTP_TRACE_ID.toString(), nextId.getTransactionId());
        httpMethod.setRequestHeader(Header.HTTP_SPAN_ID.toString(), String.valueOf(nextId.getSpanId()));
        httpMethod.setRequestHeader(Header.HTTP_PARENT_SPAN_ID.toString(),
                String.valueOf(nextId.getParentSpanId()));
        httpMethod.setRequestHeader(Header.HTTP_FLAGS.toString(), String.valueOf(nextId.getFlags()));
        httpMethod.setRequestHeader(Header.HTTP_PARENT_APPLICATION_NAME.toString(),
                traceContext.getApplicationName());
        httpMethod.setRequestHeader(Header.HTTP_PARENT_APPLICATION_TYPE.toString(),
                Short.toString(traceContext.getServerTypeCode()));
        final String host = getHost(httpMethod);
        if (host != null) {
            httpMethod.setRequestHeader(Header.HTTP_HOST.toString(), host);
        }
    }
}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFsw.CFFswAuditActionPKey.java

public String toString() {
    String ret = "<CFFswAuditActionPKey" + " RequiredAuditActionId=" + "\""
            + Short.toString(getRequiredAuditActionId()) + "\"" + "/>";
    return (ret);
}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFsw.CFFswURLProtocolPKey.java

public String toString() {
    String ret = "<CFFswURLProtocolPKey" + " RequiredURLProtocolId=" + "\""
            + Short.toString(getRequiredURLProtocolId()) + "\"" + "/>";
    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAst.CFAstAuditActionPKey.java

public String toString() {
    String ret = "<CFAstAuditActionPKey" + " RequiredAuditActionId=" + "\""
            + Short.toString(getRequiredAuditActionId()) + "\"" + "/>";
    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAst.CFAstISOTimezonePKey.java

public String toString() {
    String ret = "<CFAstISOTimezonePKey" + " RequiredISOTimezoneId=" + "\""
            + Short.toString(getRequiredISOTimezoneId()) + "\"" + "/>";
    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAst.CFAstURLProtocolPKey.java

public String toString() {
    String ret = "<CFAstURLProtocolPKey" + " RequiredURLProtocolId=" + "\""
            + Short.toString(getRequiredURLProtocolId()) + "\"" + "/>";
    return (ret);
}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_0.CFFsw.CFFswISOTimezonePKey.java

public String toString() {
    String ret = "<CFFswISOTimezonePKey" + " RequiredISOTimezoneId=" + "\""
            + Short.toString(getRequiredISOTimezoneId()) + "\"" + "/>";
    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.CFAccAuditActionPKey.java

public String toString() {
    String ret = "<CFAccAuditActionPKey" + " RequiredAuditActionId=" + "\""
            + Short.toString(getRequiredAuditActionId()) + "\"" + "/>";
    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.CFAccISOTimezonePKey.java

public String toString() {
    String ret = "<CFAccISOTimezonePKey" + " RequiredISOTimezoneId=" + "\""
            + Short.toString(getRequiredISOTimezoneId()) + "\"" + "/>";
    return (ret);
}