Search in sources :

Example 11 with Endpoint

use of org.jboss.remoting3.Endpoint in project zipkin by openzipkin.

the class ThriftEndpointCodec method write.

static void write(Endpoint value, WriteBuffer buffer) {
    IPV4.write(buffer);
    buffer.write(value.ipv4Bytes() != null ? value.ipv4Bytes() : INT_ZERO);
    PORT.write(buffer);
    int port = value.portAsInt();
    // write short!
    buffer.writeByte((port >>> 8L) & 0xff);
    buffer.writeByte(port & 0xff);
    SERVICE_NAME.write(buffer);
    ThriftCodec.writeLengthPrefixed(buffer, value.serviceName() != null ? value.serviceName() : "");
    byte[] ipv6 = value.ipv6Bytes();
    if (ipv6 != null) {
        IPV6.write(buffer);
        ThriftCodec.writeInt(buffer, 16);
        buffer.write(ipv6);
    }
    buffer.writeByte(TYPE_STOP);
}
Also used : Endpoint(zipkin2.Endpoint)

Example 12 with Endpoint

use of org.jboss.remoting3.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 13 with Endpoint

use of org.jboss.remoting3.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 14 with Endpoint

use of org.jboss.remoting3.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 15 with Endpoint

use of org.jboss.remoting3.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)

Aggregations

Endpoint (zipkin2.Endpoint)60 Span (zipkin2.Span)27 Test (org.junit.jupiter.api.Test)18 V1Span (zipkin2.v1.V1Span)16 Test (org.junit.Test)15 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)5 SpanSampler (com.wavefront.agent.sampler.SpanSampler)5 ByteBuf (io.netty.buffer.ByteBuf)5 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)5 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)5 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)5 ArrayList (java.util.ArrayList)5 Span (wavefront.report.Span)5 Endpoint (org.apache.woden.wsdl20.Endpoint)4 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)4 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Service (org.apache.woden.wsdl20.Service)3