use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusTxTracingTest method testCloseTransaction.
/**
* <ol>
* <li>Run some transaction with some label.</li>
* <li>Call two puts inside the transaction.</li>
* <li>Close given transaction.</li>
* </ol>
*
* Check that got trace is equal to:
* transaction
* transactions.near.enlist.write
* transactions.close
*
* <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 testCloseTransaction() 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.close();
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);
checkSpan(TX_CLOSE, txSpanIds.get(0), 1, null);
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusTxTracingTest method testPessimisticRepeatableReadTxTracing.
/**
* <ol>
* <li>Run pessimistic 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.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 testPessimisticRepeatableReadTxTracing() throws Exception {
IgniteEx client = startGrid("client");
Transaction tx = client.transactions().withLabel("label1").txStart(PESSIMISTIC, 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", PESSIMISTIC.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);
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);
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlJdbcTracingTest method testSelectLocal.
/**
* Tests tracing of local SQL SELECT query.
*
* @throws Exception If failed.
*/
@Test
public void testSelectLocal() throws Exception {
String orgTable = createTableAndPopulate(Organization.class, REPLICATED, 1);
SpanId rootSpan = executeAndCheckRootSpan("SELECT orgVal FROM " + orgTable, TEST_SCHEMA, false, false, true);
String qryId = getAttribute(rootSpan, SQL_QRY_ID);
assertTrue(Long.parseLong(qryId.substring(qryId.indexOf('_') + 1)) > 0);
UUID.fromString(qryId.substring(0, qryId.indexOf('_')));
checkChildSpan(SQL_QRY_PARSE, rootSpan);
checkChildSpan(SQL_CURSOR_OPEN, rootSpan);
checkChildSpan(SQL_ITER_OPEN, rootSpan);
SpanId iterSpan = checkChildSpan(SQL_ITER_OPEN, rootSpan);
checkChildSpan(SQL_QRY_EXECUTE, iterSpan);
int fetchedRows = findChildSpans(SQL_PAGE_FETCH, rootSpan).stream().mapToInt(span -> Integer.parseInt(getAttribute(span, SQL_PAGE_ROWS))).sum();
assertEquals(TEST_TABLE_POPULATION, fetchedRows);
checkChildSpan(SQL_ITER_CLOSE, rootSpan);
assertFalse(findChildSpans(SQL_CURSOR_CLOSE, rootSpan).isEmpty());
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlJdbcTracingTest method testCopy.
/**
* Test SQL bulk load query tracing.
*/
@Test
public void testCopy() throws Exception {
ignite(0).tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(SQL).build(), new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_NEVER).build());
String table = "test_table";
executeQuery("CREATE TABLE " + table + "(id LONG PRIMARY KEY, first_name VARCHAR, last_name VARCHAR, age LONG)", DFLT_SCHEMA, false, false, null);
ignite(0).tracingConfiguration().set(new TracingConfigurationCoordinates.Builder(SQL).build(), new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).build());
SpanId rootSpan = executeAndCheckRootSpan("COPY FROM '" + BULKLOAD_FILE + "' INTO " + table + "(id, age, first_name, last_name) FORMAT csv", DFLT_SCHEMA, false, false, false);
checkChildSpan(SQL_QRY_PARSE, rootSpan);
checkChildSpan(SQL_CMD_QRY_EXECUTE, rootSpan);
checkSpan(SQL_BATCH_PROCESS, rootSpan, BULKLOAD_ENTRIES, null);
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlJdbcTracingTest method testSelectQueryUserThreadSpanNotAffected.
/**
* {@inheritDoc}
*/
@Override
public void testSelectQueryUserThreadSpanNotAffected() throws Exception {
String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
String orgTable = createTableAndPopulate(Organization.class, PARTITIONED, 1);
String url = JDBC_URL_PREFIX + Config.SERVER + '/' + TEST_SCHEMA;
try (Connection prsntConn = getConnection(url);
Connection orgConn = getConnection(url);
PreparedStatement prsntStmt = prsntConn.prepareStatement("SELECT * FROM " + prsnTable);
PreparedStatement orgStmt = orgConn.prepareStatement("SELECT * FROM " + orgTable)) {
prsntStmt.executeQuery();
orgStmt.executeQuery();
try (ResultSet prsnResultSet = prsntStmt.getResultSet();
ResultSet orgResultSet = orgStmt.getResultSet()) {
while (prsnResultSet.next() && orgResultSet.next()) {
// No-op.
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
handler().flush();
checkDroppedSpans();
List<SpanId> rootSpans = findRootSpans(SQL_QRY);
assertEquals(2, rootSpans.size());
for (SpanId rootSpan : rootSpans) checkBasicSelectQuerySpanTree(rootSpan, TEST_TABLE_POPULATION);
}
Aggregations