Search in sources :

Example 36 with Endpoint

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

the class SelectSpansAndAnnotations method apply.

@Override
public List<Span> apply(DSLContext context) {
    final Map<Pair, List<V1Span.Builder>> spansWithoutAnnotations;
    final Map<Row3<Long, Long, Long>, List<Record>> dbAnnotations;
    spansWithoutAnnotations = context.select(schema.spanFields).from(ZIPKIN_SPANS).where(traceIdCondition(context)).stream().map(r -> V1Span.newBuilder().traceIdHigh(maybeGet(r, ZIPKIN_SPANS.TRACE_ID_HIGH, 0L)).traceId(r.getValue(ZIPKIN_SPANS.TRACE_ID)).name(r.getValue(ZIPKIN_SPANS.NAME)).id(r.getValue(ZIPKIN_SPANS.ID)).parentId(maybeGet(r, ZIPKIN_SPANS.PARENT_ID, 0L)).timestamp(maybeGet(r, ZIPKIN_SPANS.START_TS, 0L)).duration(maybeGet(r, ZIPKIN_SPANS.DURATION, 0L)).debug(r.getValue(ZIPKIN_SPANS.DEBUG))).collect(groupingBy(s -> new Pair(s.traceIdHigh(), s.traceId()), LinkedHashMap::new, Collectors.toList()));
    dbAnnotations = context.select(schema.annotationFields).from(ZIPKIN_ANNOTATIONS).where(schema.annotationsTraceIdCondition(spansWithoutAnnotations.keySet())).orderBy(ZIPKIN_ANNOTATIONS.A_TIMESTAMP.asc(), ZIPKIN_ANNOTATIONS.A_KEY.asc()).stream().collect(groupingBy((Record a) -> row(maybeGet(a, ZIPKIN_ANNOTATIONS.TRACE_ID_HIGH, 0L), a.getValue(ZIPKIN_ANNOTATIONS.TRACE_ID), a.getValue(ZIPKIN_ANNOTATIONS.SPAN_ID)), LinkedHashMap::new, // LinkedHashMap preserves order while grouping
    Collectors.toList()));
    V1SpanConverter converter = V1SpanConverter.create();
    List<Span> allSpans = new ArrayList<>(spansWithoutAnnotations.size());
    for (List<V1Span.Builder> spans : spansWithoutAnnotations.values()) {
        for (V1Span.Builder span : spans) {
            Row3<Long, Long, Long> key = row(span.traceIdHigh(), span.traceId(), span.id());
            if (dbAnnotations.containsKey(key)) {
                for (Record a : dbAnnotations.get(key)) {
                    Endpoint endpoint = endpoint(a);
                    processAnnotationRecord(a, span, endpoint);
                }
            }
            converter.convert(span.build(), allSpans);
        }
    }
    return allSpans;
}
Also used : ArrayList(java.util.ArrayList) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) LinkedHashMap(java.util.LinkedHashMap) Endpoint(zipkin2.Endpoint) V1SpanConverter(zipkin2.v1.V1SpanConverter) HexCodec.lowerHexToUnsignedLong(zipkin2.internal.HexCodec.lowerHexToUnsignedLong) ArrayList(java.util.ArrayList) List(java.util.List) Record(org.jooq.Record) V1Span(zipkin2.v1.V1Span) Row3(org.jooq.Row3)

Example 37 with Endpoint

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

the class JsonSerializersTest method span_specialCharsInJson.

/**
 * This isn't a test of what we "should" accept as a span, rather that characters that trip-up
 * json don't fail in SPAN_PARSER.
 */
@Test
public void span_specialCharsInJson() {
    // service name is surrounded by control characters
    Endpoint e = Endpoint.newBuilder().serviceName(new String(new char[] { 0, 'a', 1 })).build();
    Span worstSpanInTheWorld = Span.newBuilder().traceId("1").id("1").name(new String(new char[] { '"', '\\', '\t', '\b', '\n', '\r', '\f' })).localEndpoint(e).addAnnotation(1L, "\u2028 and \u2029").putTag("\"foo", "Database error: ORA-00942:\u2028 and \u2029 table or view does not exist\n").build();
    assertThat(parse(SPAN_PARSER, new String(SpanBytesEncoder.JSON_V2.encode(worstSpanInTheWorld), UTF_8))).isEqualTo(worstSpanInTheWorld);
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Test(org.junit.Test)

Example 38 with Endpoint

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

the class JsonSerializers method parseEndpoint.

static Endpoint parseEndpoint(JsonParser parser) throws IOException {
    if (!parser.isExpectedStartObjectToken()) {
        throw new IllegalArgumentException("Not a valid JSON object, start token: " + parser.currentToken());
    }
    String serviceName = null, ipv4 = null, ipv6 = null;
    int port = 0;
    while (parser.nextToken() != JsonToken.END_OBJECT) {
        JsonToken value = parser.nextValue();
        if (value == JsonToken.VALUE_NULL) {
            continue;
        }
        switch(parser.currentName()) {
            case "serviceName":
                serviceName = parser.getText();
                break;
            case "ipv4":
                ipv4 = parser.getText();
                break;
            case "ipv6":
                ipv6 = parser.getText();
                break;
            case "port":
                port = parser.getIntValue();
                break;
            default:
        }
    }
    if (serviceName == null && ipv4 == null && ipv6 == null && port == 0)
        return null;
    return Endpoint.newBuilder().serviceName(serviceName).ip(ipv4).ip(ipv6).port(port).build();
}
Also used : JsonToken(com.fasterxml.jackson.core.JsonToken) Endpoint(zipkin2.Endpoint)

Example 39 with Endpoint

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

the class WireSpanDecoder method decodeEndpoint.

private static Endpoint decodeEndpoint(ProtoReader input) throws IOException {
    Endpoint.Builder endpoint = Endpoint.newBuilder();
    boolean done = false;
    while (!done) {
        int tag = input.nextTag();
        switch(tag) {
            case -1:
                done = true;
                break;
            case 1:
                {
                    String s = input.readString();
                    endpoint.serviceName(s);
                    break;
                }
            case 2:
            case 3:
                {
                    endpoint.parseIp(input.readBytes().toByteArray());
                    break;
                }
            case 4:
                {
                    endpoint.port(input.readVarint32());
                    break;
                }
            default:
                {
                    logAndSkip(input, tag);
                    break;
                }
        }
    }
    return endpoint.build();
}
Also used : Endpoint(zipkin2.Endpoint) ByteString(okio.ByteString) Endpoint(zipkin2.Endpoint)

Example 40 with Endpoint

use of com.google.cloud.aiplatform.v1.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)

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