Search in sources :

Example 61 with Span

use of zipkin2.proto3.Span in project zipkin by openzipkin.

the class CassandraUtilTest method annotationKeys_skipsTagsLongerThan256chars.

@Test
public void annotationKeys_skipsTagsLongerThan256chars() {
    // example long value
    String arn = "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012";
    // 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 = TestObjects.CLIENT_SPAN.toBuilder().putTag("aws.arn", arn).putTag("http.url", url).build();
    assertThat(CassandraUtil.annotationQuery(span)).contains("aws.arn", "aws.arn=" + arn).doesNotContain("http.url").doesNotContain("http.url=" + url);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 62 with Span

use of zipkin2.proto3.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 63 with Span

use of zipkin2.proto3.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 64 with Span

use of zipkin2.proto3.Span in project zipkin by openzipkin.

the class ElasticsearchSpanStore method getTraces.

@Override
public Call<List<List<Span>>> getTraces(Iterable<String> traceIds) {
    Set<String> normalizedTraceIds = new LinkedHashSet<>();
    for (String traceId : traceIds) {
        // make sure we have a 16 or 32 character trace ID
        traceId = Span.normalizeTraceId(traceId);
        // Unless we are strict, truncate the trace ID to 64bit (encoded as 16 characters)
        if (!strictTraceId && traceId.length() == 32)
            traceId = traceId.substring(16);
        normalizedTraceIds.add(traceId);
    }
    if (normalizedTraceIds.isEmpty())
        return Call.emptyList();
    SearchRequest request = SearchRequest.create(asList(allSpanIndices)).terms("traceId", normalizedTraceIds);
    return search.newCall(request, BodyConverters.SPANS).map(groupByTraceId);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SearchRequest(zipkin2.elasticsearch.internal.client.SearchRequest)

Example 65 with Span

use of zipkin2.proto3.Span in project zipkin by openzipkin.

the class BulkIndexWriter method addSearchFields.

static void addSearchFields(Span span, JsonGenerator writer) throws IOException {
    long timestampMillis = span.timestampAsLong() / 1000L;
    if (timestampMillis != 0L)
        writer.writeNumberField("timestamp_millis", timestampMillis);
    if (!span.tags().isEmpty() || !span.annotations().isEmpty()) {
        writer.writeArrayFieldStart("_q");
        for (Annotation a : span.annotations()) {
            if (a.value().length() > SHORT_STRING_LENGTH)
                continue;
            writer.writeString(a.value());
        }
        for (Map.Entry<String, String> tag : span.tags().entrySet()) {
            int length = tag.getKey().length() + tag.getValue().length() + 1;
            if (length > SHORT_STRING_LENGTH)
                continue;
            // search is possible by key alone
            writer.writeString(tag.getKey());
            writer.writeString(tag.getKey() + "=" + tag.getValue());
        }
        writer.writeEndArray();
    }
}
Also used : Map(java.util.Map) Annotation(zipkin2.Annotation) Endpoint(zipkin2.Endpoint)

Aggregations

Span (zipkin2.Span)290 Test (org.junit.Test)203 Test (org.junit.jupiter.api.Test)69 Endpoint (zipkin2.Endpoint)62 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 ArrayList (java.util.ArrayList)29 V1Span (zipkin2.v1.V1Span)23 List (java.util.List)19 Map (java.util.Map)18 Annotation (zipkin2.Annotation)13 AggregateCall (zipkin2.internal.AggregateCall)13 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)12 IOException (java.io.IOException)10 LinkedHashMap (java.util.LinkedHashMap)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 Arrays.asList (java.util.Arrays.asList)9 Span (com.google.devtools.cloudtrace.v2.Span)8 Trace (com.google.devtools.cloudtrace.v1.Trace)7 Call (zipkin2.Call)7 Span (zipkin2.proto3.Span)7