Search in sources :

Example 46 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class V2SpanWriter method annotationSizeInBytes.

static int annotationSizeInBytes(long timestamp, String value, int endpointSizeInBytes) {
    // {"timestamp":,"value":""}
    int sizeInBytes = 25;
    sizeInBytes += asciiSizeInBytes(timestamp);
    sizeInBytes += jsonEscapedSizeInBytes(value);
    if (endpointSizeInBytes != 0) {
        // ,"endpoint":
        sizeInBytes += 12;
        sizeInBytes += endpointSizeInBytes;
    }
    return sizeInBytes;
}
Also used : Endpoint(zipkin2.Endpoint)

Example 47 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class V2SpanWriter method writeEndpoint.

static void writeEndpoint(Endpoint value, WriteBuffer b, boolean writeEmptyServiceName) {
    b.writeByte('{');
    boolean wroteField = false;
    String serviceName = value.serviceName();
    if (serviceName == null && writeEmptyServiceName)
        serviceName = "";
    if (serviceName != null) {
        b.writeAscii("\"serviceName\":\"");
        b.writeUtf8(jsonEscape(serviceName));
        b.writeByte('"');
        wroteField = true;
    }
    if (value.ipv4() != null) {
        if (wroteField)
            b.writeByte(',');
        b.writeAscii("\"ipv4\":\"");
        b.writeAscii(value.ipv4());
        b.writeByte('"');
        wroteField = true;
    }
    if (value.ipv6() != null) {
        if (wroteField)
            b.writeByte(',');
        b.writeAscii("\"ipv6\":\"");
        b.writeAscii(value.ipv6());
        b.writeByte('"');
        wroteField = true;
    }
    int port = value.portAsInt();
    if (port != 0) {
        if (wroteField)
            b.writeByte(',');
        b.writeAscii("\"port\":");
        b.writeAscii(port);
    }
    b.writeByte('}');
}
Also used : Endpoint(zipkin2.Endpoint)

Example 48 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class V1Annotation method hashCode.

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

Example 49 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class V1SpanConverter method processBinaryAnnotations.

