Search in sources :

Example 41 with SpanData

use of io.opencensus.trace.export.SpanData in project ignite by apache.

the class OpenCensusTracingSpiTest method testCustomEventContainsMessageClassTag.

/**
 * Ensure that root discovery.custom.event have message.class with corresponding value.
 *
 * @throws Exception If failed.
 */
@Test
public void testCustomEventContainsMessageClassTag() throws Exception {
    IgniteEx ignite = grid(0);
    startGrid(GRID_CNT).createCache("New cache");
    handler().flush();
    // Only root discovery.custom.event spans have message.class tag.
    List<SpanData> rootCustomEvtSpans = handler().allSpans().filter(spanData -> DISCOVERY_CUSTOM_EVENT.spanName().equals(spanData.getName()) && spanData.getParentSpanId() == null).collect(Collectors.toList());
    // Check that there's at least one discovery.custom.event span with tag "message.class"
    // and value "CacheAffinityChangeMessage"
    assertTrue(rootCustomEvtSpans.stream().anyMatch(span -> "CacheAffinityChangeMessage".equals(attributeValueToString(span.getAttributes().getAttributeMap().get(SpanTags.MESSAGE_CLASS)))));
}
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) SpanData(io.opencensus.trace.export.SpanData) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test)

Example 42 with SpanData

use of io.opencensus.trace.export.SpanData in project ignite by apache.

the class OpenCensusTxTracingConfigurationTest method testTxTraceIncludesCommunicationTracesInCaseOfCommunicationScopeInTxIncludedScopes.

/**
 * Ensure that TX trace does include COMMUNICATION sub-traces in case of COMMUNICATION scope within the set
 * of included scopes of the corresponding TX tracing configuration.
 *
 * @throws Exception If Failed.
 */
@Test
public void testTxTraceIncludesCommunicationTracesInCaseOfCommunicationScopeInTxIncludedScopes() throws Exception {
    IgniteEx client = startGrid("client");
    client.tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(TX).build(), new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).withIncludedScopes(Collections.singleton(Scope.COMMUNICATION)).build());
    Transaction tx = client.transactions().txStart(PESSIMISTIC, SERIALIZABLE);
    client.cache(DEFAULT_CACHE_NAME).put(1, 1);
    tx.commit();
    handler().flush();
    SpanId parentSpanId = handler().allSpans().filter(span -> SpanType.TX_NEAR_PREPARE.spanName().equals(span.getName())).collect(Collectors.toList()).get(0).getContext().getSpanId();
    java.util.List<SpanData> gotSpans = handler().allSpans().filter(span -> parentSpanId.equals(span.getParentSpanId()) && SpanType.COMMUNICATION_SOCKET_WRITE.spanName().equals(span.getName())).collect(Collectors.toList());
    assertFalse(gotSpans.isEmpty());
}
Also used : Arrays(java.util.Arrays) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) SpanType(org.apache.ignite.internal.processors.tracing.SpanType) Transaction(org.apache.ignite.transactions.Transaction) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) Scope(org.apache.ignite.spi.tracing.Scope) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SpanData(io.opencensus.trace.export.SpanData) OpenCensusTracingSpi(org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi) TX(org.apache.ignite.spi.tracing.Scope.TX) SAMPLING_RATE_ALWAYS(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS) TracingConfigurationParameters(org.apache.ignite.spi.tracing.TracingConfigurationParameters) TracingSpi(org.apache.ignite.spi.tracing.TracingSpi) SpanId(io.opencensus.trace.SpanId) SAMPLING_RATE_NEVER(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) Collections(java.util.Collections) TracingConfigurationCoordinates(org.apache.ignite.spi.tracing.TracingConfigurationCoordinates) Transaction(org.apache.ignite.transactions.Transaction) SpanData(io.opencensus.trace.export.SpanData) IgniteEx(org.apache.ignite.internal.IgniteEx) SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Example 43 with SpanData

use of io.opencensus.trace.export.SpanData in project ignite by apache.

the class OpenCensusTxTracingConfigurationTest method testThatLabelSpecificConfigurationIsUsedWheneverPossible.

