use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlNativeTracingTest method checkDmlQuerySpans.
/**
* Executes DML query and checks corresponding span tree.
*
* @param qry SQL query to execute.
* @param fetchRequired Whether query need to fetch data before cache update.
*/
private void checkDmlQuerySpans(String qry, boolean fetchRequired, int expCacheUpdates) throws Exception {
SpanId rootSpan = executeAndCheckRootSpan(qry, TEST_SCHEMA, false, false, false);
checkChildSpan(SQL_QRY_PARSE, rootSpan);
SpanId dmlExecSpan = checkChildSpan(SQL_DML_QRY_EXECUTE, rootSpan);
if (fetchRequired) {
checkChildSpan(SQL_ITER_OPEN, dmlExecSpan);
int fetchedRows = findChildSpans(SQL_PAGE_FETCH, null).stream().mapToInt(span -> parseInt(getAttribute(span, SQL_PAGE_ROWS))).sum();
assertEquals(expCacheUpdates, fetchedRows);
}
int cacheUpdates = findChildSpans(SQL_CACHE_UPDATE, dmlExecSpan).stream().mapToInt(span -> parseInt(getAttribute(span, SQL_CACHE_UPDATES))).sum();
assertEquals(expCacheUpdates, cacheUpdates);
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlNativeTracingTest method testNextPageRequestFailure.
/**
* Tests tracing of the SQL query next page request failure.
*
* @throws Exception If failed.
*/
@Test
@SuppressWarnings("Convert2MethodRef")
public void testNextPageRequestFailure() throws Exception {
String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
IgniteEx qryInitiator = reducer();
spi(qryInitiator).blockMessages((node, msg) -> msg instanceof GridQueryNextPageRequest);
IgniteInternalFuture<?> iterFut = runAsync(() -> executeQuery("SELECT * FROM " + prsnTable, TEST_SCHEMA, false, false, true));
spi(qryInitiator).waitForBlocked(mapNodesCount());
qryInitiator.context().query().runningQueries(-1).iterator().next().cancel();
spi(qryInitiator).stopBlock();
GridTestUtils.assertThrowsWithCause(() -> iterFut.get(), IgniteCheckedException.class);
handler().flush();
checkDroppedSpans();
SpanId rootSpan = checkChildSpan(SQL_QRY, null);
SpanId cursorCancelSpan = checkChildSpan(SQL_CURSOR_CANCEL, rootSpan);
SpanId cursorCloseSpan = checkChildSpan(SQL_CURSOR_CLOSE, cursorCancelSpan);
SpanId iterCloseSpan = checkChildSpan(SQL_ITER_CLOSE, cursorCloseSpan);
checkSpan(SQL_QRY_CANCEL_REQ, iterCloseSpan, mapNodesCount(), null);
List<SpanId> pageFetchSpans = findChildSpans(SQL_PAGE_FETCH, rootSpan);
for (SpanId pageFetchSpan : pageFetchSpans) {
List<SpanId> nextPageReqSpans = findChildSpans(SQL_NEXT_PAGE_REQ, pageFetchSpan);
if (!nextPageReqSpans.isEmpty()) {
assertEquals(1, nextPageReqSpans.size());
checkChildSpan(SQL_FAIL_RESP, nextPageReqSpans.get(0));
}
}
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusSqlNativeTracingTest method testSelectWithParallelism.
/**
* Tests tracing of SELECT query with parallelism.
*
* @throws Exception If failed.
*/
@Test
public void testSelectWithParallelism() throws Exception {
int qryParallelism = 2;
String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, qryParallelism);
SpanId rootSpan = executeAndCheckRootSpan("SELECT * FROM " + prsnTable, TEST_SCHEMA, false, false, true);
SpanId iterOpenSpan = checkChildSpan(SQL_ITER_OPEN, rootSpan);
List<SpanId> qryExecSpans = findChildSpans(SQL_QRY_EXEC_REQ, iterOpenSpan);
assertEquals(GRID_CNT * qryParallelism, qryExecSpans.size());
}
use of io.opencensus.trace.SpanId 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());
}
use of io.opencensus.trace.SpanId in project ignite by apache.
the class OpenCensusTxTracingTest method testRollbackTransaction.
/**
* <ol>
* <li>Run some transaction with some label.</li>
* <li>Call two puts inside the transaction.</li>
* <li>Rollback given transaction.</li>
* </ol>
*
* Check that got trace is equal to:
* transaction
* transactions.near.enlist.write
* transactions.rollback
*
* <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 testRollbackTransaction() 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.rollback();
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_ROLLBACK, txSpanIds.get(0), 1, null);
}
Aggregations