Search in sources :

Example 21 with SpanId

use of io.opencensus.trace.SpanId in project ignite by apache.

the class OpenCensusTxTracingTest method testPessimisticReadCommittedTxTracing.

/**
 * <ol>
 *     <li>Run pessimistic read-committed transaction with some label.</li>
 *     <li>Call two puts inside the transaction.</li>
 *     <li>Commit given transaction.</li>
 * </ol>
 *
 * Check that got trace is equal to:
 *  transaction
 *      transactions.near.enlist.write
 *      transactions.colocated.lock.map
 *      transactions.commit
 *          transactions.near.prepare
 *              tx.near.process.prepare.request
 *                  transactions.dht.prepare
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.near.process.prepare.response
 *              transactions.near.finish
 *                  tx.near.process.finish.request
 *                      transactions.dht.finish
 *                          tx.dht.process.finish.req
 *                          tx.dht.process.finish.req
 *                      tx.near.process.finish.response
 *
 *   <p>
 *   Also check that root transaction span contains following tags:
 *   <ol>
 *       <li>node.id</li>
 *       <li>node.consistent.id</li>
 *       <li>node.name</li>
 *       <li>concurrency</li>
 *       <li>isolation</li>
 *       <li>timeout</li>
 *       <li>label</li>
 *   </ol>
 */