/**
 * Ensure that label specific configuration is used instead of scope specific if it's possible.
 *
 * @throws Exception If Failed.
 */
@Test
public void testThatLabelSpecificConfigurationIsUsedWheneverPossible() throws Exception {
    IgniteEx client = startGrid("client");
    final String txLbToBeTraced = "label1";
    final String txLbNotToBeTraced = "label2";
    client.tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(TX).withLabel(txLbToBeTraced).build(), new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).build());
    client.transactions().withLabel(txLbToBeTraced).txStart(PESSIMISTIC, SERIALIZABLE).commit();
    handler().flush();
    java.util.List<SpanData> gotSpans = handler().allSpans().filter(span -> SpanType.TX.spanName().equals(span.getName())).collect(Collectors.toList());
    assertEquals(1, gotSpans.size());
    // Not to be traced, cause there's neither tracing configuration with given label
    // nor scope specific tx configuration. In that case default tx tracing configuration will be used that
    // actually disables tracing.
    client.transactions().withLabel(txLbNotToBeTraced).txStart(PESSIMISTIC, SERIALIZABLE).commit();
    handler().flush();
    gotSpans = handler().allSpans().filter(span -> SpanType.TX.spanName().equals(span.getName())).collect(Collectors.toList());
    // Still only one, previously detected, span is expected.
    assertEquals(1, gotSpans.size());
}
Also used : Arrays(java.util.Arrays) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) SpanType(org.apache.ignite.internal.processors.tracing.SpanType) Transaction(org.apache.ignite.transactions.Transaction) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) Scope(org.apache.ignite.spi.tracing.Scope) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SpanData(io.opencensus.trace.export.SpanData) OpenCensusTracingSpi(org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi) TX(org.apache.ignite.spi.tracing.Scope.TX) SAMPLING_RATE_ALWAYS(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS) TracingConfigurationParameters(org.apache.ignite.spi.tracing.TracingConfigurationParameters) TracingSpi(org.apache.ignite.spi.tracing.TracingSpi) SpanId(io.opencensus.trace.SpanId) SAMPLING_RATE_NEVER(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) Collections(java.util.Collections) TracingConfigurationCoordinates(org.apache.ignite.spi.tracing.TracingConfigurationCoordinates) TracingConfigurationParameters(org.apache.ignite.spi.tracing.TracingConfigurationParameters) SpanData(io.opencensus.trace.export.SpanData) IgniteEx(org.apache.ignite.internal.IgniteEx) TracingConfigurationCoordinates(org.apache.ignite.spi.tracing.TracingConfigurationCoordinates) Test(org.junit.Test)

Example 44 with SpanData

use of io.opencensus.trace.export.SpanData in project ignite by apache.

the class OpenCensusTxTracingConfigurationTest method testThatDefaultConfigurationIsUsedIfScopeSpecificNotFoundAndThatByDefaultTxTracingIsDisabled.

/**
 * Ensure that default scope specific configuration is used if there's no neither label specif not custom scope specific ones.
 * Also ensure that by default TX tracing is disabled.
 *
 * @throws Exception If Failed.
 */
@Test
public void testThatDefaultConfigurationIsUsedIfScopeSpecificNotFoundAndThatByDefaultTxTracingIsDisabled() throws Exception {
    IgniteEx client = startGrid("client");
    client.transactions().withLabel("label1").txStart(PESSIMISTIC, SERIALIZABLE).commit();
    handler().flush();
    java.util.List<SpanData> gotSpans = handler().allSpans().filter(span -> SpanType.TX.spanName().equals(span.getName())).collect(Collectors.toList());
    assertTrue(gotSpans.isEmpty());
}
Also used : Arrays(java.util.Arrays) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) SpanType(org.apache.ignite.internal.processors.tracing.SpanType) Transaction(org.apache.ignite.transactions.Transaction) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) Scope(org.apache.ignite.spi.tracing.Scope) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SpanData(io.opencensus.trace.export.SpanData) OpenCensusTracingSpi(org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi) TX(org.apache.ignite.spi.tracing.Scope.TX) SAMPLING_RATE_ALWAYS(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS) TracingConfigurationParameters(org.apache.ignite.spi.tracing.TracingConfigurationParameters) TracingSpi(org.apache.ignite.spi.tracing.TracingSpi) SpanId(io.opencensus.trace.SpanId) SAMPLING_RATE_NEVER(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) Collections(java.util.Collections) TracingConfigurationCoordinates(org.apache.ignite.spi.tracing.TracingConfigurationCoordinates) SpanData(io.opencensus.trace.export.SpanData) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test)

