Search in sources :

Example 46 with Span

use of io.opentelemetry.proto.trace.v1.Span in project zipkin by openzipkin.

the class CassandraUtilTest method annotationKeys_skipsAllocationWhenNoValidInput.

@Test
public void annotationKeys_skipsAllocationWhenNoValidInput() {
    // example too long value
    String url = "http://webservices.amazon.com/onca/xml?AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&AssociateTag=mytag-20&ItemId=0679722769&Operation=ItemLookup&ResponseGroup=Images%2CItemAttributes%2COffers%2CReviews&Service=AWSECommerceService&Timestamp=2014-08-18T12%3A00%3A00Z&Version=2013-08-01&Signature=j7bZM0LXZ9eXeZruTqWm2DIvDYVUU3wxPPpp%2BiXxzQc%3D";
    Span span = Span.newBuilder().traceId("1").id("1").build();
    assertThat(CassandraUtil.annotationQuery(span)).isNull();
    span = span.toBuilder().addAnnotation(1L, url).putTag("http.url", url).build();
    assertThat(CassandraUtil.annotationQuery(span)).isNull();
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 47 with Span

use of io.opentelemetry.proto.trace.v1.Span in project zipkin by openzipkin.

the class ITEnsureSchema method worksWithOldSchema.

/**
 * This tests we don't accidentally rely on new indexes such as autocomplete tags
 */
@Test
void worksWithOldSchema(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Schema.applyCqlFile(storage.keyspace, session(), "/zipkin2-schema.cql");
    Schema.applyCqlFile(storage.keyspace, session(), "/zipkin2-schema-indexes-original.cql");
    // Ensure the storage component is functional before proceeding
    CheckResult check = storage.check();
    if (!check.ok()) {
        throw new AssertionError("Could not connect to storage: " + check.error().getMessage(), check.error());
    }
    List<Span> trace = newTrace(testSuffix);
    accept(trace);
    assertGetTraceReturns(trace.get(0).traceId(), trace);
    assertThat(storage.autocompleteTags().getValues("environment").execute()).isEmpty();
    String serviceName = trace.get(0).localServiceName();
    assertThat(storage.serviceAndSpanNames().getRemoteServiceNames(serviceName).execute()).isEmpty();
    QueryRequest request = requestBuilder().serviceName(serviceName).remoteServiceName(appendSuffix(BACKEND.serviceName(), testSuffix)).build();
    // Make sure there's an error if a query will return incorrectly vs returning invalid results
    assertThatThrownBy(() -> storage.spanStore().getTraces(request)).isInstanceOf(IllegalArgumentException.class).hasMessage("remoteService=" + trace.get(1).remoteServiceName() + " unsupported due to missing table remote_service_by_service");
}
Also used : QueryRequest(zipkin2.storage.QueryRequest) CheckResult(zipkin2.CheckResult) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 48 with Span

use of io.opentelemetry.proto.trace.v1.Span in project zipkin by openzipkin.

the class ElasticsearchSpanConsumerTest method addsTimestamp_millisIntoJson.

@Test
void addsTimestamp_millisIntoJson() throws Exception {
    server.enqueue(SUCCESS_RESPONSE);
    Span span = Span.newBuilder().traceId("20").id("20").name("get").timestamp(TODAY * 1000).build();
    accept(span);
    assertThat(server.takeRequest().request().contentUtf8()).contains("\n{\"timestamp_millis\":" + TODAY + ",\"traceId\":");
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 49 with Span

use of io.opentelemetry.proto.trace.v1.Span in project zipkin by openzipkin.

the class ElasticsearchSpanConsumerTest method traceIsSearchableByServerServiceName.

@Test
void traceIsSearchableByServerServiceName() throws Exception {
    server.enqueue(SUCCESS_RESPONSE);
    Span clientSpan = Span.newBuilder().traceId("20").id("22").name("").parentId("21").timestamp(1000L).kind(Kind.CLIENT).localEndpoint(WEB_ENDPOINT).build();
    Span serverSpan = Span.newBuilder().traceId("20").id("22").name("get").parentId("21").timestamp(2000L).kind(Kind.SERVER).localEndpoint(APP_ENDPOINT).build();
    accept(serverSpan, clientSpan);
    // make sure that both timestamps are in the index
    assertThat(server.takeRequest().request().contentUtf8()).contains("{\"timestamp_millis\":2").contains("{\"timestamp_millis\":1");
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 50 with Span

use of io.opentelemetry.proto.trace.v1.Span in project zipkin by openzipkin.

the class ElasticsearchSpanConsumerTest method choosesTypeSpecificIndex.

@Test
void choosesTypeSpecificIndex() throws Exception {
    server.enqueue(SUCCESS_RESPONSE);
    Span span = Span.newBuilder().traceId("1").id("2").parentId("1").name("s").localEndpoint(APP_ENDPOINT).addAnnotation(TimeUnit.DAYS.toMicros(365), /* 1971-01-01 */
    "foo").build();
    // sanity check data
    assertThat(span.timestamp()).isNull();
    accept(span);
    // index timestamp is the server timestamp, not current time!
    assertThat(server.takeRequest().request().contentUtf8()).startsWith("{\"index\":{\"_index\":\"zipkin:span-1971-01-01\",\"_type\":\"span\"");
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Aggregations

Span (zipkin2.Span)335 Test (org.junit.Test)237 Test (org.junit.jupiter.api.Test)84 ArrayList (java.util.ArrayList)47 Endpoint (zipkin2.Endpoint)43 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 Span (io.opentelemetry.proto.trace.v1.Span)35 List (java.util.List)23 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)20 V1Span (zipkin2.v1.V1Span)17 Span (com.google.devtools.cloudtrace.v2.Span)16 Map (java.util.Map)14 AggregateCall (zipkin2.internal.AggregateCall)13 ResourceSpans (io.opentelemetry.proto.trace.v1.ResourceSpans)11 Arrays.asList (java.util.Arrays.asList)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 Annotation (wavefront.report.Annotation)11 Trace (com.google.devtools.cloudtrace.v1.Trace)10 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)10 AttributeValue (com.google.devtools.cloudtrace.v2.AttributeValue)10