@Test
public void testPessimisticReadCommittedTxTracing() throws Exception {
    IgniteEx client = startGrid("client");
    Transaction tx = client.transactions().withLabel("label1").txStart(PESSIMISTIC, READ_COMMITTED);
    client.cache(DEFAULT_CACHE_NAME).put(1, 1);
    tx.commit();
    handler().flush();
    List<SpanId> txSpanIds = checkSpan(TX, null, 1, ImmutableMap.<String, String>builder().put("node.id", client.localNode().id().toString()).put("node.consistent.id", client.localNode().consistentId().toString()).put("node.name", client.name()).put("concurrency", PESSIMISTIC.name()).put("isolation", READ_COMMITTED.name()).put("timeout", String.valueOf(0)).put("label", "label1").build());
    checkSpan(TX_NEAR_ENLIST_WRITE, txSpanIds.get(0), 1, null);
    checkSpan(TX_COLOCATED_LOCK_MAP, txSpanIds.get(0), 1, null);
    List<SpanId> commitSpanIds = checkSpan(TX_COMMIT, txSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareSpanIds = checkSpan(TX_NEAR_PREPARE, commitSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareReqSpanIds = checkSpan(TX_NEAR_PREPARE_REQ, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareSpanIds = checkSpan(TX_DHT_PREPARE, txNearPrepareReqSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareReqSpanIds = checkSpan(TX_PROCESS_DHT_PREPARE_REQ, txDhtPrepareSpanIds.get(0), 2, null);
    for (SpanId parentSpanId : txDhtPrepareReqSpanIds) {
        checkSpan(TX_PROCESS_DHT_PREPARE_RESP, parentSpanId, 1, null);
    }
    checkSpan(TX_NEAR_PREPARE_RESP, txDhtPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishSpanIds = checkSpan(TX_NEAR_FINISH, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishReqSpanIds = checkSpan(TX_NEAR_FINISH_REQ, txNearFinishSpanIds.get(0), 1, null);
    List<SpanId> txDhtFinishSpanIds = checkSpan(TX_DHT_FINISH, txNearFinishReqSpanIds.get(0), 1, null);
    checkSpan(TX_PROCESS_DHT_FINISH_REQ, txDhtFinishSpanIds.get(0), 2, null);
    checkSpan(TX_NEAR_FINISH_RESP, txNearFinishReqSpanIds.get(0), 1, null);
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Example 22 with SpanId

use of io.opencensus.trace.SpanId in project ignite by apache.

the class OpenCensusTxTracingTest method testOptimisticReadCommittedTxTracing.

/**
 * <ol>
 *     <li>Run optimistic read-committed transaction with some label.</li>
 *     <li>Call two puts inside the transaction.</li>
 *     <li>Commit given transaction.</li>
 * </ol>
 *
 * Check that got trace is equal to:
 *  transaction
 *      transactions.near.enlist.write
 *      transactions.commit
 *          transactions.near.prepare
 *              tx.near.process.prepare.request
 *                  transactions.dht.prepare
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.near.process.prepare.response
 *              transactions.near.finish
 *                  tx.near.process.finish.request
 *                      transactions.dht.finish
 *                          tx.dht.process.finish.req
 *                          tx.dht.process.finish.req
 *                      tx.near.process.finish.response
 *
 *   <p>
 *   Also check that root transaction span contains following tags:
 *   <ol>
 *       <li>node.id</li>
 *       <li>node.consistent.id</li>
 *       <li>node.name</li>
 *       <li>concurrency</li>
 *       <li>isolation</li>
 *       <li>timeout</li>
 *       <li>label</li>
 *   </ol>
 */
@Test
public void testOptimisticReadCommittedTxTracing() throws Exception {
    IgniteEx client = startGrid("client");
    Transaction tx = client.transactions().withLabel("label1").txStart(OPTIMISTIC, READ_COMMITTED);
    client.cache(DEFAULT_CACHE_NAME).put(1, 1);
    tx.commit();
    handler().flush();
    List<SpanId> txSpanIds = checkSpan(TX, null, 1, ImmutableMap.<String, String>builder().put("node.id", client.localNode().id().toString()).put("node.consistent.id", client.localNode().consistentId().toString()).put("node.name", client.name()).put("concurrency", OPTIMISTIC.name()).put("isolation", READ_COMMITTED.name()).put("timeout", String.valueOf(0)).put("label", "label1").build());
    checkSpan(TX_NEAR_ENLIST_WRITE, txSpanIds.get(0), 1, null);
    List<SpanId> commitSpanIds = checkSpan(TX_COMMIT, txSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareSpanIds = checkSpan(TX_NEAR_PREPARE, commitSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareReqSpanIds = checkSpan(TX_NEAR_PREPARE_REQ, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareSpanIds = checkSpan(TX_DHT_PREPARE, txNearPrepareReqSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareReqSpanIds = checkSpan(TX_PROCESS_DHT_PREPARE_REQ, txDhtPrepareSpanIds.get(0), 2, null);
    for (SpanId parentSpanId : txDhtPrepareReqSpanIds) {
        checkSpan(TX_PROCESS_DHT_PREPARE_RESP, parentSpanId, 1, null);
    }
    checkSpan(TX_NEAR_PREPARE_RESP, txDhtPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishSpanIds = checkSpan(TX_NEAR_FINISH, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishReqSpanIds = checkSpan(TX_NEAR_FINISH_REQ, txNearFinishSpanIds.get(0), 1, null);
    List<SpanId> txDhtFinishSpanIds = checkSpan(TX_DHT_FINISH, txNearFinishReqSpanIds.get(0), 1, null);
    checkSpan(TX_PROCESS_DHT_FINISH_REQ, txDhtFinishSpanIds.get(0), 2, null);
    checkSpan(TX_NEAR_FINISH_RESP, txNearFinishReqSpanIds.get(0), 1, null);
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Example 23 with SpanId

use of io.opencensus.trace.SpanId in project ignite by apache.

the class OpenCensusTxTracingTest method testOptimisticSerializableTxTracing.

/**
 * <ol>
 *     <li>Run optimistic serializable transaction with some label.</li>
 *     <li>Call two puts inside the transaction.</li>
 *     <li>Commit given transaction.</li>
 * </ol>
 *
 * Check that got trace is equal to:
 *  transaction
 *      transactions.near.enlist.write
 *      transactions.commit
 *          transactions.near.prepare
 *              tx.near.process.prepare.request
 *                  transactions.dht.prepare
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.near.process.prepare.response
 *              transactions.near.finish
 *                  tx.near.process.finish.request
 *                      transactions.dht.finish
 *                          tx.dht.process.finish.req
 *                          tx.dht.process.finish.req
 *                      tx.near.process.finish.response
 *
 *   <p>
 *   Also check that root transaction span contains following tags:
 *   <ol>
 *       <li>node.id</li>
 *       <li>node.consistent.id</li>
 *       <li>node.name</li>
 *       <li>concurrency</li>
 *       <li>isolation</li>
 *       <li>timeout</li>
 *       <li>label</li>
 *   </ol>
 */
@Test
public void testOptimisticSerializableTxTracing() throws Exception {
    IgniteEx client = startGrid("client");
    Transaction tx = client.transactions().withLabel("label1").txStart(OPTIMISTIC, SERIALIZABLE);
    client.cache(DEFAULT_CACHE_NAME).put(1, 1);
    tx.commit();
    handler().flush();
    List<SpanId> txSpanIds = checkSpan(TX, null, 1, ImmutableMap.<String, String>builder().put("node.id", client.localNode().id().toString()).put("node.consistent.id", client.localNode().consistentId().toString()).put("node.name", client.name()).put("concurrency", OPTIMISTIC.name()).put("isolation", SERIALIZABLE.name()).put("timeout", String.valueOf(0)).put("label", "label1").build());
    checkSpan(TX_NEAR_ENLIST_WRITE, txSpanIds.get(0), 1, null);
    List<SpanId> commitSpanIds = checkSpan(TX_COMMIT, txSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareSpanIds = checkSpan(TX_NEAR_PREPARE, commitSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareReqSpanIds = checkSpan(TX_NEAR_PREPARE_REQ, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareSpanIds = checkSpan(TX_DHT_PREPARE, txNearPrepareReqSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareReqSpanIds = checkSpan(TX_PROCESS_DHT_PREPARE_REQ, txDhtPrepareSpanIds.get(0), 2, null);
    for (SpanId parentSpanId : txDhtPrepareReqSpanIds) {
        checkSpan(TX_PROCESS_DHT_PREPARE_RESP, parentSpanId, 1, null);
    }
    checkSpan(TX_NEAR_PREPARE_RESP, txDhtPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishSpanIds = checkSpan(TX_NEAR_FINISH, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishReqSpanIds = checkSpan(TX_NEAR_FINISH_REQ, txNearFinishSpanIds.get(0), 1, null);
    List<SpanId> txDhtFinishSpanIds = checkSpan(TX_DHT_FINISH, txNearFinishReqSpanIds.get(0), 1, null);
    checkSpan(TX_PROCESS_DHT_FINISH_REQ, txDhtFinishSpanIds.get(0), 2, null);
    checkSpan(TX_NEAR_FINISH_RESP, txNearFinishReqSpanIds.get(0), 1, null);
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Example 24 with SpanId

use of io.opencensus.trace.SpanId in project ignite by apache.

the class OpenCensusTxTracingTest method testOptimisticRepeatableReadTxTracing.

/**
 * <ol>
 *     <li>Run optimistic repeatable-read transaction with some label.</li>
 *     <li>Call two puts inside the transaction.</li>
 *     <li>Commit given transaction.</li>
 * </ol>
 *
 * Check that got trace is equal to:
 *  transaction
 *      transactions.near.enlist.write
 *      transactions.commit
 *          transactions.near.prepare
 *              tx.near.process.prepare.request
 *                  transactions.dht.prepare
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.dht.process.prepare.req
 *                          tx.dht.process.prepare.response
 *                      tx.near.process.prepare.response
 *              transactions.near.finish
 *                  tx.near.process.finish.request
 *                      transactions.dht.finish
 *                          tx.dht.process.finish.req
 *                          tx.dht.process.finish.req
 *                      tx.near.process.finish.response
 *
 *   <p>
 *   Also check that root transaction span contains following tags:
 *   <ol>
 *       <li>node.id</li>
 *       <li>node.consistent.id</li>
 *       <li>node.name</li>
 *       <li>concurrency</li>
 *       <li>isolation</li>
 *       <li>timeout</li>
 *       <li>label</li>
 *   </ol>
 */
@Test
public void testOptimisticRepeatableReadTxTracing() throws Exception {
    IgniteEx client = startGrid("client");
    Transaction tx = client.transactions().withLabel("label1").txStart(OPTIMISTIC, REPEATABLE_READ);
    client.cache(DEFAULT_CACHE_NAME).put(1, 1);
    tx.commit();
    handler().flush();
    List<SpanId> txSpanIds = checkSpan(TX, null, 1, ImmutableMap.<String, String>builder().put("node.id", client.localNode().id().toString()).put("node.consistent.id", client.localNode().consistentId().toString()).put("node.name", client.name()).put("concurrency", OPTIMISTIC.name()).put("isolation", REPEATABLE_READ.name()).put("timeout", String.valueOf(0)).put("label", "label1").build());
    checkSpan(TX_NEAR_ENLIST_WRITE, txSpanIds.get(0), 1, null);
    List<SpanId> commitSpanIds = checkSpan(TX_COMMIT, txSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareSpanIds = checkSpan(TX_NEAR_PREPARE, commitSpanIds.get(0), 1, null);
    List<SpanId> txNearPrepareReqSpanIds = checkSpan(TX_NEAR_PREPARE_REQ, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareSpanIds = checkSpan(TX_DHT_PREPARE, txNearPrepareReqSpanIds.get(0), 1, null);
    List<SpanId> txDhtPrepareReqSpanIds = checkSpan(TX_PROCESS_DHT_PREPARE_REQ, txDhtPrepareSpanIds.get(0), 2, null);
    for (SpanId parentSpanId : txDhtPrepareReqSpanIds) {
        checkSpan(TX_PROCESS_DHT_PREPARE_RESP, parentSpanId, 1, null);
    }
    checkSpan(TX_NEAR_PREPARE_RESP, txDhtPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishSpanIds = checkSpan(TX_NEAR_FINISH, txNearPrepareSpanIds.get(0), 1, null);
    List<SpanId> txNearFinishReqSpanIds = checkSpan(TX_NEAR_FINISH_REQ, txNearFinishSpanIds.get(0), 1, null);
    List<SpanId> txDhtFinishSpanIds = checkSpan(TX_DHT_FINISH, txNearFinishReqSpanIds.get(0), 1, null);
    checkSpan(TX_PROCESS_DHT_FINISH_REQ, txDhtFinishSpanIds.get(0), 2, null);
    checkSpan(TX_NEAR_FINISH_RESP, txNearFinishReqSpanIds.get(0), 1, null);
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Example 25 with SpanId

use of io.opencensus.trace.SpanId in project ignite by apache.

the class OpenCensusSqlNativeTracingTest method testUpdateWithReducerSkipped.

/**
 * Tests tracing of UPDATE query with skipped reduce phase.
 *
 * @throws Exception If failed.
 */
@Test
public void testUpdateWithReducerSkipped() throws Exception {
    String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
    SpanId rootSpan = executeAndCheckRootSpan("UPDATE " + prsnTable + " SET prsnVal = (prsnVal + 1)", TEST_SCHEMA, true, false, false);
    checkChildSpan(SQL_QRY_PARSE, rootSpan);
    SpanId dmlExecSpan = checkChildSpan(SQL_DML_QRY_EXECUTE, rootSpan);
    List<SpanId> execReqSpans = checkSpan(SQL_DML_QRY_EXEC_REQ, dmlExecSpan, GRID_CNT, null);
    int fetchedRows = 0;
    int cacheUpdates = 0;
    assertEquals(GRID_CNT, execReqSpans.size());
    for (int i = 0; i < GRID_CNT; i++) {
        SpanId execReqSpan = execReqSpans.get(i);
        checkChildSpan(SQL_PARTITIONS_RESERVE, execReqSpan);
        checkSpan(SQL_QRY_PARSE, execReqSpan, 2, null);
        SpanId iterSpan = checkChildSpan(SQL_ITER_OPEN, execReqSpan);
        checkChildSpan(SQL_QRY_EXECUTE, iterSpan);
        fetchedRows += findChildSpans(SQL_PAGE_FETCH, execReqSpan).stream().mapToInt(span -> parseInt(getAttribute(span, SQL_PAGE_ROWS))).sum();
        List<SpanId> cacheUpdateSpans = findChildSpans(SQL_CACHE_UPDATE, execReqSpan);
        cacheUpdates += cacheUpdateSpans.stream().mapToInt(span -> parseInt(getAttribute(span, SQL_CACHE_UPDATES))).sum();
        checkChildSpan(SQL_ITER_CLOSE, execReqSpan);
        checkChildSpan(SQL_DML_QRY_RESP, execReqSpan);
    }
    assertEquals(TEST_TABLE_POPULATION, fetchedRows);
    assertEquals(TEST_TABLE_POPULATION, cacheUpdates);
}
Also used : SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Aggregations

SpanId (io.opencensus.trace.SpanId)31 Test (org.junit.Test)21 IgniteEx (org.apache.ignite.internal.IgniteEx)14 Transaction (org.apache.ignite.transactions.Transaction)10 TraceId (io.opencensus.trace.TraceId)6 TracingConfigurationParameters (org.apache.ignite.spi.tracing.TracingConfigurationParameters)6 TraceOptions (io.opencensus.trace.TraceOptions)5 TracingConfigurationCoordinates (org.apache.ignite.spi.tracing.TracingConfigurationCoordinates)5 SAMPLING_RATE_ALWAYS (org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS)5 SpanData (io.opencensus.trace.export.SpanData)4 SpanContextParseException (io.opencensus.trace.propagation.SpanContextParseException)4 Arrays (java.util.Arrays)4 List (java.util.List)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 SpanType (org.apache.ignite.internal.processors.tracing.SpanType)4 TracingSpi (org.apache.ignite.spi.tracing.TracingSpi)4 OpenCensusTracingSpi (org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi)4 Timestamp (io.opencensus.common.Timestamp)3 SpanContext (io.opencensus.trace.SpanContext)3