Search in sources :

Example 51 with Endpoint

use of org.pjsip.pjsua2.Endpoint in project zipkin by openzipkin.

the class V1JsonSpanReader method readAnnotation.

void readAnnotation(JsonReader reader) throws IOException {
    String nextName;
    reader.beginObject();
    Long timestamp = null;
    String value = null;
    Endpoint endpoint = null;
    while (reader.hasNext()) {
        nextName = reader.nextName();
        if (nextName.equals("timestamp")) {
            timestamp = reader.nextLong();
        } else if (nextName.equals("value")) {
            value = reader.nextString();
        } else if (nextName.equals("endpoint") && !reader.peekNull()) {
            endpoint = ENDPOINT_READER.fromJson(reader);
        } else {
            reader.skipValue();
        }
    }
    if (timestamp == null || value == null) {
        throw new IllegalArgumentException("Incomplete annotation at " + reader.getPath());
    }
    reader.endObject();
    builder.addAnnotation(timestamp, value, endpoint);
}
Also used : Endpoint(zipkin2.Endpoint)

Example 52 with Endpoint

use of org.pjsip.pjsua2.Endpoint in project zipkin by openzipkin.

the class V1SpanWriter method sizeInBytes.

@Override
public int sizeInBytes(V1Span value) {
    // {"traceId":"xxxxxxxxxxxxxxxx"
    int sizeInBytes = 29;
    if (value.traceIdHigh() != 0L)
        sizeInBytes += 16;
    if (value.parentId() != 0L) {
        // ,"parentId":"0123456789abcdef"
        sizeInBytes += 30;
    }
    // ,"id":"0123456789abcdef"
    sizeInBytes += 24;
    // ,"name":""
    sizeInBytes += 10;
    if (value.name() != null) {
        sizeInBytes += jsonEscapedSizeInBytes(value.name());
    }
    if (value.timestamp() != 0L) {
        // ,"timestamp":
        sizeInBytes += 13;
        sizeInBytes += asciiSizeInBytes(value.timestamp());
    }
    if (value.duration() != 0L) {
        // ,"duration":
        sizeInBytes += 12;
        sizeInBytes += asciiSizeInBytes(value.duration());
    }
    int annotationCount = value.annotations().size();
    Endpoint lastEndpoint = null;
    int lastEndpointSize = 0;
    if (annotationCount > 0) {
        // ,"annotations":[]
        sizeInBytes += 17;
        // comma to join elements
        if (annotationCount > 1)
            sizeInBytes += annotationCount - 1;
        for (int i = 0; i < annotationCount; i++) {
            V1Annotation a = value.annotations().get(i);
            Endpoint endpoint = a.endpoint();
            int endpointSize;
            if (endpoint == null) {
                endpointSize = 0;
            } else if (endpoint.equals(lastEndpoint)) {
                endpointSize = lastEndpointSize;
            } else {
                lastEndpoint = endpoint;
                endpointSize = lastEndpointSize = endpointSizeInBytes(endpoint, true);
            }
            sizeInBytes += V2SpanWriter.annotationSizeInBytes(a.timestamp(), a.value(), endpointSize);
        }
    }
    int binaryAnnotationCount = value.binaryAnnotations().size();
    if (binaryAnnotationCount > 0) {
        // ,"binaryAnnotations":[]
        sizeInBytes += 23;
        // commas
        if (binaryAnnotationCount > 1)
            sizeInBytes += binaryAnnotationCount - 1;
        for (int i = 0; i < binaryAnnotationCount; ) {
            V1BinaryAnnotation a = value.binaryAnnotations().get(i++);
            Endpoint endpoint = a.endpoint();
            int endpointSize;
            if (endpoint == null) {
                endpointSize = 0;
            } else if (endpoint.equals(lastEndpoint)) {
                endpointSize = lastEndpointSize;
            } else {
                lastEndpoint = endpoint;
                endpointSize = lastEndpointSize = endpointSizeInBytes(endpoint, true);
            }
            if (a.stringValue() != null) {
                sizeInBytes += binaryAnnotationSizeInBytes(a.key(), a.stringValue(), endpointSize);
            } else {
                // {"key":"NN","value":true,"endpoint":}
                sizeInBytes += 37;
                sizeInBytes += endpointSize;
            }
        }
    }
    // ,"debug":true
    if (Boolean.TRUE.equals(value.debug()))
        sizeInBytes += 13;
    // }
    return ++sizeInBytes;
}
Also used : Endpoint(zipkin2.Endpoint) V1BinaryAnnotation(zipkin2.v1.V1BinaryAnnotation) Endpoint(zipkin2.Endpoint) V1Annotation(zipkin2.v1.V1Annotation)

