Search in sources :

Example 1 with CallbackCaptor

use of zipkin.internal.CallbackCaptor in project zipkin by openzipkin.

the class HttpBulkSpanIndexerTest method addsPipelineId.

@Test
public void addsPipelineId() throws Exception {
    close();
    indexer = new HttpBulkSpanIndexer(storage = ElasticsearchHttpStorage.builder().hosts(asList(es.url("").toString())).pipeline("zipkin").build());
    es.enqueue(new MockResponse());
    CallbackCaptor<Void> callback = new CallbackCaptor<>();
    indexer.add("zipkin-2016-10-01", TestObjects.TRACE.get(0), (Long) null).execute(callback);
    callback.get();
    RecordedRequest request = es.takeRequest();
    assertThat(request.getPath()).isEqualTo("/_bulk?pipeline=zipkin");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) CallbackCaptor(zipkin.internal.CallbackCaptor) Test(org.junit.Test)

Example 2 with CallbackCaptor

use of zipkin.internal.CallbackCaptor in project zipkin by openzipkin.

the class InternalForTests method writeDependencyLinks.

public static void writeDependencyLinks(ElasticsearchHttpStorage es, List<DependencyLink> links, long midnightUTC) {
    String index = es.indexNameFormatter().indexNameForTimestamp(midnightUTC);
    HttpBulkIndexer<DependencyLink> indexer = new HttpBulkIndexer<DependencyLink>(DEPENDENCY_LINK, es) {

        @Override
        byte[] toJsonBytes(DependencyLink link) {
            return Codec.JSON.writeDependencyLink(link);
        }
    };
    for (DependencyLink link : links) {
        // Unique constraint
        indexer.add(index, link, link.parent + "|" + link.child);
    }
    CallbackCaptor<Void> callback = new CallbackCaptor<>();
    indexer.execute(callback);
    callback.get();
}
Also used : CallbackCaptor(zipkin.internal.CallbackCaptor) DependencyLink(zipkin.DependencyLink)

Aggregations

CallbackCaptor (zipkin.internal.CallbackCaptor)2 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.junit.Test)1 DependencyLink (zipkin.DependencyLink)1