Search in sources :

Example 1 with SOCKET_WRITE_BYTES

use of org.apache.ignite.internal.processors.tracing.SpanTags.SOCKET_WRITE_BYTES 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()))));
}
Also used : DISCOVERY_NODE_LEFT(org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_LEFT) AttributeValue(io.opencensus.trace.AttributeValue) COMMUNICATION_REGULAR_PROCESS(org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_REGULAR_PROCESS) SOCKET_WRITE_BYTES(org.apache.ignite.internal.processors.tracing.SpanTags.SOCKET_WRITE_BYTES) COMMUNICATION_JOB_EXECUTE_REQUEST(org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_JOB_EXECUTE_REQUEST) CUSTOM_JOB_CALL(org.apache.ignite.internal.processors.tracing.SpanType.CUSTOM_JOB_CALL) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteFeatures(org.apache.ignite.internal.IgniteFeatures) SpanData(io.opencensus.trace.export.SpanData) OpenCensusTracingSpi(org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi) COMMUNICATION_SOCKET_READ(org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_READ) Map(java.util.Map) DISCOVERY_NODE_JOIN_ADD(org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_JOIN_ADD) TracingConfigurationCoordinates(org.apache.ignite.spi.tracing.TracingConfigurationCoordinates) DISCOVERY_NODE_JOIN_REQUEST(org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_JOIN_REQUEST) EXCHANGE_FUTURE(org.apache.ignite.internal.processors.tracing.SpanType.EXCHANGE_FUTURE) Status(io.opencensus.trace.Status) EventType(org.apache.ignite.events.EventType) SpanTags(org.apache.ignite.internal.processors.tracing.SpanTags) DISCOVERY_NODE_JOIN_FINISH(org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_JOIN_FINISH) Scope(org.apache.ignite.spi.tracing.Scope) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Integer.parseInt(java.lang.Integer.parseInt) COMMUNICATION_SOCKET_WRITE(org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_WRITE) DISCOVERY_CUSTOM_EVENT(org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_CUSTOM_EVENT) List(java.util.List) COMMUNICATION_JOB_EXECUTE_RESPONSE(org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_JOB_EXECUTE_RESPONSE) SAMPLING_RATE_ALWAYS(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS) MTC(org.apache.ignite.internal.processors.tracing.MTC) TracingConfigurationParameters(org.apache.ignite.spi.tracing.TracingConfigurationParameters) TracingSpi(org.apache.ignite.spi.tracing.TracingSpi) Assert(org.junit.Assert) AttributeValue.stringAttributeValue(io.opencensus.trace.AttributeValue.stringAttributeValue) AttributeValue(io.opencensus.trace.AttributeValue) AttributeValue.stringAttributeValue(io.opencensus.trace.AttributeValue.stringAttributeValue) SpanData(io.opencensus.trace.export.SpanData) IgniteEx(org.apache.ignite.internal.IgniteEx) MTC(org.apache.ignite.internal.processors.tracing.MTC) Test(org.junit.Test)

Aggregations

AttributeValue (io.opencensus.trace.AttributeValue)1 AttributeValue.stringAttributeValue (io.opencensus.trace.AttributeValue.stringAttributeValue)1 Status (io.opencensus.trace.Status)1 SpanData (io.opencensus.trace.export.SpanData)1 Integer.parseInt (java.lang.Integer.parseInt)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 EventType (org.apache.ignite.events.EventType)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 IgniteFeatures (org.apache.ignite.internal.IgniteFeatures)1 MTC (org.apache.ignite.internal.processors.tracing.MTC)1 SpanTags (org.apache.ignite.internal.processors.tracing.SpanTags)1 SOCKET_WRITE_BYTES (org.apache.ignite.internal.processors.tracing.SpanTags.SOCKET_WRITE_BYTES)1 COMMUNICATION_JOB_EXECUTE_REQUEST (org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_JOB_EXECUTE_REQUEST)1 COMMUNICATION_JOB_EXECUTE_RESPONSE (org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_JOB_EXECUTE_RESPONSE)1 COMMUNICATION_REGULAR_PROCESS (org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_REGULAR_PROCESS)1 COMMUNICATION_SOCKET_READ (org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_READ)1 COMMUNICATION_SOCKET_WRITE (org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_WRITE)1 CUSTOM_JOB_CALL (org.apache.ignite.internal.processors.tracing.SpanType.CUSTOM_JOB_CALL)1