Example usage for com.squareup.okhttp Connection getRoute

List of usage examples for com.squareup.okhttp Connection getRoute

Introduction

In this page you can find the example usage for com.squareup.okhttp Connection getRoute.

Prototype

Route getRoute();

Source Link

Document

Returns the route used by this connection.

Usage

From source file:com.baidu.oped.apm.plugin.okhttp.interceptor.HttpEngineConnectMethodInterceptor.java

License:Apache License

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result,
        Throwable throwable) {//from w ww.  ja  va2 s  . co  m
    if (target instanceof ConnectionGetter) {
        Connection connection = ((ConnectionGetter) target)._$APM$_getConnection();
        if (connection != null) {
            final StringBuilder sb = new StringBuilder();
            sb.append(connection.getRoute().getAddress().getUriHost()).append(":");
            sb.append(connection.getRoute().getAddress().getUriPort());
            recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, sb.toString());
        }
    }
    recorder.recordApi(methodDescriptor);
    recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT_INTERNAL);
    recorder.recordException(throwable);
}

From source file:com.navercorp.pinpoint.plugin.okhttp.interceptor.HttpEngineConnectMethodInterceptor.java

License:Apache License

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result,
        Throwable throwable) {/*from   ww w  .  j  a v  a2 s . com*/
    if (target instanceof ConnectionGetter) {
        Connection connection = ((ConnectionGetter) target)._$PINPOINT$_getConnection();
        if (connection != null) {
            final StringBuilder sb = new StringBuilder();
            sb.append(connection.getRoute().getAddress().getUriHost()).append(":");
            sb.append(connection.getRoute().getAddress().getUriPort());
            recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, sb.toString());
        }
    }
    recorder.recordApi(methodDescriptor);
    recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT_INTERNAL);
    recorder.recordException(throwable);
}

From source file:com.navercorp.pinpoint.plugin.okhttp.v2.interceptor.HttpEngineConnectMethodInterceptor.java

License:Apache License

private String getHostAndPort(Connection connection) {
    final Address address = connection.getRoute().getAddress();
    return HostAndPort.toHostAndPortString(address.getUriHost(), address.getUriPort());
}