use of zipkin2.DependencyLink in project zipkin by openzipkin.
the class InternalForTests method writeDependencyLinks.
static void writeDependencyLinks(CassandraStorage storage, List<DependencyLink> links, long midnightUTC) {
CqlSession session = storage.session();
PreparedStatement prepared = session.prepare("INSERT INTO " + Schema.TABLE_DEPENDENCY + " (day,parent,child,calls,errors)" + " VALUES (?,?,?,?,?)");
LocalDate day = Instant.ofEpochMilli(midnightUTC).atZone(ZoneOffset.UTC).toLocalDate();
for (DependencyLink link : links) {
int i = 0;
storage.session().execute(prepared.bind().setLocalDate(i++, day).setString(i++, link.parent()).setString(i++, link.child()).setLong(i++, link.callCount()).setLong(i, link.errorCount()));
}
}
use of zipkin2.DependencyLink in project zipkin by openzipkin.
the class InternalForTests method writeDependencyLinks.
public static void writeDependencyLinks(ElasticsearchStorage es, List<DependencyLink> links, long midnightUTC) {
String index = ((ElasticsearchSpanConsumer) es.spanConsumer()).formatTypeAndTimestampForInsert("dependency", midnightUTC);
BulkCallBuilder indexer = new BulkCallBuilder(es, es.version(), "indexlinks");
for (DependencyLink link : links) indexer.index(index, "dependency", link, DEPENDENCY_LINK_WRITER);
try {
indexer.build().execute();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of zipkin2.DependencyLink in project zipkin by openzipkin.
the class KryoTest method kryoJavaSerialization_dependencyLink.
@Test
public void kryoJavaSerialization_dependencyLink() {
Kryo kryo = new Kryo();
kryo.register(DependencyLink.class, new JavaSerializer());
DependencyLink link = DependencyLink.newBuilder().parent("client").child("server").callCount(2L).errorCount(23L).build();
Output output = new Output(4096);
kryo.writeObject(output, link);
output.flush();
byte[] serialized = output.getBuffer();
assertThat(kryo.readObject(new Input(serialized), DependencyLink.class)).isEqualTo(link);
}
use of zipkin2.DependencyLink in project zipkin by openzipkin.
the class ITMySQLStorage method aggregateDependencies.
static void aggregateDependencies(MySQLStorage storage, List<zipkin2.Span> spans) throws SQLException {
try (Connection conn = storage.datasource.getConnection()) {
DSLContext context = storage.context.get(conn);
// batch insert the rows at timestamp midnight
List<Query> inserts = new ArrayList<>();
aggregateLinks(spans).forEach((midnight, links) -> {
LocalDate day = Instant.ofEpochMilli(midnight).atZone(ZoneId.of("UTC")).toLocalDate();
for (DependencyLink link : links) {
inserts.add(context.insertInto(ZIPKIN_DEPENDENCIES).set(ZIPKIN_DEPENDENCIES.DAY, day).set(ZIPKIN_DEPENDENCIES.PARENT, link.parent()).set(ZIPKIN_DEPENDENCIES.CHILD, link.child()).set(ZIPKIN_DEPENDENCIES.CALL_COUNT, link.callCount()).set(ZIPKIN_DEPENDENCIES.ERROR_COUNT, link.errorCount()).onDuplicateKeyIgnore());
}
});
context.batch(inserts).execute();
}
}
use of zipkin2.DependencyLink in project zipkin by openzipkin.
the class ITDependenciesHeavy method manyLinks.
/**
* Ensure there's no query limit problem around links
*/
@Test
protected void manyLinks() throws Exception {
// Larger than 10, which is the default ES search limit that tripped this
int count = 1000;
List<Span> spans = new ArrayList<>(count);
for (int i = 1; i <= count; i++) {
String traceId = newTraceId();
Endpoint web = FRONTEND.toBuilder().serviceName("web-" + i).build();
Endpoint app = BACKEND.toBuilder().serviceName("app-" + i).build();
Endpoint db = DB.toBuilder().serviceName("db-" + i).build();
spans.add(Span.newBuilder().traceId(traceId).id("10").name("get").timestamp((TODAY + 50L) * 1000L).duration(250L * 1000L).kind(Kind.CLIENT).localEndpoint(web).build());
spans.add(Span.newBuilder().traceId(traceId).id("10").name("get").shared(true).timestamp((TODAY + 100) * 1000L).duration(150 * 1000L).kind(Kind.SERVER).localEndpoint(app).build());
spans.add(Span.newBuilder().traceId(traceId).parentId("10").id("11").name("get").timestamp((TODAY + 150L) * 1000L).duration(50L * 1000L).kind(Kind.CLIENT).localEndpoint(app).remoteEndpoint(db).build());
}
processDependencies(spans);
List<DependencyLink> links = store().getDependencies(endTs(spans), DAY).execute();
// web-? -> app-?, app-? -> db-?
assertThat(links).hasSize(count * 2);
assertThat(links).extracting(DependencyLink::callCount).allSatisfy(callCount -> assertThat(callCount).isEqualTo(1));
}
Aggregations