Search in sources :

Example 36 with Endpoint

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

the class ThriftEndpointCodec method sizeInBytes.

static int sizeInBytes(Endpoint value) {
    String serviceName = value.serviceName();
    int sizeInBytes = 0;
    // IPV4
    sizeInBytes += 3 + 4;
    // PORT
    sizeInBytes += 3 + 2;
    sizeInBytes += 3 + 4 + (serviceName != null ? utf8SizeInBytes(serviceName) : 0);
    if (value.ipv6() != null)
        sizeInBytes += 3 + 4 + 16;
    // TYPE_STOP
    sizeInBytes++;
    return sizeInBytes;
}
Also used : Endpoint(zipkin2.Endpoint)

Example 37 with Endpoint

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

the class Trace method compareEndpoint.

/**
 * Put spans with null endpoints first, so that their data can be attached to the first span with
 * the same ID and endpoint. It is possible that a server can get the same request on a different
 * port. Not addressing this.
 */
static int compareEndpoint(Endpoint left, Endpoint right) {
    if (left == null) {
        // nulls first
        return (right == null) ? 0 : -1;
    } else if (right == null) {
        return 1;
    }
    int byService = nullSafeCompareTo(left.serviceName(), right.serviceName(), false);
    if (byService != 0)
        return byService;
    int byIpV4 = nullSafeCompareTo(left.ipv4(), right.ipv4(), false);
    if (byIpV4 != 0)
        return byIpV4;
    return nullSafeCompareTo(left.ipv6(), right.ipv6(), false);
}
Also used : Endpoint(zipkin2.Endpoint)

Example 38 with Endpoint

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

the class V1JsonSpanReader method readBinaryAnnotation.

void readBinaryAnnotation(JsonReader reader) throws IOException {
    String key = null;
    Endpoint endpoint = null;
    Boolean booleanValue = null;
    String stringValue = null;
    reader.beginObject();
    while (reader.hasNext()) {
        String nextName = reader.nextName();
        if (reader.peekNull()) {
            reader.skipValue();
            continue;
        }
        if (nextName.equals("key")) {
            key = reader.nextString();
        } else if (nextName.equals("value")) {
            if (reader.peekString()) {
                stringValue = reader.nextString();
            } else if (reader.peekBoolean()) {
                booleanValue = reader.nextBoolean();
            } else {
                reader.skipValue();
            }
        } else if (nextName.equals("endpoint")) {
            endpoint = ENDPOINT_READER.fromJson(reader);
        } else {
            reader.skipValue();
        }
    }
    if (key == null) {
        throw new IllegalArgumentException("No key at " + reader.getPath());
    }
    reader.endObject();
    if (stringValue != null) {
        builder.addBinaryAnnotation(key, stringValue, endpoint);
    } else if (booleanValue != null && booleanValue && endpoint != null) {
        if (key.equals("sa") || key.equals("ca") || key.equals("ma")) {
            builder.addBinaryAnnotation(key, endpoint);
        }
    }
}
Also used : Endpoint(zipkin2.Endpoint)

Example 39 with Endpoint

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

the class V1SpanWriter method write.

@Override
public void write(V1Span value, WriteBuffer b) {
    b.writeAscii("{\"traceId\":\"");
    if (value.traceIdHigh() != 0L)
        b.writeLongHex(value.traceIdHigh());
    b.writeLongHex(value.traceId());
    b.writeByte('"');
    if (value.parentId() != 0L) {
        b.writeAscii(",\"parentId\":\"");
        b.writeLongHex(value.parentId());
        b.writeByte('"');
    }
    b.writeAscii(",\"id\":\"");
    b.writeLongHex(value.id());
    b.writeByte('"');
    b.writeAscii(",\"name\":\"");
    if (value.name() != null)
        b.writeUtf8(jsonEscape(value.name()));
    b.writeByte('"');
    if (value.timestamp() != 0L) {
        b.writeAscii(",\"timestamp\":");
        b.writeAscii(value.timestamp());
    }
    if (value.duration() != 0L) {
        b.writeAscii(",\"duration\":");
        b.writeAscii(value.duration());
    }
    int annotationCount = value.annotations().size();
    Endpoint lastEndpoint = null;
    byte[] lastEndpointBytes = null;
    if (annotationCount > 0) {
        b.writeAscii(",\"annotations\":[");
        for (int i = 0; i < annotationCount; ) {
            V1Annotation a = value.annotations().get(i++);
            Endpoint endpoint = a.endpoint();
            byte[] endpointBytes;
            if (endpoint == null) {
                endpointBytes = null;
            } else if (endpoint.equals(lastEndpoint)) {
                endpointBytes = lastEndpointBytes;
            } else {
                lastEndpoint = endpoint;
                endpointBytes = lastEndpointBytes = legacyEndpointBytes(endpoint);
            }
            writeAnnotation(a.timestamp(), a.value(), endpointBytes, b);
            if (i < annotationCount)
                b.writeByte(',');
        }
        b.writeByte(']');
    }
    int binaryAnnotationCount = value.binaryAnnotations().size();
    if (binaryAnnotationCount > 0) {
        b.writeAscii(",\"binaryAnnotations\":[");
        for (int i = 0; i < binaryAnnotationCount; ) {
            V1BinaryAnnotation a = value.binaryAnnotations().get(i++);
            Endpoint endpoint = a.endpoint();
            byte[] endpointBytes;
            if (endpoint == null) {
                endpointBytes = null;
            } else if (endpoint.equals(lastEndpoint)) {
                endpointBytes = lastEndpointBytes;
            } else {
                lastEndpoint = endpoint;
                endpointBytes = lastEndpointBytes = legacyEndpointBytes(endpoint);
            }
            if (a.stringValue() != null) {
                writeBinaryAnnotation(a.key(), a.stringValue(), endpointBytes, b);
            } else {
                b.writeAscii("{\"key\":\"");
                b.writeAscii(a.key());
                b.writeAscii("\",\"value\":true,\"endpoint\":");
                b.write(endpointBytes);
                b.writeByte('}');
            }
            if (i < binaryAnnotationCount)
                b.writeByte(',');
        }
        b.writeByte(']');
    }
    if (Boolean.TRUE.equals(value.debug())) {
        b.writeAscii(",\"debug\":true");
    }
    b.writeByte('}');
}
Also used : Endpoint(zipkin2.Endpoint) V1BinaryAnnotation(zipkin2.v1.V1BinaryAnnotation) Endpoint(zipkin2.Endpoint) V1Annotation(zipkin2.v1.V1Annotation)

Example 40 with Endpoint

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

the class V1SpanWriter method binaryAnnotationSizeInBytes.

static int binaryAnnotationSizeInBytes(String key, String value, int endpointSize) {
    // {"key":"","value":""}
    int sizeInBytes = 21;
    sizeInBytes += jsonEscapedSizeInBytes(key);
    sizeInBytes += jsonEscapedSizeInBytes(value);
    if (endpointSize != 0) {
        // ,"endpoint":
        sizeInBytes += 12;
        sizeInBytes += endpointSize;
    }
    return sizeInBytes;
}
Also used : 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