Search in sources :

Example 31 with Endpoint

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

the class ITSpanStore method getTraces_differentiateOnServiceName.

/**
 * This test makes sure that annotation queries pay attention to which host recorded data
 */
@Test
protected void getTraces_differentiateOnServiceName(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    Span trace1 = Span.newBuilder().traceId(newTraceId()).name("1").id(1).kind(CLIENT).timestamp((TODAY + 1) * 1000L).duration(3000L).localEndpoint(frontend).addAnnotation(((TODAY + 1) * 1000L) + 500, "web").putTag("local", "web").putTag("web-b", "web").build();
    Span trace1Server = Span.newBuilder().traceId(trace1.traceId()).name("1").id(1).kind(SERVER).shared(true).localEndpoint(backend).timestamp((TODAY + 2) * 1000L).duration(1000L).build();
    Span trace2 = Span.newBuilder().traceId(newTraceId()).name("2").id(2).timestamp((TODAY + 11) * 1000L).duration(3000L).kind(CLIENT).localEndpoint(backend).addAnnotation(((TODAY + 11) * 1000) + 500, "app").putTag("local", "app").putTag("app-b", "app").build();
    Span trace2Server = Span.newBuilder().traceId(trace2.traceId()).name("2").id(2).shared(true).kind(SERVER).localEndpoint(frontend).timestamp((TODAY + 12) * 1000L).duration(1000L).build();
    accept(trace1, trace1Server, trace2, trace2Server);
    // Sanity check
    assertGetTraceReturns(trace1.traceId(), asList(trace1, trace1Server));
    assertGetTraceReturns(trace2.traceId(), asList(trace2, trace2Server));
    assertGetTracesReturns(requestBuilder().build(), asList(trace1, trace1Server), asList(trace2, trace2Server));
    // We only return traces where the service specified caused the data queried.
    assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("web").build(), asList(trace1, trace1Server));
    assertGetTracesReturnsEmpty(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("web").build());
    assertGetTracesReturns(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("app").build(), asList(trace2, trace2Server));
    assertGetTracesReturnsEmpty(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("app").build());
    // tags are returned on annotation queries
    assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("web-b").build(), asList(trace1, trace1Server));
    assertGetTracesReturnsEmpty(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("web-b").build());
    assertGetTracesReturns(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("app-b").build(), asList(trace2, trace2Server));
    assertGetTracesReturnsEmpty(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("app-b").build());
    // We only return traces where the service specified caused the tag queried.
    assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("local=web").build(), asList(trace1, trace1Server));
    assertGetTracesReturnsEmpty(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("local=web").build());
    assertGetTracesReturns(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("local=app").build(), asList(trace2, trace2Server));
    assertGetTracesReturnsEmpty(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("local=app").build());
}
Also used : Endpoint(zipkin2.Endpoint) TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 32 with Endpoint

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

the class ITSpanStore method getTraces_considersBitsAbove64bit.

@Test
protected void getTraces_considersBitsAbove64bit(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    // 64-bit trace ID
    Span span1 = Span.newBuilder().traceId(traceId.substring(16)).id("1").putTag("foo", "1").timestamp(TODAY * 1000L).localEndpoint(frontend).build();
    // 128-bit trace ID prefixed by above
    Span span2 = span1.toBuilder().traceId(traceId).putTag("foo", "2").build();
    // Different 128-bit trace ID prefixed by above
    Span span3 = span1.toBuilder().traceId("1" + span1.traceId()).putTag("foo", "3").build();
    accept(span1, span2, span3);
    for (Span span : Arrays.asList(span1, span2, span3)) {
        assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("foo=" + span.tags().get("foo")).build(), asList(span));
    }
}
Also used : Endpoint(zipkin2.Endpoint) TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 33 with Endpoint

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

the class TraceTest method cleanupComparator_transitiveKindComparison.

/**
 * Comparators are meant to be transitive. This exploits edge cases to fool our comparator.
 */
@Test
public void cleanupComparator_transitiveKindComparison() {
    List<Span> trace = new ArrayList<>();
    Endpoint aEndpoint = Endpoint.newBuilder().serviceName("a").build();
    Endpoint bEndpoint = Endpoint.newBuilder().serviceName("b").build();
    Span template = Span.newBuilder().traceId("a").id("a").build();
    // when there are at least 32 elements.
    for (int i = 0, length = 7; i < length; i++) {
        trace.add(template.toBuilder().shared(true).localEndpoint(bEndpoint).build());
        trace.add(template.toBuilder().kind(Kind.CLIENT).localEndpoint(bEndpoint).build());
        trace.add(template.toBuilder().localEndpoint(aEndpoint).build());
        trace.add(template);
        trace.add(template.toBuilder().kind(Kind.CLIENT).localEndpoint(aEndpoint).build());
    }
    Collections.sort(trace, Trace.CLEANUP_COMPARATOR);
    assertThat(new LinkedHashSet<>(trace)).extracting(Span::shared, Span::kind, s -> s.localServiceName()).containsExactly(tuple(null, Kind.CLIENT, "a"), tuple(null, Kind.CLIENT, "b"), tuple(null, null, null), tuple(null, null, "a"), tuple(true, null, "b"));
}
Also used : List(java.util.List) Endpoint(zipkin2.Endpoint) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Arrays.asList(java.util.Arrays.asList) Kind(zipkin2.Span.Kind) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Span(zipkin2.Span) Test(org.junit.Test) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) Endpoint(zipkin2.Endpoint) ArrayList(java.util.ArrayList) Span(zipkin2.Span) Endpoint(zipkin2.Endpoint) Test(org.junit.Test)