void processBinaryAnnotations(V1Span source) {
    zipkin2.Endpoint ca = null, sa = null, ma = null;
    for (int i = 0, length = source.binaryAnnotations.size(); i < length; i++) {
        V1BinaryAnnotation b = source.binaryAnnotations.get(i);
        // endpoint. Hence, we leniently parse.
        if ("ca".equals(b.key)) {
            ca = b.endpoint;
            continue;
        } else if ("sa".equals(b.key)) {
            sa = b.endpoint;
            continue;
        } else if ("ma".equals(b.key)) {
            ma = b.endpoint;
            continue;
        }
        Span.Builder currentSpan = forEndpoint(source, b.endpoint);
        // don't add marker "lc" tags
        if ("lc".equals(b.key) && b.stringValue.isEmpty())
            continue;
        currentSpan.putTag(b.key, b.stringValue);
    }
    boolean noCoreAnnotations = cs == null && cr == null && ss == null && sr == null;
    // special-case when we are missing core annotations, but we have both address annotations
    if (noCoreAnnotations && (ca != null || sa != null)) {
        if (ca != null && sa != null) {
            forEndpoint(source, ca).remoteEndpoint(sa);
        } else if (sa != null) {
            // "sa" is a default for a remote address, don't make it a client span
            forEndpoint(source, null).remoteEndpoint(sa);
        } else {
            // ca != null: treat it like a server
            forEndpoint(source, null).kind(Kind.SERVER).remoteEndpoint(ca);
        }
        return;
    }
    V1Annotation server = sr != null ? sr : ss;
    if (ca != null && server != null && !ca.equals(server.endpoint)) {
        // the same service name as "sa". Removing the service name prevents creating loopback links.
        if (hasSameServiceName(ca, server.endpoint)) {
            ca = ca.toBuilder().serviceName(null).build();
        }
        forEndpoint(source, server.endpoint).remoteEndpoint(ca);
    }
    if (sa != null) {
        // client span
        if (cs != null) {
            forEndpoint(source, cs.endpoint).remoteEndpoint(sa);
        } else if (cr != null) {
            forEndpoint(source, cr.endpoint).remoteEndpoint(sa);
        }
    }
    if (ma != null) {
        // a messaging span. This will ensure both sides have the address of the broker.
        if (ms != null)
            forEndpoint(source, ms.endpoint).remoteEndpoint(ma);
        if (mr != null)
            forEndpoint(source, mr.endpoint).remoteEndpoint(ma);
    }
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Endpoint(zipkin2.Endpoint)

Example 50 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class V1SpanConverter method processAnnotations.

void processAnnotations(V1Span source) {
    for (int i = 0, length = source.annotations.size(); i < length; i++) {
        V1Annotation a = source.annotations.get(i);
        Span.Builder currentSpan = forEndpoint(source, a.endpoint);
        // core annotations require an endpoint. Don't give special treatment when that's missing
        if (a.value.length() == 2 && a.endpoint != null) {
            if (a.value.equals("cs")) {
                currentSpan.kind(Kind.CLIENT);
                cs = a;
            } else if (a.value.equals("sr")) {
                currentSpan.kind(Kind.SERVER);
                sr = a;
            } else if (a.value.equals("ss")) {
                currentSpan.kind(Kind.SERVER);
                ss = a;
            } else if (a.value.equals("cr")) {
                currentSpan.kind(Kind.CLIENT);
                cr = a;
            } else if (a.value.equals("ms")) {
                currentSpan.kind(Kind.PRODUCER);
                ms = a;
            } else if (a.value.equals("mr")) {
                currentSpan.kind(Kind.CONSUMER);
                mr = a;
            } else if (a.value.equals("ws")) {
                ws = a;
            } else if (a.value.equals("wr")) {
                wr = a;
            } else {
                currentSpan.addAnnotation(a.timestamp, a.value);
            }
        } else {
            currentSpan.addAnnotation(a.timestamp, a.value);
        }
    }
    // When bridging between event and span model, you can end up missing a start annotation
    if (cs == null && endTimestampReflectsSpanDuration(cr, source)) {
        cs = V1Annotation.create(source.timestamp, "cs", cr.endpoint);
    }
    if (sr == null && endTimestampReflectsSpanDuration(ss, source)) {
        sr = V1Annotation.create(source.timestamp, "sr", ss.endpoint);
    }
    if (cs != null && sr != null) {
        // in a shared span, the client side owns span duration by annotations or explicit timestamp
        maybeTimestampDuration(source, cs, cr);
        // special-case loopback: We need to make sure on loopback there are two span2s
        Span.Builder client = forEndpoint(source, cs.endpoint);
        Span.Builder server;
        if (hasSameServiceName(cs.endpoint, sr.endpoint)) {
            client.kind(Kind.CLIENT);
            // fork a new span for the server side
            server = newSpanBuilder(source, sr.endpoint).kind(Kind.SERVER);
        } else {
            server = forEndpoint(source, sr.endpoint);
        }
        // the server side is smaller than that, we have to read annotations to find out
        server.shared(true).timestamp(sr.timestamp);
        if (ss != null)
            server.duration(ss.timestamp - sr.timestamp);
        // one-way has no duration
        if (cr == null && source.duration == 0)
            client.duration(null);
    } else if (cs != null && cr != null) {
        maybeTimestampDuration(source, cs, cr);
    } else if (sr != null && ss != null) {
        maybeTimestampDuration(source, sr, ss);
    } else {
        // otherwise, the span is incomplete. revert special-casing
        handleIncompleteRpc(source);
    }
    // implied shared. When we only see the server-side, carry this signal over.
    if (cs == null && sr != null && // case could be due to the client-side of that RPC.
    (source.timestamp == 0 || (ss != null && source.duration == 0))) {
        forEndpoint(source, sr.endpoint).shared(true);
    }
    // ms and mr are not supposed to be in the same span, but in case they are..
    if (ms != null && mr != null) {
        // special-case loopback: We need to make sure on loopback there are two span2s
        Span.Builder producer = forEndpoint(source, ms.endpoint);
        Span.Builder consumer;
        if (hasSameServiceName(ms.endpoint, mr.endpoint)) {
            producer.kind(Kind.PRODUCER);
            // fork a new span for the consumer side
            consumer = newSpanBuilder(source, mr.endpoint).kind(Kind.CONSUMER);
        } else {
            consumer = forEndpoint(source, mr.endpoint);
        }
        consumer.shared(true);
        if (wr != null) {
            consumer.timestamp(wr.timestamp).duration(mr.timestamp - wr.timestamp);
        } else {
            consumer.timestamp(mr.timestamp);
        }
        producer.timestamp(ms.timestamp).duration(ws != null ? ws.timestamp - ms.timestamp : null);
    } else if (ms != null) {
        maybeTimestampDuration(source, ms, ws);
    } else if (mr != null) {
        if (wr != null) {
            maybeTimestampDuration(source, wr, mr);
        } else {
            maybeTimestampDuration(source, mr, null);
        }
    } else {
        if (ws != null)
            forEndpoint(source, ws.endpoint).addAnnotation(ws.timestamp, ws.value);
        if (wr != null)
            forEndpoint(source, wr.endpoint).addAnnotation(wr.timestamp, wr.value);
    }
}
Also used : Span(zipkin2.Span) Endpoint(zipkin2.Endpoint)

Aggregations

Endpoint (zipkin2.Endpoint)73 Span (zipkin2.Span)33 Test (org.junit.Test)28 Endpoint (org.jboss.remoting3.Endpoint)22 Test (org.junit.jupiter.api.Test)20 V1Span (zipkin2.v1.V1Span)16 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)10 SpanSampler (com.wavefront.agent.sampler.SpanSampler)10 ByteBuf (io.netty.buffer.ByteBuf)10 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)10 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)10 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)10 Span (wavefront.report.Span)10 IOException (java.io.IOException)8 URI (java.net.URI)8 HashMap (java.util.HashMap)8 Annotation (wavefront.report.Annotation)8 ServiceName (org.jboss.msc.service.ServiceName)7 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)6 SaslAuthenticationFactory (org.wildfly.security.auth.server.SaslAuthenticationFactory)6