use of org.apache.ignite.internal.processors.tracing.SpanType.CUSTOM_JOB_CALL in project ignite by apache.
the class OpenCensusTracingSpiTest method testCommunicationMessages.
/**
* @throws Exception if failed.
*/
@Test
public void testCommunicationMessages() throws Exception {
IgniteEx ignite = grid(0);
IgniteEx ignite1 = grid(1);
try (MTC.TraceSurroundings ignore = MTC.support(ignite.context().tracing().create(CUSTOM_JOB_CALL))) {
ignite.compute(ignite.cluster().forNode(ignite1.localNode())).withNoFailover().call(() -> "");
}
handler().flush();
SpanData jobSpan = handler().spanByName(CUSTOM_JOB_CALL.spanName());
List<SpanData> data = handler().unrollByParent(jobSpan);
List<AttributeValue> nodejobMsgTags = data.stream().filter(it -> it.getAttributes().getAttributeMap().containsKey(SpanTags.MESSAGE)).map(it -> it.getAttributes().getAttributeMap().get(SpanTags.MESSAGE)).collect(Collectors.toList());
List<String> nodejobTraces = data.stream().map(SpanData::getName).collect(Collectors.toList());
assertEquals(nodejobTraces.toString(), 7, nodejobTraces.size());
assertEquals(1, nodejobTraces.stream().filter(it -> it.contains(CUSTOM_JOB_CALL.spanName())).count());
List<SpanData> sockWriteTraces = data.stream().filter(span -> span.getName().contains(COMMUNICATION_SOCKET_WRITE.spanName())).collect(Collectors.toList());
// request + response
assertEquals(2, sockWriteTraces.size());
sockWriteTraces.forEach(span -> assertTrue(parseInt(attributeValueToString(span.getAttributes().getAttributeMap().get(SOCKET_WRITE_BYTES))) > 0));
// request + response
assertEquals(2, nodejobTraces.stream().filter(it -> it.contains(COMMUNICATION_SOCKET_READ.spanName())).count());
// request + response
assertEquals(2, nodejobTraces.stream().filter(it -> it.contains(COMMUNICATION_REGULAR_PROCESS.spanName())).count());
assertTrue(nodejobMsgTags.stream().anyMatch(it -> it.equals(stringAttributeValue(COMMUNICATION_JOB_EXECUTE_REQUEST.spanName()))));
assertTrue(nodejobMsgTags.stream().anyMatch(it -> it.equals(stringAttributeValue(COMMUNICATION_JOB_EXECUTE_RESPONSE.spanName()))));
}
Aggregations