Example 53 with Endpoint

use of org.pjsip.pjsua2.Endpoint in project zipkin by openzipkin.

the class V2SpanWriter method endpointSizeInBytes.

static int endpointSizeInBytes(Endpoint value, boolean writeEmptyServiceName) {
    // {
    int sizeInBytes = 1;
    String serviceName = value.serviceName();
    if (serviceName == null && writeEmptyServiceName)
        serviceName = "";
    if (serviceName != null) {
        // "serviceName":""
        sizeInBytes += 16;
        sizeInBytes += jsonEscapedSizeInBytes(serviceName);
    }
    if (value.ipv4() != null) {
        // ,
        if (sizeInBytes != 1)
            sizeInBytes++;
        // "ipv4":""
        sizeInBytes += 9;
        sizeInBytes += value.ipv4().length();
    }
    if (value.ipv6() != null) {
        // ,
        if (sizeInBytes != 1)
            sizeInBytes++;
        // "ipv6":""
        sizeInBytes += 9;
        sizeInBytes += value.ipv6().length();
    }
    int port = value.portAsInt();
    if (port != 0) {
        // ,
        if (sizeInBytes != 1)
            sizeInBytes++;
        // "port":
        sizeInBytes += 7;
        sizeInBytes += asciiSizeInBytes(port);
    }
    // }
    return ++sizeInBytes;
}
Also used : Endpoint(zipkin2.Endpoint)

Example 54 with Endpoint

use of org.pjsip.pjsua2.Endpoint in project zipkin by openzipkin.

the class V1BinaryAnnotation method hashCode.

@Override
public int hashCode() {
    int h = 1;
    h *= 1000003;
    h ^= key.hashCode();
    h *= 1000003;
    h ^= stringValue == null ? 0 : stringValue.hashCode();
    h *= 1000003;
    h ^= endpoint == null ? 0 : endpoint.hashCode();
    return h;
}
Also used : Endpoint(zipkin2.Endpoint)

Example 55 with Endpoint

use of org.pjsip.pjsua2.Endpoint in project zipkin by openzipkin.

the class SelectSpansAndAnnotations method endpoint.

static Endpoint endpoint(Record a) {
    Endpoint.Builder result = Endpoint.newBuilder().serviceName(a.getValue(ZIPKIN_ANNOTATIONS.ENDPOINT_SERVICE_NAME)).port(Schema.maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_PORT, (short) 0));
    int ipv4 = maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_IPV4, 0);
    if (ipv4 != 0) {
        // allocation is ok here as Endpoint.ipv4Bytes would anyway
        result.parseIp(new byte[] { (byte) (ipv4 >> 24 & 0xff), (byte) (ipv4 >> 16 & 0xff), (byte) (ipv4 >> 8 & 0xff), (byte) (ipv4 & 0xff) });
    }
    result.parseIp(Schema.maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_IPV6, null));
    return result.build();
}
Also used : Endpoint(zipkin2.Endpoint) Endpoint(zipkin2.Endpoint)

Aggregations

Endpoint (zipkin2.Endpoint)55 Span (zipkin2.Span)27 Test (org.junit.jupiter.api.Test)18 V1Span (zipkin2.v1.V1Span)16 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)5 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)5 List (java.util.List)3 JsonToken (com.fasterxml.jackson.core.JsonToken)2 IOException (java.io.IOException)2 InetAddress (java.net.InetAddress)2 NetworkInterface (java.net.NetworkInterface)2 Arrays.asList (java.util.Arrays.asList)2 Endpoint (org.jboss.remoting3.Endpoint)2 Record (org.jooq.Record)2 Access (org.openstack4j.model.identity.v2.Access)2 V1SpanConverter (zipkin2.v1.V1SpanConverter)2 Tracing (brave.Tracing)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CrnkClient (io.crnk.client.CrnkClient)1