Search in sources :

Example 6 with SERIALIZABLE

use of org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE in project ignite by apache.

the class OpenCensusTxTracingConfigurationTest method testTxConfigurationSamplingRateAlwaysEnablesTxTracing.

/**
 * Ensure that in case of sampling rate equals to 1.0 (Always) transactions are successfully traced.
 *
 * @throws Exception If Failed.
 */
@Test
public void testTxConfigurationSamplingRateAlwaysEnablesTxTracing() throws Exception {
    IgniteEx client = startGrid("client");
    client.tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(TX).build(), new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).build());
    client.transactions().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());
}
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)

Example 7 with SERIALIZABLE

use of org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE in project ignite by apache.

the class OpenCensusTxTracingConfigurationTest method testTxTraceDoesNotIncludeCommunicationTracesInCaseOfEmptyIncludedScopes.

/**
 * Ensure that TX traces doesn't include COMMUNICATION sub-traces in case of empty set of included scopes.
 *
 * @throws Exception If Failed.
 */
@Test
public void testTxTraceDoesNotIncludeCommunicationTracesInCaseOfEmptyIncludedScopes() throws Exception {
    IgniteEx client = startGrid("client");
    client.tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(TX).build(), new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).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());
    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) 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 8 with SERIALIZABLE

use of org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE in project ignite by apache.

the class OpenCensusTxTracingConfigurationTest method testTxConfigurationSamplingRateHalfSamplesSomethingAboutHalfTransactions.

/**
 * Ensure that specifying 0 < sapling rate < 1 within TX scope will trace some but not all transactions.
 * Cause of probability nature of sampling, it's not possible to check that 0.5 sampling rate
 * will result in exactly half of the transactions being traced.
 *
 * @throws Exception If Failed.
 */
@Test
public void testTxConfigurationSamplingRateHalfSamplesSomethingAboutHalfTransactions() throws Exception {
    IgniteEx client = startGrid("client");
    client.tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(TX).build(), new TracingConfigurationParameters.Builder().withSamplingRate(0.5).build());
    final int txAmount = 100;
    for (int i = 0; i < txAmount; i++) client.transactions().txStart(PESSIMISTIC, SERIALIZABLE).commit();
    handler().flush();
    java.util.List<SpanData> gotSpans = handler().allSpans().filter(span -> SpanType.TX.spanName().equals(span.getName())).collect(Collectors.toList());
    // Cause of probability nature of sampling, it's not possible to check that 0.5 sampling rate will end with
    // 5 sampling transactions out of {@code txAmount},
    // so we just check that some and not all transactions were traced.
    assertTrue(!gotSpans.isEmpty() && gotSpans.size() < txAmount);
}
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

SpanId (io.opencensus.trace.SpanId)8 SpanData (io.opencensus.trace.export.SpanData)8 Arrays (java.util.Arrays)8 Collections (java.util.Collections)8 Set (java.util.Set)8 Collectors (java.util.stream.Collectors)8 IgniteEx (org.apache.ignite.internal.IgniteEx)8 SpanType (org.apache.ignite.internal.processors.tracing.SpanType)8 Scope (org.apache.ignite.spi.tracing.Scope)8 TX (org.apache.ignite.spi.tracing.Scope.TX)8 TracingConfigurationCoordinates (org.apache.ignite.spi.tracing.TracingConfigurationCoordinates)8 TracingConfigurationParameters (org.apache.ignite.spi.tracing.TracingConfigurationParameters)8 SAMPLING_RATE_ALWAYS (org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS)8 SAMPLING_RATE_NEVER (org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER)8 TracingSpi (org.apache.ignite.spi.tracing.TracingSpi)8 OpenCensusTracingSpi (org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi)8 Transaction (org.apache.ignite.transactions.Transaction)8 PESSIMISTIC (org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC)8 SERIALIZABLE (org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE)8 Test (org.junit.Test)8