Search in sources :

Example 11 with Builder

use of zipkin2.elasticsearch.ElasticsearchStorage.Builder in project zipkin by openzipkin.

the class ZipkinElasticsearchStorageConfiguration method esClientFactory.

// exposed as a bean so that we can test TLS by swapping it out.
// TODO: see if we can override the TLS via properties instead as that has less surface area.
@Bean
@Qualifier(QUALIFIER)
@ConditionalOnMissingBean
ClientFactory esClientFactory(ZipkinElasticsearchStorageProperties es, MeterRegistry meterRegistry) throws Exception {
    ClientFactoryBuilder builder = ClientFactory.builder();
    Ssl ssl = es.getSsl();
    if (ssl.isNoVerify())
        builder.tlsNoVerify();
    // Allow use of a custom KeyStore or TrustStore when connecting to Elasticsearch
    if (ssl.getKeyStore() != null || ssl.getTrustStore() != null)
        configureSsl(builder, ssl);
    // TODO: find or raise a bug with Elastic
    return builder.useHttp2Preface(false).connectTimeoutMillis(es.getTimeout()).meterRegistry(meterRegistry).build();
}
Also used : ClientFactoryBuilder(com.linecorp.armeria.client.ClientFactoryBuilder) Ssl(zipkin2.server.internal.elasticsearch.ZipkinElasticsearchStorageProperties.Ssl) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 12 with Builder

use of zipkin2.elasticsearch.ElasticsearchStorage.Builder in project zipkin by openzipkin.

the class ITZipkinSelfTracing method assertQueryReturnsResults.

void assertQueryReturnsResults(QueryRequest.Builder builder, List<List<Span>> traces) throws IOException {
    QueryRequest query = builder.endTs(System.currentTimeMillis()).lookback(DAY).limit(2).build();
    assertThat(inMemoryStorage().getTraces(query).execute()).withFailMessage("Expected results from %s. Current traces: %s", query, traces).isNotEmpty();
}
Also used : QueryRequest(zipkin2.storage.QueryRequest)

Example 13 with Builder

use of zipkin2.elasticsearch.ElasticsearchStorage.Builder in project zipkin by openzipkin.

the class ITSpanStoreHeavy method getTraces_manyTraces.

/**
 * Formerly, a bug was present where cassandra didn't index more than bucket count traces per
 * millisecond. This stores a lot of spans to ensure indexes work under high-traffic scenarios.
 */
@Test
protected void getTraces_manyTraces(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Span span = spanBuilder(testSuffix).build();
    Map.Entry<String, String> tag = span.tags().entrySet().iterator().next();
    int traceCount = 1000;
    Span[] traces = new Span[traceCount];
    traces[0] = span;
    IntStream.range(1, traces.length).forEach(i -> traces[i] = spanBuilder(testSuffix).timestamp((TODAY + i) * 1000).duration(10L).build());
    accept(traces);
    assertGetTracesReturnsCount(requestBuilder().limit(traceCount).build(), traceCount);
    QueryRequest.Builder builder = requestBuilder().limit(traceCount).serviceName(span.localServiceName());
    assertGetTracesReturnsCount(builder.build(), traceCount);
    assertGetTracesReturnsCount(builder.remoteServiceName(span.remoteServiceName()).build(), traceCount);
    assertGetTracesReturnsCount(builder.spanName(span.name()).build(), traceCount);
    assertGetTracesReturnsCount(builder.parseAnnotationQuery(tag.getKey() + "=" + tag.getValue()).build(), traceCount);
}
Also used : Span(zipkin2.Span) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 14 with Builder

use of zipkin2.elasticsearch.ElasticsearchStorage.Builder in project zipkin by openzipkin.

the class Proto3CodecInteropTest method annotation_read_matchesWireEncodingWithTag.

@Test
public void annotation_read_matchesWireEncodingWithTag() {
    zipkin2.Annotation zipkinAnnotation = ZIPKIN_SPAN.annotations().get(0);
    Span wireSpan = new Span.Builder().annotations(PROTO_SPAN.annotations).build();
    ReadBuffer wireBytes = ReadBuffer.wrap(wireSpan.encode());
    assertThat(wireBytes.readVarint32()).isEqualTo(ANNOTATION.key);
    zipkin2.Span.Builder builder = zipkinSpanBuilder();
    ANNOTATION.readLengthPrefixAndValue(wireBytes, builder);
    assertThat(builder.build().annotations()).containsExactly(zipkinAnnotation);
}
Also used : Span(zipkin2.proto3.Span) Test(org.junit.Test)

Example 15 with Builder

use of zipkin2.elasticsearch.ElasticsearchStorage.Builder in project zipkin by openzipkin.

the class BulkRequestBenchmarks method buildAndWriteRequest_singleSpan.

@Benchmark
public HttpRequest buildAndWriteRequest_singleSpan() {
    BulkCallBuilder builder = new BulkCallBuilder(es, V6_0, "index-span");
    builder.index(spanIndex, "span", CLIENT_SPAN, BulkIndexWriter.SPAN);
    HttpCall.RequestSupplier supplier = builder.build().request;
    HttpRequestWriter request = HttpRequest.streaming(supplier.headers());
    supplier.writeBody(request::tryWrite);
    return request;
}
Also used : HttpCall(zipkin2.elasticsearch.internal.client.HttpCall) HttpRequestWriter(com.linecorp.armeria.common.HttpRequestWriter) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

Endpoint (zipkin2.Endpoint)8 Test (org.junit.Test)4 URI (java.net.URI)3 SQLException (java.sql.SQLException)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Test (org.junit.jupiter.api.Test)3 Call (zipkin2.Call)3 HttpRequestWriter (com.linecorp.armeria.common.HttpRequestWriter)2 InetAddress (java.net.InetAddress)2 NetworkInterface (java.net.NetworkInterface)2 Benchmark (org.openjdk.jmh.annotations.Benchmark)2 HttpCall (zipkin2.elasticsearch.internal.client.HttpCall)2 V1Span (zipkin2.v1.V1Span)2 ClientFactory (com.linecorp.armeria.client.ClientFactory)1 ClientFactoryBuilder (com.linecorp.armeria.client.ClientFactoryBuilder)1 ClientOptions (com.linecorp.armeria.client.ClientOptions)1 ClientOptionsBuilder (com.linecorp.armeria.client.ClientOptionsBuilder)1 WebClient (com.linecorp.armeria.client.WebClient)1 WebClientBuilder (com.linecorp.armeria.client.WebClientBuilder)1 ContentPreviewingClient (com.linecorp.armeria.client.logging.ContentPreviewingClient)1