use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlNativeTracingTest method testParserCacheHitTag.
/**
* Tests SQL parser cache hit tag.
*/
@Test
public void testParserCacheHitTag() throws Exception {
String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
SpanId rootSpan = executeAndCheckRootSpan("SELECT * FROM " + prsnTable, TEST_SCHEMA, false, false, true);
SpanId qryParseSpan = checkChildSpan(SQL_QRY_PARSE, rootSpan);
assertFalse(parseBoolean(getAttribute(qryParseSpan, SQL_PARSER_CACHE_HIT)));
handler().clearCollectedSpans();
rootSpan = executeAndCheckRootSpan("SELECT * FROM " + prsnTable, TEST_SCHEMA, false, false, true);
qryParseSpan = checkChildSpan(SQL_QRY_PARSE, rootSpan);
assertTrue(parseBoolean(getAttribute(qryParseSpan, SQL_PARSER_CACHE_HIT)));
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlNativeTracingTest method testCreateTable.
/**
* Tests tracing of the CREATE TABLE command execution.
*/
@Test
public void testCreateTable() throws Exception {
SpanId rootSpan = executeAndCheckRootSpan("CREATE TABLE test_table(id INT PRIMARY KEY, val VARCHAR)", DFLT_SCHEMA, false, false, null);
checkChildSpan(SQL_QRY_PARSE, rootSpan);
checkChildSpan(SQL_CMD_QRY_EXECUTE, rootSpan);
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlNativeTracingTest method checkBasicSelectQuerySpanTree.
/**
* Checks presence of basic spans that related to SELECT SQL query and are childs of the specfied span.
*
* @param expRows Number of rows as a result of SELECT query.
* @param rootSpan Span which childs will be checked.
*/
protected void checkBasicSelectQuerySpanTree(SpanId rootSpan, int expRows) {
int fetchedRows = 0;
String qryId = getAttribute(rootSpan, SQL_QRY_ID);
assertTrue(Long.parseLong(qryId.substring(qryId.indexOf('_') + 1)) > 0);
SpanId iterSpan = checkChildSpan(SQL_ITER_OPEN, rootSpan);
SpanId fetchSpan = checkChildSpan(SQL_PAGE_FETCH, iterSpan);
fetchedRows += parseInt(getAttribute(fetchSpan, SQL_PAGE_ROWS));
List<SpanId> pageFetchSpans = findChildSpans(SQL_PAGE_FETCH, rootSpan);
for (SpanId span : pageFetchSpans) fetchedRows += parseInt(getAttribute(span, SQL_PAGE_ROWS));
assertEquals(expRows, fetchedRows);
assertFalse(findChildSpans(SQL_CURSOR_CLOSE, rootSpan).isEmpty());
}
use of io.opencensus.trace.SpanId 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());
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusTxTracingTest method testPessimisticSerializableTxTracing.
/**
* <ol>
* <li>Run pessimistic 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.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 testPessimisticSerializableTxTracing() throws Exception {
IgniteEx client = startGrid("client");
Transaction tx = client.transactions().withLabel("label1").txStart(PESSIMISTIC, 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", PESSIMISTIC.name()).put("isolation", SERIALIZABLE.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);
}
Aggregations