Example 34 with Endpoint

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

the class V1ThriftSpanWriterTest method endpoint_highPort.

@Test
public void endpoint_highPort() {
    int highPort = 63840;
    Endpoint endpoint = Endpoint.newBuilder().ip("127.0.0.1").port(63840).build();
    byte[] buff = new byte[ThriftEndpointCodec.sizeInBytes(endpoint)];
    ThriftEndpointCodec.write(endpoint, WriteBuffer.wrap(buff, 0));
    assertThat(buff).containsSequence(TYPE_I32, 0, 1, 127, 0, 0, // ipv4
    1).containsSequence(TYPE_I16, 0, 2, (highPort >> 8) & 0xFF, // port
    highPort & 0xFF);
    assertThat(ThriftEndpointCodec.read(ReadBuffer.wrap(buff)).portAsInt()).isEqualTo(highPort);
}
Also used : Endpoint(zipkin2.Endpoint) Endpoint(zipkin2.Endpoint) Test(org.junit.Test)

Example 35 with Endpoint

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

the class DependencyLinkV2SpanIterator method next.

@Override
public Span next() {
    if (!hasNext())
        throw new NoSuchElementException();
    Record row = delegate.peek();
    long spanId = row.getValue(ZipkinSpans.ZIPKIN_SPANS.ID);
    boolean error = false;
    String lcService = null, srService = null, csService = null, caService = null, saService = null, maService = null, mrService = null, msService = null;
    while (hasNext()) {
        // there are more values for this trace
        if (spanId != delegate.peek().getValue(ZipkinSpans.ZIPKIN_SPANS.ID)) {
            // if we are in a new span
            break;
        }
        // row for the same span
        Record next = delegate.next();
        String key = emptyToNull(next, ZIPKIN_ANNOTATIONS.A_KEY);
        String value = emptyToNull(next, ZIPKIN_ANNOTATIONS.ENDPOINT_SERVICE_NAME);
        // neither client nor server
        if (key == null || value == null)
            continue;
        switch(key) {
            case "lc":
                lcService = value;
                break;
            case "ca":
                caService = value;
                break;
            case "cs":
                csService = value;
                break;
            case "ma":
                maService = value;
                break;
            case "mr":
                mrService = value;
                break;
            case "ms":
                msService = value;
                break;
            case "sa":
                saService = value;
                break;
            case "sr":
                srService = value;
                break;
            case "error":
                // a span is in error if it has a tag, not an annotation, of name "error"
                error = V1BinaryAnnotation.TYPE_STRING == next.get(ZIPKIN_ANNOTATIONS.A_TYPE);
        }
    }
    // The client address is more authoritative than the client send owner.
    if (caService == null)
        caService = csService;
    // Skip the client side, so it isn't mistaken for a loopback request
    if (saService != null && saService.equals(caService))
        caService = null;
    long parentId = maybeGet(row, ZipkinSpans.ZIPKIN_SPANS.PARENT_ID, 0L);
    Span.Builder result = Span.newBuilder().traceId(traceIdHi, traceIdLo).parentId(parentId).id(spanId);
    if (error) {
        result.putTag("error", "");
    }
    if (srService != null) {
        return result.kind(Span.Kind.SERVER).localEndpoint(ep(srService)).remoteEndpoint(ep(caService)).build();
    } else if (saService != null) {
        Endpoint localEndpoint = ep(caService);
        // When span.kind is missing, the local endpoint is "lc" and the remote endpoint is "sa"
        if (localEndpoint == null)
            localEndpoint = ep(lcService);
        return result.kind(csService != null ? Span.Kind.CLIENT : null).localEndpoint(localEndpoint).remoteEndpoint(ep(saService)).build();
    } else if (csService != null) {
        return result.kind(Span.Kind.SERVER).localEndpoint(ep(caService)).build();
    } else if (mrService != null) {
        return result.kind(Span.Kind.CONSUMER).localEndpoint(ep(mrService)).remoteEndpoint(ep(maService)).build();
    } else if (msService != null) {
        return result.kind(Span.Kind.PRODUCER).localEndpoint(ep(msService)).remoteEndpoint(ep(maService)).build();
    }
    return result.build();
}
Also used : Endpoint(zipkin2.Endpoint) Record(org.jooq.Record) Span(zipkin2.Span) NoSuchElementException(java.util.NoSuchElementException)

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