Example 45 with SpanData

use of io.opencensus.trace.export.SpanData in project ignite by apache.

the class OpenCensusTxTracingConfigurationTest method testTxConfigurationSamplingRateNeverPreventsTxTracing.

/**
 * Ensure that in case of sampling rate equals to 0.0 (Never) no transactions are traced.
 *
 * @throws Exception If Failed.
 */
@Test
public void testTxConfigurationSamplingRateNeverPreventsTxTracing() throws Exception {
    IgniteEx client = startGrid("client");
    client.tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(TX).build(), new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_NEVER).build());
    client.transactions().txStart(PESSIMISTIC, SERIALIZABLE).commit();
    handler().flush();
    Set<String> unexpectedTxSpanNames = Arrays.stream(SpanType.values()).filter(spanType -> spanType.scope() == TX).map(SpanType::spanName).collect(Collectors.toSet());
    java.util.List<SpanData> gotSpans = handler().allSpans().filter(span -> unexpectedTxSpanNames.contains(span.getName())).collect(Collectors.toList());
    assertTrue(gotSpans.isEmpty());
}
Also used : Arrays(java.util.Arrays) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) SpanType(org.apache.ignite.internal.processors.tracing.SpanType) Transaction(org.apache.ignite.transactions.Transaction) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) Scope(org.apache.ignite.spi.tracing.Scope) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SpanData(io.opencensus.trace.export.SpanData) OpenCensusTracingSpi(org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi) TX(org.apache.ignite.spi.tracing.Scope.TX) SAMPLING_RATE_ALWAYS(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS) TracingConfigurationParameters(org.apache.ignite.spi.tracing.TracingConfigurationParameters) TracingSpi(org.apache.ignite.spi.tracing.TracingSpi) SpanId(io.opencensus.trace.SpanId) SAMPLING_RATE_NEVER(org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) Collections(java.util.Collections) TracingConfigurationCoordinates(org.apache.ignite.spi.tracing.TracingConfigurationCoordinates) TracingConfigurationParameters(org.apache.ignite.spi.tracing.TracingConfigurationParameters) SpanData(io.opencensus.trace.export.SpanData) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test)

Aggregations

SpanData (io.opencensus.trace.export.SpanData)86 Test (org.junit.Test)74 RecordEventsSpanImpl (io.opencensus.implcore.trace.RecordEventsSpanImpl)18 Link (io.opencensus.trace.Link)17 AttributeValue (io.opencensus.trace.AttributeValue)13 Collectors (java.util.stream.Collectors)13 Scope (org.apache.ignite.spi.tracing.Scope)13 TracingConfigurationCoordinates (org.apache.ignite.spi.tracing.TracingConfigurationCoordinates)13 TracingConfigurationParameters (org.apache.ignite.spi.tracing.TracingConfigurationParameters)13 TracingSpi (org.apache.ignite.spi.tracing.TracingSpi)13 IgniteEx (org.apache.ignite.internal.IgniteEx)12 SAMPLING_RATE_ALWAYS (org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS)12 OpenCensusTracingSpi (org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi)12 SpanId (io.opencensus.trace.SpanId)11 Collections (java.util.Collections)9 SpanType (org.apache.ignite.internal.processors.tracing.SpanType)9 TX (org.apache.ignite.spi.tracing.Scope.TX)9 ArrayList (java.util.ArrayList)8 Arrays (java.util.Arrays)8 Set (java.util.Set)8