Search in sources :

Example 1 with DependencyLinker

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

the class MySQLSpanStore method aggregateDependencies.

List<DependencyLink> aggregateDependencies(long endTs, @Nullable Long lookback, Connection conn) {
    endTs = endTs * 1000;
    // Lazy fetching the cursor prevents us from buffering the whole dataset in memory.
    Cursor<Record> cursor = context.get(conn).selectDistinct(schema.dependencyLinkFields).from(ZIPKIN_SPANS.leftJoin(ZIPKIN_ANNOTATIONS).on(ZIPKIN_SPANS.TRACE_ID.eq(ZIPKIN_ANNOTATIONS.TRACE_ID).and(ZIPKIN_SPANS.ID.eq(ZIPKIN_ANNOTATIONS.SPAN_ID))).and(ZIPKIN_ANNOTATIONS.A_KEY.in(CLIENT_SEND, CLIENT_ADDR, SERVER_RECV, SERVER_ADDR))).where(lookback == null ? ZIPKIN_SPANS.START_TS.lessOrEqual(endTs) : ZIPKIN_SPANS.START_TS.between(endTs - lookback * 1000, endTs)).groupBy(schema.dependencyLinkGroupByFields).fetchLazy();
    Iterator<Iterator<DependencyLinkSpan>> traces = new DependencyLinkSpanIterator.ByTraceId(cursor.iterator(), schema.hasTraceIdHigh);
    if (!traces.hasNext())
        return Collections.emptyList();
    DependencyLinker linker = new DependencyLinker();
    while (traces.hasNext()) {
        linker.putTrace(traces.next());
    }
    return linker.link();
}
Also used : GroupByTraceId(zipkin.internal.GroupByTraceId) DependencyLinker(zipkin.internal.DependencyLinker) Iterator(java.util.Iterator) Record(org.jooq.Record)

Example 2 with DependencyLinker

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

the class InMemorySpanStore method getDependencies.

@Override
public List<DependencyLink> getDependencies(long endTs, @Nullable Long lookback) {
    QueryRequest request = QueryRequest.builder().endTs(endTs).lookback(lookback).limit(Integer.MAX_VALUE).build();
    DependencyLinker linksBuilder = new DependencyLinker();
    for (Collection<Span> trace : getTraces(request)) {
        linksBuilder.putTrace(trace);
    }
    return linksBuilder.link();
}
Also used : DependencyLinker(zipkin.internal.DependencyLinker) Span(zipkin.Span)

Aggregations

DependencyLinker (zipkin.internal.DependencyLinker)2 Iterator (java.util.Iterator)1 Record (org.jooq.Record)1 Span (zipkin.Span)1 GroupByTraceId (zipkin.internal.GroupByTraceId)1