Search in sources :

Example 6 with SpanId

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)));
}
Also used : SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Example 7 with SpanId

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);
}
Also used : SpanId(io.opencensus.trace.SpanId) Test(org.junit.Test)

Example 8 with SpanId

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());
}
Also used : SpanId(io.opencensus.trace.SpanId)

Example 9 with SpanId

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());
}
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) 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 10 with SpanId

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);
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) 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