From 14b7c953adf54257e35b83175064ec7231c278d5 Mon Sep 17 00:00:00 2001
From: Mikhail Petrov
Date: Tue, 21 Jul 2026 12:16:48 +0300
Subject: [PATCH 1/2] IGNITE-28910 Ignite Tracing public API was deprecated and
internal implementation was removed
---
checkstyle/checkstyle-suppressions.xml | 3 -
docs/_data/toc.yaml | 2 -
docs/_docs/code-snippets/java/pom.xml | 5 -
.../org/apache/ignite/snippets/Tracing.java | 110 --
docs/_docs/code-snippets/xml/tracing.xml | 45 -
docs/_docs/key-value-api/transactions.adoc | 2 -
docs/_docs/monitoring-metrics/tracing.adoc | 240 ----
docs/_docs/tools/control-script.adoc | 66 -
.../jmh/misc/JmhTracingContextBenchmark.java | 108 --
.../org/apache/ignite/spi/tracing/Scope.java | 4 +
.../CommandHandlerParsingTest.java | 184 ---
.../IgniteControlUtilityTestSuite2.java | 3 -
.../GridCommandHandlerClusterByClassTest.java | 1 -
...ommandHandlerTracingConfigurationTest.java | 394 ------
.../main/java/org/apache/ignite/Ignite.java | 3 +
.../org/apache/ignite/IgniteTransactions.java | 5 +-
.../configuration/IgniteConfiguration.java | 18 +-
.../apache/ignite/events/DiscoveryEvent.java | 22 -
.../ignite/internal/GridKernalContext.java | 8 -
.../internal/GridKernalContextImpl.java | 14 -
.../ignite/internal/IgniteComponentType.java | 7 -
.../apache/ignite/internal/IgniteKernal.java | 19 +-
.../apache/ignite/internal/IgnitionEx.java | 4 -
.../management/IgniteCommandRegistry.java | 2 -
.../AbstractTracingConfigurationCommand.java | 49 -
.../tracing/TracingConfigurationCommand.java | 90 --
.../TracingConfigurationGetAllCommand.java | 31 -
.../TracingConfigurationGetAllCommandArg.java | 61 -
.../TracingConfigurationGetCommand.java | 31 -
.../TracingConfigurationGetCommandArg.java | 76 --
.../tracing/TracingConfigurationItem.java | 150 ---
.../TracingConfigurationResetAllCommand.java | 37 -
.../TracingConfigurationResetCommand.java | 36 -
.../TracingConfigurationSetCommand.java | 34 -
.../TracingConfigurationSetCommandArg.java | 66 -
.../tracing/TracingConfigurationTask.java | 214 ----
.../TracingConfigurationTaskResult.java | 91 --
.../managers/communication/GridIoManager.java | 112 +-
.../managers/communication/GridIoMessage.java | 19 +-
.../managers/communication/TraceRunnable.java | 63 -
.../discovery/GridDiscoveryManager.java | 33 +-
.../managers/tracing/GridTracingManager.java | 541 --------
.../bulkload/BulkLoadProcessor.java | 36 +-
.../cache/CacheAffinitySharedManager.java | 7 -
.../GridCachePartitionExchangeManager.java | 24 -
.../processors/cache/GridCacheProcessor.java | 2 +-
.../distributed/dht/GridDhtLockFuture.java | 68 +-
.../dht/GridDhtTxFinishFuture.java | 104 +-
.../dht/GridDhtTxPrepareFuture.java | 220 ++--
.../colocated/GridDhtColocatedLockFuture.java | 136 +--
.../GridDhtPartitionsExchangeFuture.java | 47 -
.../topology/PartitionReservationManager.java | 71 +-
...OptimisticSerializableTxPrepareFuture.java | 44 +-
.../GridNearOptimisticTxPrepareFuture.java | 125 +-
...dNearOptimisticTxPrepareFutureAdapter.java | 55 +-
.../GridNearPessimisticTxPrepareFuture.java | 70 +-
.../near/GridNearTxFinishFuture.java | 133 +-
.../distributed/near/GridNearTxLocal.java | 799 ++++++------
.../reader/StandaloneGridKernalContext.java | 7 -
.../transactions/IgniteTransactionsImpl.java | 28 +-
.../cache/transactions/IgniteTxHandler.java | 504 ++++----
.../transactions/TransactionProxyImpl.java | 200 ++-
.../query/running/GridRunningQueryInfo.java | 13 -
.../query/running/RunningQueryManager.java | 159 ++-
.../processors/tracing/DeferredSpan.java | 91 --
.../processors/tracing/NoopTracing.java | 49 -
.../internal/processors/tracing/SpanImpl.java | 104 --
.../processors/tracing/TraceableIterator.java | 66 -
.../internal/processors/tracing/Tracing.java | 45 -
.../DistributedTracingConfiguration.java | 56 -
.../GridTracingConfigurationManager.java | 222 ----
.../NoopTracingConfigurationManager.java | 6 +-
.../tracing/messages/SpanContainer.java | 82 --
.../tracing/messages/TraceableMessage.java | 28 -
.../messages/TraceableMessagesHandler.java | 106 --
.../messages/TraceableMessagesTable.java | 88 --
.../internal/tracing/TracingSpiType.java | 48 -
.../tcp/TcpCommunicationSpi.java | 4 -
.../tcp/internal/GridNioServerWrapper.java | 14 -
.../internal/InboundConnectionHandler.java | 9 -
.../TcpCommunicationConfigInitializer.java | 7 -
.../spi/discovery/DiscoveryNotification.java | 16 +-
.../isolated/IsolatedDiscoverySpi.java | 6 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 104 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 237 +---
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 10 -
.../TcpDiscoveryAbstractTraceableMessage.java | 95 --
.../TcpDiscoveryCustomEventMessage.java | 2 +-
.../TcpDiscoveryJoinRequestMessage.java | 2 +-
.../TcpDiscoveryNodeAddFinishedMessage.java | 3 +-
.../TcpDiscoveryNodeAddedMessage.java | 2 +-
.../TcpDiscoveryNodeFailedMessage.java | 2 +-
.../messages/TcpDiscoveryNodeLeftMessage.java | 2 +-
.../spi/tracing/NoopSpiSpecificSpan.java | 4 +
.../ignite/spi/tracing/NoopTracingSpi.java | 7 +-
.../ignite/spi/tracing/SpiSpecificSpan.java | 4 +
.../TracingConfigurationCoordinates.java | 26 +
.../tracing/TracingConfigurationManager.java | 4 +
.../TracingConfigurationParameters.java | 31 +-
.../apache/ignite/spi/tracing/TracingSpi.java | 4 +
.../TestRecordingCommunicationSpi.java | 20 +-
.../ClientSlowDiscoveryAbstractTest.java | 2 -
...shallerCacheClientRequestsMappingTest.java | 4 -
...IgniteSequentialNodeCrashRecoveryTest.java | 2 -
.../IncrementalSnapshotJoiningClientTest.java | 2 -
.../schema/IndexWithSameNameTestBase.java | 2 -
.../discovery/tcp/BlockTcpDiscoverySpi.java | 2 -
.../discovery/tcp/TcpDiscoverySelfTest.java | 2 -
...mmandHandlerClusterByClassTest_help.output | 66 -
...ndlerClusterByClassWithSSLTest_help.output | 66 -
.../processors/query/h2/CommandProcessor.java | 2 +-
.../processors/query/h2/H2FieldsIterator.java | 7 +-
.../query/h2/H2ResultSetIterator.java | 25 +-
.../processors/query/h2/IgniteH2Indexing.java | 182 ++-
.../processors/query/h2/QueryParser.java | 16 +-
.../query/h2/RegisteredQueryCursor.java | 61 +-
.../query/h2/database/H2TreeIndex.java | 181 ++-
.../query/h2/dml/DmlBatchSender.java | 35 +-
.../processors/query/h2/dml/DmlUtils.java | 39 +-
.../query/h2/twostep/AbstractReducer.java | 53 +-
.../h2/twostep/GridMapQueryExecutor.java | 233 ++--
.../h2/twostep/GridReduceQueryExecutor.java | 106 +-
.../query/h2/twostep/ReduceIndexIterator.java | 17 +-
.../internal/processors/tracing/MTC.java | 114 --
.../internal/processors/tracing/NoopSpan.java | 74 --
.../processors/tracing/NoopSpanManager.java | 58 -
.../internal/processors/tracing/Span.java | 85 --
.../processors/tracing/SpanManager.java | 80 --
.../internal/processors/tracing/SpanTags.java | 127 --
.../internal/processors/tracing/SpanType.java | 329 -----
.../tracing/messages/SpanTransport.java | 35 -
.../internal/util/nio/GridNioServer.java | 160 +--
.../util/nio/GridNioTracerFilter.java | 126 --
.../util/nio/GridSelectorNioSessionImpl.java | 14 -
.../util/nio/SessionWriteRequest.java | 8 -
modules/opencensus/pom.xml | 13 -
.../exporter/trace/TimeLimitedHandler.java | 146 ---
.../opencensus/OpenCensusSpanAdapter.java | 82 --
.../opencensus/OpenCensusTraceExporter.java | 68 --
.../opencensus/OpenCensusTracingSpi.java | 159 ---
.../tracing/opencensus/StatusMatchTable.java | 56 -
.../spi/tracing/opencensus/package-info.java | 22 -
.../TracingConfigurationValidationTest.java | 122 --
.../opencensus/AbstractTracingTest.java | 507 --------
.../opencensus/IgniteOpenCensusSuite.java | 15 +-
.../opencensus/MixedTracingSpiTest.java | 126 --
.../OpenCensusDiscoveryTracingTest.java | 339 ------
.../OpenCensusSqlJdbcTracingTest.java | 222 ----
.../OpenCensusSqlNativeTracingTest.java | 787 ------------
...nCensusTracingConfigurationGetAllTest.java | 106 --
...OpenCensusTracingConfigurationGetTest.java | 149 ---
...ensusTracingConfigurationResetAllTest.java | 98 --
...enCensusTracingConfigurationResetTest.java | 154 ---
.../opencensus/OpenCensusTracingSpiTest.java | 374 ------
.../OpenCensusTxTracingConfigurationTest.java | 294 -----
.../opencensus/OpenCensusTxTracingTest.java | 1084 -----------------
.../zk/internal/ZookeeperDiscoveryImpl.java | 10 +-
157 files changed, 1823 insertions(+), 12886 deletions(-)
delete mode 100644 docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Tracing.java
delete mode 100644 docs/_docs/code-snippets/xml/tracing.xml
delete mode 100644 docs/_docs/monitoring-metrics/tracing.adoc
delete mode 100644 modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/misc/JmhTracingContextBenchmark.java
delete mode 100644 modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTracingConfigurationTest.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/AbstractTracingConfigurationCommand.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationCommand.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationGetAllCommand.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationGetAllCommandArg.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationGetCommand.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationGetCommandArg.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationItem.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationResetAllCommand.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationResetCommand.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationSetCommand.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationSetCommandArg.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationTask.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/management/tracing/TracingConfigurationTaskResult.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/managers/communication/TraceRunnable.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/managers/tracing/GridTracingManager.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/DeferredSpan.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/NoopTracing.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/SpanImpl.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/TraceableIterator.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/Tracing.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/configuration/DistributedTracingConfiguration.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/configuration/GridTracingConfigurationManager.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/messages/SpanContainer.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/messages/TraceableMessage.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/messages/TraceableMessagesHandler.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/messages/TraceableMessagesTable.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/tracing/TracingSpiType.java
delete mode 100644 modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/MTC.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpan.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpanManager.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/Span.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanManager.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanTags.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanType.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/messages/SpanTransport.java
delete mode 100644 modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
delete mode 100644 modules/opencensus/src/main/java/io/opencensus/exporter/trace/TimeLimitedHandler.java
delete mode 100644 modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusSpanAdapter.java
delete mode 100644 modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTraceExporter.java
delete mode 100644 modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTracingSpi.java
delete mode 100644 modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/StatusMatchTable.java
delete mode 100644 modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/package-info.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/TracingConfigurationValidationTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/AbstractTracingTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/MixedTracingSpiTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusDiscoveryTracingTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlJdbcTracingTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlNativeTracingTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetAllTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetAllTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingSpiTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingConfigurationTest.java
delete mode 100644 modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingTest.java
diff --git a/checkstyle/checkstyle-suppressions.xml b/checkstyle/checkstyle-suppressions.xml
index 9a40f8d4b725a..0b6d14c332dc4 100644
--- a/checkstyle/checkstyle-suppressions.xml
+++ b/checkstyle/checkstyle-suppressions.xml
@@ -60,9 +60,6 @@
-
-
diff --git a/docs/_data/toc.yaml b/docs/_data/toc.yaml
index e8a6eefc570b6..11cd73ae1c9eb 100644
--- a/docs/_data/toc.yaml
+++ b/docs/_data/toc.yaml
@@ -450,8 +450,6 @@
url: monitoring-metrics/system-views
- title: Performance Statistics
url: monitoring-metrics/performance-statistics
- - title: Tracing
- url: monitoring-metrics/tracing
- title: Working with Events
items:
- title: Enabling and Listenting to Events
diff --git a/docs/_docs/code-snippets/java/pom.xml b/docs/_docs/code-snippets/java/pom.xml
index a67910da040b2..6f8f739ee2a4b 100644
--- a/docs/_docs/code-snippets/java/pom.xml
+++ b/docs/_docs/code-snippets/java/pom.xml
@@ -100,11 +100,6 @@
${project.groupId}ignite-opencensus
-
- io.opencensus
- opencensus-exporter-trace-zipkin
- 0.31.1
- ${project.groupId}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Tracing.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Tracing.java
deleted file mode 100644
index d62ee3f04c20b..0000000000000
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Tracing.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ignite.snippets;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteTransactions;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.transactions.Transaction;
-import org.junit.jupiter.api.Test;
-
-import io.opencensus.exporter.trace.zipkin.ZipkinExporterConfiguration;
-import io.opencensus.exporter.trace.zipkin.ZipkinTraceExporter;
-
-public class Tracing {
-
- @Test
- void config() {
- //tag::config[]
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- cfg.setTracingSpi(new org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi());
-
- Ignite ignite = Ignition.start(cfg);
- //end::config[]
-
- ignite.close();
- }
-
- @Test
- void enableSampling() {
- //tag::enable-sampling[]
- Ignite ignite = Ignition.start();
-
- ignite.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(Scope.TX).build(),
- new TracingConfigurationParameters.Builder().withSamplingRate(1).build());
-
- //end::enable-sampling[]
- ignite.close();
- }
-
- void exportToZipkin() {
- //tag::export-to-zipkin[]
- //register Zipkin exporter
- ZipkinTraceExporter.createAndRegister(
- ZipkinExporterConfiguration.builder().setV2Url("http://localhost:9411/api/v2/spans")
- .setServiceName("ignite-cluster").build());
-
- IgniteConfiguration cfg = new IgniteConfiguration().setClientMode(true)
- .setTracingSpi(new org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi());
-
- Ignite ignite = Ignition.start(cfg);
-
- //enable trace sampling for transactions with 100% sampling rate
- ignite.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(Scope.TX).build(),
- new TracingConfigurationParameters.Builder().withSamplingRate(1).build());
-
- //create a transactional cache
- IgniteCache cache = ignite
- .getOrCreateCache(new CacheConfiguration("myCache")
- .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
-
- IgniteTransactions transactions = ignite.transactions();
-
- // start a transaction
- try (Transaction tx = transactions.txStart()) {
- //do some operations
- cache.put(1, "test value");
-
- System.out.println(cache.get(1));
-
- cache.put(1, "second value");
-
- tx.commit();
- }
-
- try {
- //This code here is to wait until the trace is exported to Zipkin.
- //If your application doesn't stop here, you don't need this piece of code.
- Thread.sleep(5_000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- //end::export-to-zipkin[]
- ignite.close();
- }
-}
diff --git a/docs/_docs/code-snippets/xml/tracing.xml b/docs/_docs/code-snippets/xml/tracing.xml
deleted file mode 100644
index ff510719879e4..0000000000000
--- a/docs/_docs/code-snippets/xml/tracing.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 127.0.0.1:47500..47509
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/_docs/key-value-api/transactions.adoc b/docs/_docs/key-value-api/transactions.adoc
index 646691a09e3ee..2297e1e9a2502 100644
--- a/docs/_docs/key-value-api/transactions.adoc
+++ b/docs/_docs/key-value-api/transactions.adoc
@@ -357,6 +357,4 @@ tab:C++[unsupported]
Refer to the link:monitoring-metrics/new-metrics-system#monitoring-transactions[Monitoring Transactions] section for the list of metrics that expose some transaction-related information.
-For the information on how to trace transactions, refer to the link:monitoring-metrics/tracing[Tracing] section.
-
You can also use the link:tools/control-script#transaction-management[control script] to get information about, or cancel, specific transactions being executed in the cluster.
diff --git a/docs/_docs/monitoring-metrics/tracing.adoc b/docs/_docs/monitoring-metrics/tracing.adoc
deleted file mode 100644
index aa10768058036..0000000000000
--- a/docs/_docs/monitoring-metrics/tracing.adoc
+++ /dev/null
@@ -1,240 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-= Tracing
-
-:javaFile: {javaCodeDir}/Tracing.java
-
-A number of APIs in Ignite are instrumented for tracing with OpenCensus.
-You can collect distributed traces of various tasks executed in your cluster and use this information to diagnose latency problems.
-
-We suggest you get familiar with OpenCensus tracing documentation before reading this chapter: https://opencensus.io/tracing/[^].
-
-The following Ignite APIs are instrumented for tracing:
-
-* Discovery
-* Communication
-* Exchange
-* Transactions
-* SQL queries
-
-
-To view traces, you must export them into an external system.
-You can use one of the OpenCensus exporters or write your own, but in any case, you will have to write code that registers an exporter in Ignite.
-Refer to <> for details.
-
-
-== Configuring Tracing
-
-Enable OpenCensus tracing in the node configuration. All nodes in the cluster must use the same tracing configuration.
-
-[tabs]
---
-tab:XML[]
-[source, xml]
-----
-include::code-snippets/xml/tracing.xml[tags=ignite-config;!discovery, indent=0]
-----
-
-tab:Java[]
-[source, java]
-----
-include::{javaFile}[tags=config, indent=0]
-----
-tab:C#/.NET[]
-
-tab:C++[unsupported]
---
-
-
-== Enabling Trace Sampling
-
-When you start your cluster with the above configuration, Ignite does not collect traces.
-You have to enable trace sampling for a specific API at runtime.
-You can turn trace sampling on and off at will, for example, only for the period when you are troubleshooting a problem.
-
-You can do this in two ways:
-
-* via the control script from the command line
-* programmatically
-
-Traces are collected at a given probabilistic sampling rate.
-The rate is specified as a value between 0.0 and 1.0 inclusive: `0` means no sampling, `1` means always sampling.
-
-When the sampling rate is set to a value greater than 0, Ignite collects traces.
-To disable trace collection, set the sampling rate to 0.
-
-The following sections describe the two ways of enabling trace sampling.
-
-=== Using Control Script
-
-Go to the `{IGNITE_HOME}/bin` directory of your Ignite installation.
-
-Enable tracing for a specific API:
-
-[source, shell]
-----
-./control.sh --tracing-configuration set --scope TX --sampling-rate 1
-----
-
-Refer to the link:tools/control-script#tracing-configuration[Control Script] sections for the list of all parameters.
-
-=== Programmatically
-
-Once you start the node, you can enable trace sampling as follows:
-
-[source, java]
-----
-include::{javaFile}[tags=enable-sampling, indent=0]
-----
-
-
-The `--scope` parameter specifies the API you want to trace.
-The following APIs are instrumented for tracing:
-
-* `DISCOVERY` — discovery events
-* `EXCHANGE` — exchange events
-* `COMMUNICATION` — communication events
-* `TX` — transactions
-* `SQL` — SQL queries
-
-The `--sampling-rate` is the probabilistic sampling rate, a number between `0` and `1`:
-
-* `0` means no sampling,
-* `1` means always sampling.
-
-
-== Exporting Traces
-
-To view traces, you need to export them to an external backend using one of the available exporters.
-OpenCensus supports a number of exporters out-of-the-box, and you can write a custom one.
-Refer to the link:https://opencensus.io/exporters/[OpenCensus Exporters^] for details.
-
-In this section, we will show how to export traces to link:https://zipkin.io[Zipkin^].
-
-. Follow link:https://zipkin.io/pages/quickstart.html[this guide^] to launch Zipkin on your machine.
-. Register `ZipkinTraceExporter` in the application where you start Ignite:
-+
---
-[source, java]
-----
-include::{javaFile}[tags=export-to-zipkin, indent=0]
-----
---
-
-
-. Open http://localhost:9411/zipkin[^] in your browser and click the search icon.
-+
---
-This is what a trace of the transaction looks like:
-
-image::images/trace_in_zipkin.png[]
---
-
-== Analyzing Trace Data
-
-A trace is recorded information about the execution of a specific event.
-Each trace consists of a tree of _spans_.
-A span is an individual unit of work performed by the system in order to process the event.
-
-Because of the distributed nature of Ignite, an operation usually involves multiple nodes.
-Therefore, a trace can include spans from multiple nodes.
-Each span always contains the information about the node where the corresponding operation was executed.
-
-In the image of the transaction trace presented above, you can see that the trace contains the spans associated with the following operations:
-
-* acquire locks (`transactions.colocated.lock.map`),
-* get (`transactions.near.enlist.read`),
-* put (`transactions.near.enlist.write`),
-* commit (`transactions.commit`), and
-* close (`transactions.close`).
-
-The commit operation, in turn, consists of two operations: prepare and finish.
-
-You can click on each span to view the annotations and tags attached to it.
-
-
-image::images/span.png[Span]
-
-
-== Tracing SQL Queries
-
-To enable SQL queries tracing, use `SQL` as a value of the `scope` parameter during the link:https://ignite.apache.org/docs/latest/monitoring-metrics/tracing#enabling-trace-sampling[trace sampling configuration, window=_blank].
-If tracing of SQL queries is enabled, execution of each SQL query on any cluster node will produce a separate trace.
-
-[IMPORTANT]
-====
-[discrete]
-Enabling tracing for SQL queries imposes a severe degradation on SQL engine performance.
-====
-
-The table below provides descriptions, a list of tags, and annotations for each span that can be a part of the SQL query trace tree.
-
-[NOTE]
-====
-[discrete]
-Depending on the SQL query type and its execution plan, some spans may not be present in the SQL query span tree.
-====
-
-[cols="2,5,5",opts="header"]
-|===
-|Span Name | Description | Tags and Annotations
-| sql.query | Execution of an SQL query from the moment of registration until the used resources on the query initiator node are released a|
-* sql.query.text - SQL query text
-* sql.schema - SQL schema
-| sql.cursor.open | SQL query cursor opening |
-| sql.cursor.close | SQL query cursor closure |
-| sql.cursor.cancel | SQL query cursor cancellation |
-| sql.query.parse | Parsing of SQL query a|
-* sql.parser.cache.hit - Whether parsing of the SQL query was skipped due to the cached result
-| sql.query.execute.request | Processing of SQL query execution request a|
-* sql.query.text - SQL query text
-| sql.next.page.request | Processing of the request for obtaining the next page of local SQL query execution result |
-| sql.page.response | Processing of the message with a node local SQL query execution result page |
-| sql.query.execute | Execution of query by H2 SQL engine a|
-* sql.query.text - SQL query text
-| sql.page.prepare | Reading rows from the cursor and preparing a result page a|
-* sql.page.rows - Number of rows that a result page contains
-| sql.fail.response | Processing of a message that indicates failure of SQL query execution |
-| sql.dml.query.execute.request | Processing of SQL DML query execution request a|
-* sql.query.text - SQL query text
-| sql.dml.query.response | Processing of SQL DML query execution result by query initiator node |
-| sql.query.cancel.request | Processing of SQL query cancel request |
-| sql.iterator.open | SQL query iterator opening |
-| sql.iterator.close | SQL query iterator closure |
-| sql.page.fetch | Fetching SQL query result page a|
-* sql.page.rows - Number of rows that result page contains
-| sql.page.wait | Waiting for SQL query results page to be received from remote node |
-| sql.index.range.request | Processing SQL index range request a|
-* sql.index - SQL index name
-* sql.table - SQL table name
-* sql.index.range.rows - Number of rows that an index range request result contains
-| sql.index.range.response | Processing SQL index range responce |
-| sql.dml.query.execute | Execution of SQL DML query |
-| sql.command.query.execute | Execution of an SQL command query, which is either a DDL query or an Ignite native command |
-| sql.partitions.reserve | Reservation of data partitions used to execute a query a|
-* Annotation message that indicates reservation of data partitions for a particular cache - `Cache partitions were reserved [cache=, partitions=[]`
-| sql.cache.update | Cache update as a result of SQL DML query execution a|
-* sql.cache.updates - Number of cache entries to be updated as a result of DML query
-| sql.batch.process| Processing of SQL batch update |
-|===
-
-////
-TODO: describe annotations and tags
-=== Annotations
-
-=== Tags
-
-The `node.id` and `node.consistentId` are the ID and consistent ID of the node where the root operation started.
-////
diff --git a/docs/_docs/tools/control-script.adoc b/docs/_docs/tools/control-script.adoc
index 445e6e2b19b49..2c0ed77f4d8b4 100644
--- a/docs/_docs/tools/control-script.adoc
+++ b/docs/_docs/tools/control-script.adoc
@@ -907,72 +907,6 @@ Index(es):
[8327bbd1-df08-4b97-8721-de95e363e745] inline size: 2
----
-== Tracing Configuration
-
-You can enable or disable sampling of traces for a specific API by using the `--tracing-configuration` command.
-Refer to the link:monitoring-metrics/tracing[Tracing] section for details.
-
-To view the current tracing configuration, execute the following command:
-
-[source, shell]
-----
-control.sh --tracing-configuration
-----
-
-To enable trace sampling for a specific API:
-
-
-[source, shell]
-----
-control.sh --tracing-configuration set --scope --sampling-rate --label
+ *
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+@Deprecated(forRemoval = true)
public class TracingConfigurationCoordinates implements Serializable {
/** */
@@ -56,14 +64,20 @@ private TracingConfigurationCoordinates(@NotNull Scope scope, @Nullable String l
/**
* @return {@link Scope} of a trace's root span to which some specific tracing configuration will be applied.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
@NotNull public Scope scope() {
return scope;
}
/**
* @return Label of a traced operation, to which some specific tracing configuration will be applied.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
@Nullable public String label() {
return lb;
}
@@ -100,7 +114,10 @@ private TracingConfigurationCoordinates(@NotNull Scope scope, @Nullable String l
/**
* {@code TracingConfigurationCoordinates} builder.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
@SuppressWarnings("PublicInnerClass") public static class Builder {
/** Counterpart of {@code TracingConfigurationCoordinator}'s scope. */
private final Scope scope;
@@ -113,7 +130,10 @@ private TracingConfigurationCoordinates(@NotNull Scope scope, @Nullable String l
*
* @param scope Mandatory scope attribute.
* @throws IllegalArgumentException if null scope is specified.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public Builder(Scope scope) {
if (scope == null)
throw new IllegalArgumentException("Null scope is not valid for tracing coordinates.");
@@ -126,7 +146,10 @@ public Builder(Scope scope) {
*
* @param lb Label of traced operation. It's an optional attribute.
* @return Current {@code TracingConfigurationCoordinates} instance.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public @NotNull Builder withLabel(@Nullable String lb) {
this.lb = lb;
@@ -137,7 +160,10 @@ public Builder(Scope scope) {
* Builder's build() method.
*
* @return {@code TracingConfigurationCoordinates} instance.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public TracingConfigurationCoordinates build() {
return new TracingConfigurationCoordinates(scope, lb);
}
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationManager.java b/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationManager.java
index 373c10087e764..117a63fcf8262 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationManager.java
@@ -25,7 +25,11 @@
/**
* Allows to configure tracing, read the configuration and restore it to the defaults.
+ *
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+@Deprecated(forRemoval = true)
public interface TracingConfigurationManager {
/** Default SQL tracing configuration. */
static final TracingConfigurationParameters DEFAULT_SQL_CONFIGURATION =
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationParameters.java b/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationParameters.java
index b4c90ac6dd40f..5b275c713a36e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationParameters.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingConfigurationParameters.java
@@ -20,12 +20,19 @@
import java.io.Serializable;
import java.util.Collections;
import java.util.Set;
-import org.apache.ignite.internal.processors.tracing.Span;
import org.jetbrains.annotations.NotNull;
/**
* Set of tracing configuration parameters like sampling rate or included scopes.
+ *
+ *
WARNING: This class MUST NOT be removed without considering PDS backward compatibility. Instances of this
+ * class were stored in the distributed MetaStorage under the {@code "tr.config"} key. Since distributed MetaStorage values
+ * can be written to the PDS, removing this class may prevent existing PDS from being deserialized.
+ *
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+@Deprecated(forRemoval = true)
public class TracingConfigurationParameters implements Serializable {
/** */
private static final long serialVersionUID = 0L;
@@ -47,7 +54,6 @@ public class TracingConfigurationParameters implements Serializable {
* In other words, if the child's span scope is equal to parent's scope
* or it belongs to the parent's span included scopes, then the given child span will be attached to the current trace,
* otherwise it'll be skipped.
- * See {@link Span#isChainable(Scope)} for more details.
*/
private final Set includedScopes;
@@ -60,7 +66,6 @@ public class TracingConfigurationParameters implements Serializable {
* In other words, if child's span scope is equals to parent's scope
* or it belongs to the parent's span included scopes, then given child span will be attached to the current trace,
* otherwise it'll be skipped.
- * See {@link Span#isChainable(Scope)} for more details.
*/
private TracingConfigurationParameters(double samplingRate,
Set includedScopes) {
@@ -71,7 +76,10 @@ private TracingConfigurationParameters(double samplingRate,
/**
* @return Number between 0 and 1 that more or less reflects the probability of sampling specific trace.
* 0 and 1 have special meaning here, 0 means never 1 means always. Default value is 0 (never).
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public double samplingRate() {
return samplingRate;
}
@@ -81,9 +89,11 @@ public double samplingRate() {
* In other words, if child's span scope is equals to parent's scope
* or it belongs to the parent's span included scopes, then given child span will be attached to the current trace,
* otherwise it'll be skipped.
- * See {@link Span#isChainable(Scope)} for more details.
* If no scopes are specified, empty set will be returned.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public @NotNull Set includedScopes() {
return Collections.unmodifiableSet(includedScopes);
}
@@ -104,7 +114,10 @@ public double samplingRate() {
/**
* {@code TracingConfigurationParameters} builder.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
@SuppressWarnings("PublicInnerClass") public static class Builder {
/** Counterpart of {@code TracingConfigurationParameters} samplingRate. */
private double samplingRate;
@@ -118,7 +131,10 @@ public double samplingRate() {
* @param samplingRate Number between 0 and 1 that more or less reflects the probability of sampling specific trace.
* 0 and 1 have special meaning here, 0 means never 1 means always. Default value is 0 (never).
* @return {@code TracingConfigurationParameters} instance.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public @NotNull Builder withSamplingRate(double samplingRate) {
if (samplingRate < SAMPLING_RATE_NEVER || samplingRate > SAMPLING_RATE_ALWAYS) {
throw new IllegalArgumentException("Specified sampling rate=[" + samplingRate + "] has invalid value." +
@@ -136,9 +152,11 @@ public double samplingRate() {
* In other words, if child's span scope is equals to parent's scope
* or it belongs to the parent's span included scopes, then given child span will be attached to the current trace,
* otherwise it'll be skipped.
- * See {@link Span#isChainable(Scope)} for more details.
* @return {@code TracingConfigurationParameters} instance.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public @NotNull Builder withIncludedScopes(Set includedScopes) {
this.includedScopes = includedScopes == null ? Collections.emptySet() : includedScopes;
@@ -149,7 +167,10 @@ public double samplingRate() {
* Builder's build() method.
*
* @return {@code TracingConfigurationParameters} instance.
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+ @Deprecated(forRemoval = true)
public TracingConfigurationParameters build() {
return new TracingConfigurationParameters(samplingRate, includedScopes);
}
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingSpi.java
index 8c589e612c7af..cda3b8baafd7b 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/tracing/TracingSpi.java
@@ -23,7 +23,11 @@
/**
* Tracing SPI interface.
+ *
+ * @deprecated The Ignite Tracing is deprecated and subject to removal in a future release. Ignite Tracing has been
+ * retired in favor of Ignite Performance Statistics and Ignite Metrics.
*/
+@Deprecated(forRemoval = true)
public interface TracingSpi extends IgniteSpi {
/**
* Creates Span given name and explicit parent.
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
index 422d5c333a374..cee31a0224a8f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
@@ -32,9 +32,6 @@
import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
-import org.apache.ignite.internal.processors.tracing.Span;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
@@ -123,7 +120,7 @@ boolean record = (recordClasses != null && recordClasses.contains(msg0.getClass(
ignite.log().info("Block message [node=" + node.id() + ", order=" + node.order() +
", msg=" + ioMsg.message() + ']');
- blockedMsgs.add(new BlockedMessageDescriptor(node, ioMsg, MTC.span()));
+ blockedMsgs.add(new BlockedMessageDescriptor(node, ioMsg));
notifyAll();
@@ -355,7 +352,7 @@ public void stopBlock(boolean sndMsgs, @Nullable IgnitePredicate>> executeSelect(
// Register query.
long qryId = registerRunningQuery(qryDesc, qryParams, cancel, select.statement());
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_CURSOR_OPEN, MTC.span()))) {
+ try {
Iterable> iter = executeSelect0(
qryId,
qryDesc,
@@ -1157,8 +1128,7 @@ private List extends FieldsQueryCursor>> executeSelect(
cancel,
qryParams.timeout());
- RegisteredQueryCursor> cursor = new RegisteredQueryCursor<>(iter, cancel, runningQueryManager(),
- qryId, ctx.tracing());
+ RegisteredQueryCursor> cursor = new RegisteredQueryCursor<>(iter, cancel, runningQueryManager(), qryId);
cancel.add(cursor::cancel);
@@ -1431,23 +1401,21 @@ private Iterable> executeSelectDistributed(
else {
iter = new Iterable>() {
@Override public Iterator> iterator() {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_ITER_OPEN, MTC.span()))) {
- return IgniteH2Indexing.this.rdcQryExec.query(
- qryId,
- qryDesc.schemaName(),
- qryDesc.queryInitiatorId(),
- twoStepQry,
- keepBinary,
- qryDesc.enforceJoinOrder(),
- timeout,
- cancel,
- qryParams.arguments(),
- parts,
- qryParams.lazy(),
- qryParams.dataPageScanEnabled(),
- qryParams.pageSize()
- );
- }
+ return IgniteH2Indexing.this.rdcQryExec.query(
+ qryId,
+ qryDesc.schemaName(),
+ qryDesc.queryInitiatorId(),
+ twoStepQry,
+ keepBinary,
+ qryDesc.enforceJoinOrder(),
+ timeout,
+ cancel,
+ qryParams.arguments(),
+ parts,
+ qryParams.lazy(),
+ qryParams.dataPageScanEnabled(),
+ qryParams.pageSize()
+ );
}
};
}
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
index dfa8e3ccc9259..c805564fc524e 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
@@ -48,8 +48,6 @@
import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQueryParser;
import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQuerySplitter;
import org.apache.ignite.internal.processors.query.h2.sql.GridSqlStatement;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
import org.apache.ignite.internal.sql.SqlParseException;
import org.apache.ignite.internal.sql.SqlParser;
import org.apache.ignite.internal.sql.SqlStrictParseException;
@@ -62,8 +60,6 @@
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_PARSER_CACHE_HIT;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_PARSE;
/**
* Parser module. Splits incoming request into a series of parsed results.
@@ -133,13 +129,11 @@ public QueryParser(IgniteH2Indexing idx, ConnectionManager connMgr, Predicate "true");
-
return new QueryParserResult(
qryDesc,
queryParameters(qry, lazy),
@@ -211,8 +203,6 @@ private QueryParserResult parse0(String schemaName, SqlFieldsQuery qry, boolean
metricsHolder.countCacheMiss();
- MTC.span().addTag(SQL_PARSER_CACHE_HIT, () -> "false");
-
// Try parsing as native command.
QueryParserResult parseRes = parseNative(schemaName, qry, remainingAllowed);
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/RegisteredQueryCursor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/RegisteredQueryCursor.java
index 58f5ff451004c..e73c1654f9321 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/RegisteredQueryCursor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/RegisteredQueryCursor.java
@@ -24,18 +24,7 @@
import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
import org.apache.ignite.internal.processors.query.GridQueryCancel;
import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.processors.query.running.GridRunningQueryInfo;
import org.apache.ignite.internal.processors.query.running.RunningQueryManager;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
-import org.apache.ignite.internal.processors.tracing.NoopSpan;
-import org.apache.ignite.internal.processors.tracing.Span;
-import org.apache.ignite.internal.processors.tracing.TraceableIterator;
-import org.apache.ignite.internal.processors.tracing.Tracing;
-
-import static org.apache.ignite.internal.processors.tracing.SpanTags.ERROR;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_CANCEL;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_CLOSE;
/**
* Query cursor for registered as running queries.
@@ -55,25 +44,17 @@ public class RegisteredQueryCursor extends QueryCursorImpl {
/** Exception caused query failed or {@code null} if it succeded. */
private Exception failReason;
- /** Tracing processor. */
- private final Tracing tracing;
-
- /** Span of the running query. */
- private final Span qrySpan;
-
/**
* @param iterExec Query executor.
* @param cancel Cancellation closure.
* @param runningQryMgr Running query manager.
* @param qryId Registered running query id.
- * @param tracing Tracing processor.
*/
public RegisteredQueryCursor(
Iterable iterExec,
GridQueryCancel cancel,
RunningQueryManager runningQryMgr,
- long qryId,
- Tracing tracing
+ long qryId
) {
super(iterExec, cancel, true);
@@ -82,25 +63,16 @@ public RegisteredQueryCursor(
this.runningQryMgr = runningQryMgr;
this.qryId = qryId;
- this.tracing = tracing;
-
- GridRunningQueryInfo qryInfo = runningQryMgr.runningQueryInfo(qryId);
-
- qrySpan = qryInfo == null ? NoopSpan.INSTANCE : qryInfo.span();
}
/** {@inheritDoc} */
@Override protected Iterator iter() {
- try (TraceSurroundings ignored = MTC.supportContinual(qrySpan)) {
- Iterator iter = new RegisteredIterator(super.iter());
-
- return qrySpan != NoopSpan.INSTANCE ? new TraceableIterator<>(iter) : iter;
+ try {
+ return new RegisteredIterator(super.iter());
}
catch (Exception e) {
failReason = e;
- qrySpan.addTag(ERROR, e::getMessage);
-
if (QueryUtils.wasCancelled(failReason))
unregisterQuery();
@@ -110,36 +82,19 @@ public RegisteredQueryCursor(
/** {@inheritDoc} */
@Override public void close() {
- Span span = MTC.span();
+ super.close();
- try (
- TraceSurroundings ignored = MTC.support(tracing.create(
- SQL_CURSOR_CLOSE,
- span != NoopSpan.INSTANCE ? span : qrySpan))
- ) {
- super.close();
-
- unregisterQuery();
- }
- catch (Throwable th) {
- qrySpan.addTag(ERROR, th::getMessage);
-
- throw th;
- }
+ unregisterQuery();
}
/**
* Cancels query.
*/
public void cancel() {
- try (TraceSurroundings ignored = MTC.support(tracing.create(SQL_CURSOR_CANCEL, qrySpan))) {
- if (failReason == null)
- failReason = new QueryCancelledException();
-
- qrySpan.addTag(ERROR, failReason::getMessage);
+ if (failReason == null)
+ failReason = new QueryCancelledException();
- close();
- }
+ close();
}
/**
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
index fea5f1541c0c0..844f559bc7ad7 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
@@ -71,9 +71,6 @@
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2RowRangeBounds;
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessage;
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessageFactory;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
-import org.apache.ignite.internal.processors.tracing.Span;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.lang.GridCursor;
import org.apache.ignite.internal.util.typedef.CIX2;
@@ -99,12 +96,6 @@
import static org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2IndexRangeResponse.STATUS_ERROR;
import static org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2IndexRangeResponse.STATUS_NOT_FOUND;
import static org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2IndexRangeResponse.STATUS_OK;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.ERROR;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_IDX;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_IDX_RANGE_ROWS;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_TABLE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_IDX_RANGE_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_IDX_RANGE_RESP;
import static org.h2.result.Row.MEMORY_CALCULATE;
/**
@@ -466,109 +457,85 @@ else if (msg instanceof GridH2IndexRangeResponse)
* @param msg Request message.
*/
private void onIndexRangeRequest(final ClusterNode node, final GridH2IndexRangeRequest msg) {
- // We don't use try with resources on purpose - the catch block must also be executed in the context of this span.
- TraceSurroundings trace = MTC.support(ctx.tracing().create(SQL_IDX_RANGE_REQ, MTC.span()));
-
- Span span = MTC.span();
-
- try {
- span.addTag(SQL_IDX, () -> idxName);
- span.addTag(SQL_TABLE, () -> tblName);
-
- GridH2IndexRangeResponse res = new GridH2IndexRangeResponse();
-
- res.originNodeId(msg.originNodeId());
- res.queryId(msg.queryId());
- res.originSegmentId(msg.originSegmentId());
- res.segment(msg.segment());
- res.batchLookupId(msg.batchLookupId());
-
- QueryContext qctx = qryCtxRegistry.getShared(
- msg.originNodeId(),
- msg.queryId(),
- msg.originSegmentId()
- );
-
- if (qctx == null)
- res.status(STATUS_NOT_FOUND);
- else {
- DistributedJoinContext joinCtx = qctx.distributedJoinContext();
-
- assert joinCtx != null;
-
- try {
- RangeSource src;
-
- if (msg.bounds() != null) {
- // This is the first request containing all the search rows.
- assert !msg.bounds().isEmpty() : "empty bounds";
+ GridH2IndexRangeResponse res = new GridH2IndexRangeResponse();
+
+ res.originNodeId(msg.originNodeId());
+ res.queryId(msg.queryId());
+ res.originSegmentId(msg.originSegmentId());
+ res.segment(msg.segment());
+ res.batchLookupId(msg.batchLookupId());
+
+ QueryContext qctx = qryCtxRegistry.getShared(
+ msg.originNodeId(),
+ msg.queryId(),
+ msg.originSegmentId()
+ );
- src = new RangeSource(this, msg.bounds(), msg.segment(), idxQryContext(qctx));
- }
- else {
- // This is request to fetch next portion of data.
- src = joinCtx.getSource(node.id(), msg.segment(), msg.batchLookupId());
+ if (qctx == null)
+ res.status(STATUS_NOT_FOUND);
+ else {
+ DistributedJoinContext joinCtx = qctx.distributedJoinContext();
- assert src != null;
- }
+ assert joinCtx != null;
- List ranges = new ArrayList<>();
+ try {
+ RangeSource src;
- int maxRows = joinCtx.pageSize();
+ if (msg.bounds() != null) {
+ // This is the first request containing all the search rows.
+ assert !msg.bounds().isEmpty() : "empty bounds";
- assert maxRows > 0 : maxRows;
+ src = new RangeSource(this, msg.bounds(), msg.segment(), idxQryContext(qctx));
+ }
+ else {
+ // This is request to fetch next portion of data.
+ src = joinCtx.getSource(node.id(), msg.segment(), msg.batchLookupId());
- while (maxRows > 0) {
- GridH2RowRange range = src.next(maxRows);
+ assert src != null;
+ }
- if (range == null)
- break;
+ List ranges = new ArrayList<>();
- ranges.add(range);
+ int maxRows = joinCtx.pageSize();
- if (range.rows() != null)
- maxRows -= range.rows().size();
- }
+ assert maxRows > 0 : maxRows;
- assert !ranges.isEmpty();
+ while (maxRows > 0) {
+ GridH2RowRange range = src.next(maxRows);
- if (src.hasMoreRows()) {
- // Save source for future fetches.
- if (msg.bounds() != null)
- joinCtx.putSource(node.id(), msg.segment(), msg.batchLookupId(), src);
- }
- else if (msg.bounds() == null) {
- // Drop saved source.
- joinCtx.putSource(node.id(), msg.segment(), msg.batchLookupId(), null);
- }
+ if (range == null)
+ break;
- res.ranges(ranges);
- res.status(STATUS_OK);
+ ranges.add(range);
- span.addTag(SQL_IDX_RANGE_ROWS, () ->
- Integer.toString(ranges.stream().mapToInt(GridH2RowRange::rowsSize).sum()));
+ if (range.rows() != null)
+ maxRows -= range.rows().size();
}
- catch (Throwable th) {
- span.addTag(ERROR, th::getMessage);
- U.error(log, "Failed to process request: " + msg, th);
+ assert !ranges.isEmpty();
- res.error(th.getClass() + ": " + th.getMessage());
- res.status(STATUS_ERROR);
+ if (src.hasMoreRows()) {
+ // Save source for future fetches.
+ if (msg.bounds() != null)
+ joinCtx.putSource(node.id(), msg.segment(), msg.batchLookupId(), src);
}
+ else if (msg.bounds() == null) {
+ // Drop saved source.
+ joinCtx.putSource(node.id(), msg.segment(), msg.batchLookupId(), null);
+ }
+
+ res.ranges(ranges);
+ res.status(STATUS_OK);
}
+ catch (Throwable th) {
+ U.error(log, "Failed to process request: " + msg, th);
- send(singletonList(node), res);
+ res.error(th.getClass() + ": " + th.getMessage());
+ res.status(STATUS_ERROR);
+ }
}
- catch (Throwable th) {
- span.addTag(ERROR, th::getMessage);
- throw th;
- }
- finally {
- if (trace != null)
- trace.close();
- }
+ send(singletonList(node), res);
}
/**
@@ -576,31 +543,29 @@ else if (msg.bounds() == null) {
* @param msg Response message.
*/
private void onIndexRangeResponse(ClusterNode node, GridH2IndexRangeResponse msg) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_IDX_RANGE_RESP, MTC.span()))) {
- QueryContext qctx = qryCtxRegistry.getShared(
- msg.originNodeId(),
- msg.queryId(),
- msg.originSegmentId()
- );
+ QueryContext qctx = qryCtxRegistry.getShared(
+ msg.originNodeId(),
+ msg.queryId(),
+ msg.originSegmentId()
+ );
- if (qctx == null)
- return;
+ if (qctx == null)
+ return;
- DistributedJoinContext joinCtx = qctx.distributedJoinContext();
+ DistributedJoinContext joinCtx = qctx.distributedJoinContext();
- assert joinCtx != null;
+ assert joinCtx != null;
- Map streams = joinCtx.getStreams(msg.batchLookupId());
+ Map streams = joinCtx.getStreams(msg.batchLookupId());
- if (streams == null)
- return;
+ if (streams == null)
+ return;
- RangeStream stream = streams.get(new SegmentKey(node, msg.segment()));
+ RangeStream stream = streams.get(new SegmentKey(node, msg.segment()));
- assert stream != null;
+ assert stream != null;
- stream.onResponse(msg);
- }
+ stream.onResponse(msg);
}
/**
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java
index a57c932a2c19a..57695be20e3c9 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java
@@ -41,16 +41,11 @@
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException;
import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
import org.apache.ignite.internal.processors.odbc.SqlStateCode;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.createJdbcSqlException;
import static org.apache.ignite.internal.processors.query.QueryUtils.cacheForDML;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.ERROR;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_CACHE_UPDATES;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CACHE_UPDATE;
/**
* Batch sender class.
@@ -198,30 +193,22 @@ public void setFailed(int rowNum) {
* @param batch Batch.
*/
private void sendBatch(Batch batch) {
- try (
- TraceSurroundings ignored = MTC.support(cctx.kernalContext().tracing()
- .create(SQL_CACHE_UPDATE, MTC.span())
- .addTag(SQL_CACHE_UPDATES, () -> Integer.toString(batch.size())))
- ) {
- DmlPageProcessingResult pageRes = processPage(cctx, batch);
+ DmlPageProcessingResult pageRes = processPage(cctx, batch);
- batch.clear();
+ batch.clear();
- updateCnt += pageRes.count();
+ updateCnt += pageRes.count();
- if (failedKeys == null)
- failedKeys = new ArrayList<>();
+ if (failedKeys == null)
+ failedKeys = new ArrayList<>();
- failedKeys.addAll(F.asList(pageRes.errorKeys()));
+ failedKeys.addAll(F.asList(pageRes.errorKeys()));
- if (pageRes.error() != null) {
- MTC.span().addTag(ERROR, pageRes.error()::getMessage);
-
- if (err == null)
- err = pageRes.error();
- else
- err.setNextException(pageRes.error());
- }
+ if (pageRes.error() != null) {
+ if (err == null)
+ err = pageRes.error();
+ else
+ err.setNextException(pageRes.error());
}
}
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java
index 08b7caf38871e..92a9e78dc96d0 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java
@@ -43,7 +43,6 @@
import org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor;
import org.apache.ignite.internal.processors.query.h2.H2Utils;
import org.apache.ignite.internal.processors.query.h2.UpdateResult;
-import org.apache.ignite.internal.processors.tracing.MTC;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.internal.util.typedef.X;
@@ -60,8 +59,6 @@
import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.DUPLICATE_KEY;
import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.createJdbcSqlException;
import static org.apache.ignite.internal.processors.query.QueryUtils.cacheForDML;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_CACHE_UPDATES;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CACHE_UPDATE;
/**
* DML utility methods.
@@ -201,16 +198,10 @@ private static long dmlDoInsert(UpdatePlan plan, Iterable> cursor, int p
if (plan.rowCount() == 1) {
IgniteBiTuple t = plan.processRow(cursor.iterator().next());
- try (
- MTC.TraceSurroundings ignored = MTC.support(cctx.kernalContext().tracing()
- .create(SQL_CACHE_UPDATE, MTC.span())
- .addTag(SQL_CACHE_UPDATES, () -> "1"))
- ) {
- if (cacheForDML(cctx.cache()).putIfAbsent(t.getKey(), t.getValue()))
- return 1;
- else
- throw new IgniteSQLException(errMsg + '[' + t.getKey() + "]]", DUPLICATE_KEY);
- }
+ if (cacheForDML(cctx.cache()).putIfAbsent(t.getKey(), t.getValue()))
+ return 1;
+ else
+ throw new IgniteSQLException(errMsg + '[' + t.getKey() + "]]", DUPLICATE_KEY);
}
else {
// Keys that failed to INSERT due to duplication.
@@ -311,13 +302,7 @@ private static long doMerge(UpdatePlan plan, Iterable> cursor, int pageS
if (plan.rowCount() == 1) {
IgniteBiTuple t = plan.processRow(cursor.iterator().next());
- try (
- MTC.TraceSurroundings ignored = MTC.support(cctx.kernalContext().tracing()
- .create(SQL_CACHE_UPDATE, MTC.span())
- .addTag(SQL_CACHE_UPDATES, () -> "1"))
- ) {
- cacheForDML(cctx.cache()).put(t.getKey(), t.getValue());
- }
+ cacheForDML(cctx.cache()).put(t.getKey(), t.getValue());
return 1;
}
@@ -334,18 +319,12 @@ private static long doMerge(UpdatePlan plan, Iterable> cursor, int pageS
rows.put(t.getKey(), t.getValue());
if ((pageSize > 0 && rows.size() == pageSize) || !it.hasNext()) {
- try (
- MTC.TraceSurroundings ignored = MTC.support(cctx.kernalContext().tracing()
- .create(SQL_CACHE_UPDATE, MTC.span())
- .addTag(SQL_CACHE_UPDATES, () -> Integer.toString(rows.size())))
- ) {
- cacheForDML(cctx.cache()).putAll(rows);
+ cacheForDML(cctx.cache()).putAll(rows);
- resCnt += rows.size();
+ resCnt += rows.size();
- if (it.hasNext())
- rows.clear();
- }
+ if (it.hasNext())
+ rows.clear();
}
}
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractReducer.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractReducer.java
index 5e1018d2db3d6..0608e70ea156e 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractReducer.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractReducer.java
@@ -33,8 +33,6 @@
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.h2.index.Cursor;
@@ -48,9 +46,6 @@
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_MERGE_TABLE_MAX_SIZE;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_MERGE_TABLE_PREFETCH_SIZE;
import static org.apache.ignite.IgniteSystemProperties.getInteger;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_PAGE_ROWS;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_FETCH;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_WAIT;
/**
* Base class for reducer of remote index lookup results.
@@ -324,22 +319,18 @@ protected final ReduceResultPage createDummyLastPage(ReduceResultPage lastPage)
*/
protected final Iterator pollNextIterator(Pollable queue, Iterator iter) {
if (!iter.hasNext()) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_PAGE_FETCH, MTC.span()))) {
- ReduceResultPage page = takeNextPage(queue);
+ ReduceResultPage page = takeNextPage(queue);
- if (!page.isLast())
- page.fetchNextPage(); // Failed will throw an exception here.
+ if (!page.isLast())
+ page.fetchNextPage(); // Failed will throw an exception here.
- iter = page.rows();
+ iter = page.rows();
- if (iter.hasNext() && colCnt == 0)
- colCnt = page.columnCount();
+ if (iter.hasNext() && colCnt == 0)
+ colCnt = page.columnCount();
- MTC.span().addTag(SQL_PAGE_ROWS, () -> Integer.toString(page.rowsInPage()));
-
- // The received iterator must be empty in the dummy last page or on failure.
- assert iter.hasNext() || page.isDummyLast() || page.isFail();
- }
+ // The received iterator must be empty in the dummy last page or on failure.
+ assert iter.hasNext() || page.isDummyLast() || page.isFail();
}
return iter;
@@ -350,25 +341,23 @@ protected final Iterator pollNextIterator(Pollable qu
* @return Next page.
*/
private ReduceResultPage takeNextPage(Pollable queue) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_PAGE_WAIT, MTC.span()))) {
- ReduceResultPage page;
-
- for (;;) {
- try {
- page = queue.poll(500, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException e) {
- throw new CacheException("Query execution was interrupted.", e);
- }
-
- if (page != null)
- break;
+ ReduceResultPage page;
- checkSourceNodesAlive();
+ for (;;) {
+ try {
+ page = queue.poll(500, TimeUnit.MILLISECONDS);
}
+ catch (InterruptedException e) {
+ throw new CacheException("Query execution was interrupted.", e);
+ }
+
+ if (page != null)
+ break;
- return page;
+ checkSourceNodesAlive();
}
+
+ return page;
}
/**
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 36ff10e314615..e22c9b374e248 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -31,7 +31,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -72,10 +71,6 @@
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse;
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest;
import org.apache.ignite.internal.processors.query.running.RunningQueryManager;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
-import org.apache.ignite.internal.processors.tracing.Span;
-import org.apache.ignite.internal.processors.tracing.SpanType;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -91,13 +86,6 @@
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.QUERY_POOL;
import static org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest.isDataPageScanEnabled;
import static org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessageFactory.toMessages;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.ERROR;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_PAGE_ROWS;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_QRY_TEXT;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_NEXT_PAGE_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_PREPARE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_CANCEL_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_EXEC_REQ;
/**
* Map query executor.
@@ -163,21 +151,19 @@ public void stop() {
* @param msg Message.
*/
public void onCancel(ClusterNode node, GridQueryCancelRequest msg) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_QRY_CANCEL_REQ, MTC.span()))) {
- long qryReqId = msg.queryRequestId();
+ long qryReqId = msg.queryRequestId();
- MapNodeResults nodeRess = resultsForNode(node.id());
-
- boolean clear = qryCtxRegistry.clearShared(node.id(), qryReqId);
+ MapNodeResults nodeRess = resultsForNode(node.id());
- if (!clear) {
- nodeRess.onCancel(qryReqId);
+ boolean clear = qryCtxRegistry.clearShared(node.id(), qryReqId);
- qryCtxRegistry.clearShared(node.id(), qryReqId);
- }
+ if (!clear) {
+ nodeRess.onCancel(qryReqId);
- nodeRess.cancelRequest(qryReqId);
+ qryCtxRegistry.clearShared(node.id(), qryReqId);
}
+
+ nodeRess.cancelRequest(qryReqId);
}
/**
@@ -248,11 +234,9 @@ public void onQueryRequest(final ClusterNode node, final GridH2QueryRequest req)
final int segment0 = segment;
- Span span = MTC.span();
-
ctx.closure().runLocal(
() -> {
- try (TraceSurroundings ignored = MTC.supportContinual(span)) {
+ try {
onQueryRequest0(node,
req.queryId(),
req.requestId(),
@@ -369,12 +353,6 @@ private void onQueryRequest0(
QueryContext qctx = null;
- // We don't use try with resources on purpose - the catch block must also be executed in the context of this span.
- TraceSurroundings trace = MTC.support(ctx.tracing()
- .create(SQL_QRY_EXEC_REQ, MTC.span())
- .addTag(SQL_QRY_TEXT, () ->
- qrys.stream().map(GridCacheSqlQuery::query).collect(Collectors.joining("; "))));
-
try {
if (topVer != null) {
// Reserve primary for topology version or explicit partitions.
@@ -661,9 +639,6 @@ private void onQueryRequest0(
if (reserved != null)
reserved.release();
- if (trace != null)
- trace.close();
-
if (performanceStatsEnabled) {
IoStatisticsHolder stat = IoStatisticsQueryHelper.finishGatheringQueryStatistics();
@@ -710,11 +685,6 @@ public void onDmlRequest(final ClusterNode node, final GridH2DmlRequest req) {
long runningQryId = RunningQueryManager.UNDEFINED_QUERY_ID;
- // We don't use try with resources on purpose - the catch block must also be executed in the context of this span.
- TraceSurroundings trace = MTC.support(ctx.tracing()
- .create(SpanType.SQL_DML_QRY_EXEC_REQ, MTC.span())
- .addTag(SQL_QRY_TEXT, req::query));
-
try {
reserved = h2.partitionReservationManager().reservePartitions(
cacheIds,
@@ -801,8 +771,6 @@ public void onDmlRequest(final ClusterNode node, final GridH2DmlRequest req) {
h2.runningQueryManager().unregister(runningQryId, null);
}
catch (Exception e) {
- MTC.span().addTag(ERROR, e::getMessage);
-
U.error(log, "Error processing dml request. [localNodeId=" + ctx.localNodeId() +
", nodeId=" + node.id() + ", req=" + req + ']', e);
@@ -815,9 +783,6 @@ public void onDmlRequest(final ClusterNode node, final GridH2DmlRequest req) {
reserved.release();
nodeResults.removeUpdate(reqId);
-
- if (trace != null)
- trace.close();
}
}
@@ -836,8 +801,6 @@ private void sendQueryCancel(ClusterNode node, long qryReqId) {
*/
private void sendError(ClusterNode node, long qryReqId, Throwable err) {
try {
- MTC.span().addTag(ERROR, err::getMessage);
-
GridQueryFailResponse msg = new GridQueryFailResponse(qryReqId, err);
if (node.isLocal()) {
@@ -907,89 +870,87 @@ private void sendUpdateResponse(ClusterNode node, long reqId, UpdateResult updRe
* @param req Request.
*/
public void onNextPageRequest(final ClusterNode node, final GridQueryNextPageRequest req) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_NEXT_PAGE_REQ, MTC.span()))) {
- long reqId = req.queryRequestId();
+ long reqId = req.queryRequestId();
- final MapNodeResults nodeRess = qryRess.get(node.id());
+ final MapNodeResults nodeRess = qryRess.get(node.id());
- if (nodeRess == null) {
- sendError(node, reqId, new CacheException("No node result found for request: " + req));
+ if (nodeRess == null) {
+ sendError(node, reqId, new CacheException("No node result found for request: " + req));
- return;
- }
- else if (nodeRess.cancelled(reqId)) {
- sendQueryCancel(node, reqId);
+ return;
+ }
+ else if (nodeRess.cancelled(reqId)) {
+ sendQueryCancel(node, reqId);
- return;
- }
+ return;
+ }
- final MapQueryResults qryResults = nodeRess.get(reqId, req.segmentId());
+ final MapQueryResults qryResults = nodeRess.get(reqId, req.segmentId());
- MapQueryResult res = null;
+ MapQueryResult res = null;
- if (qryResults == null)
- sendError(node, reqId, new CacheException("No query result found for request: " + req));
- else if (qryResults.cancelled())
- sendQueryCancel(node, reqId);
- else {
- try {
- res = qryResults.result(req.query());
+ if (qryResults == null)
+ sendError(node, reqId, new CacheException("No query result found for request: " + req));
+ else if (qryResults.cancelled())
+ sendQueryCancel(node, reqId);
+ else {
+ try {
+ res = qryResults.result(req.query());
- assert res != null;
+ assert res != null;
+ try {
+ // Session isn't set for lazy=false queries.
+ // Also session == null when result already closed.
+ res.lock();
+ res.lockTables();
+ res.checkTablesVersions();
+
+ Boolean dataPageScanEnabled = isDataPageScanEnabled(req.flags());
+
+ GridQueryNextPageResponse msg = h2.executeWithResumableTimeTracking(
+ () -> prepareNextPage(
+ nodeRess,
+ node,
+ qryResults,
+ req.query(),
+ req.segmentId(),
+ req.pageSize(),
+ dataPageScanEnabled
+ ),
+ res.qryInfo()
+ );
+
+ if (msg != null)
+ sendNextPage(node, msg);
+ }
+ finally {
try {
- // Session isn't set for lazy=false queries.
- // Also session == null when result already closed.
- res.lock();
- res.lockTables();
- res.checkTablesVersions();
-
- Boolean dataPageScanEnabled = isDataPageScanEnabled(req.flags());
-
- GridQueryNextPageResponse msg = h2.executeWithResumableTimeTracking(
- () -> prepareNextPage(
- nodeRess,
- node,
- qryResults,
- req.query(),
- req.segmentId(),
- req.pageSize(),
- dataPageScanEnabled
- ),
- res.qryInfo()
- );
-
- if (msg != null)
- sendNextPage(node, msg);
+ res.unlockTables();
}
finally {
- try {
- res.unlockTables();
- }
- finally {
- res.unlock();
- }
+ res.unlock();
}
}
- catch (Exception e) {
- if (res.qryInfo() != null)
- h2.heavyQueriesTracker().stopTracking(res.qryInfo(), e);
+ }
+ catch (Exception e) {
+ if (res.qryInfo() != null)
+ h2.heavyQueriesTracker().stopTracking(res.qryInfo(), e);
- QueryRetryException retryEx = X.cause(e, QueryRetryException.class);
+ QueryRetryException retryEx = X.cause(e, QueryRetryException.class);
- if (retryEx != null)
- sendError(node, reqId, retryEx);
- else {
- SQLException sqlEx = X.cause(e, SQLException.class);
-
- if (sqlEx != null && sqlEx.getErrorCode() == ErrorCode.STATEMENT_WAS_CANCELED)
- sendQueryCancel(node, reqId);
- else
- sendError(node, reqId, e);
- }
+ if (retryEx != null)
+ sendError(node, reqId, retryEx);
+ else {
+ SQLException sqlEx = X.cause(e, SQLException.class);
- qryResults.cancel();
+ if (sqlEx != null && sqlEx.getErrorCode() == ErrorCode.STATEMENT_WAS_CANCELED)
+ sendQueryCancel(node, reqId);
+ else
+ sendError(node, reqId, e);
}
+
+ qryResults.cancel();
}
}
}
@@ -1013,45 +974,41 @@ private GridQueryNextPageResponse prepareNextPage(
int segmentId,
int pageSize,
Boolean dataPageScanEnabled) throws IgniteCheckedException {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_PAGE_PREPARE, MTC.span()))) {
- MapQueryResult res = qr.result(qry);
+ MapQueryResult res = qr.result(qry);
- assert res != null;
+ assert res != null;
- if (res.closed())
- return null;
+ if (res.closed())
+ return null;
- int page = res.page();
+ int page = res.page();
- List rows = new ArrayList<>(Math.min(64, pageSize));
+ List rows = new ArrayList<>(Math.min(64, pageSize));
- boolean last = res.fetchNextPage(rows, pageSize, dataPageScanEnabled);
+ boolean last = res.fetchNextPage(rows, pageSize, dataPageScanEnabled);
- if (last) {
- qr.closeResult(qry);
+ if (last) {
+ qr.closeResult(qry);
- if (qr.isAllClosed()) {
- nodeRess.remove(qr.queryRequestId(), segmentId, qr);
+ if (qr.isAllClosed()) {
+ nodeRess.remove(qr.queryRequestId(), segmentId, qr);
- // Clear context, release reservations
- if (qr.isLazy())
- qr.releaseQueryContext();
- }
+ // Clear context, release reservations
+ if (qr.isLazy())
+ qr.releaseQueryContext();
}
+ }
- boolean loc = node.isLocal();
-
- GridQueryNextPageResponse msg = new GridQueryNextPageResponse(qr.queryRequestId(), segmentId, qry, page,
- page == 0 ? res.rowCount() : -1,
- res.columnCount(),
- loc ? null : toMessages(rows, res.columnCount()),
- loc ? rows : null,
- last);
+ boolean loc = node.isLocal();
- MTC.span().addTag(SQL_PAGE_ROWS, () -> String.valueOf(rows.size()));
+ GridQueryNextPageResponse msg = new GridQueryNextPageResponse(qr.queryRequestId(), segmentId, qry, page,
+ page == 0 ? res.rowCount() : -1,
+ res.columnCount(),
+ loc ? null : toMessages(rows, res.columnCount()),
+ loc ? rows : null,
+ last);
- return msg;
- }
+ return msg;
}
/**
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index f2d943d333451..a5c896e39fbee 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -78,8 +78,6 @@
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlRequest;
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse;
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
import org.apache.ignite.internal.util.typedef.C2;
import org.apache.ignite.internal.util.typedef.CIX2;
import org.apache.ignite.internal.util.typedef.F;
@@ -102,10 +100,6 @@
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
import static org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery.EMPTY_PARAMS;
import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlQuerySplitter.mergeTableIdentifier;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.ERROR;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_DML_QRY_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_FAIL_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_RESP;
/**
* Reduce query executor.
@@ -212,11 +206,9 @@ private void handleNodeLeft(ReduceQueryRun r, UUID nodeId) {
* @param msg Message.
*/
public void onFail(ClusterNode node, GridQueryFailResponse msg) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_FAIL_RESP, MTC.span()))) {
- ReduceQueryRun r = runs.get(msg.queryRequestId());
+ ReduceQueryRun r = runs.get(msg.queryRequestId());
- fail(r, node.id(), msg.error(), msg.failCode());
- }
+ fail(r, node.id(), msg.error(), msg.failCode());
}
/**
@@ -247,66 +239,62 @@ else if (failCode == GridQueryFailResponse.RETRY_QUERY)
* @param msg Message.
*/
public void onNextPage(final ClusterNode node, final GridQueryNextPageResponse msg) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_PAGE_RESP, MTC.span()))) {
- final long qryReqId = msg.queryRequestId();
- final int qry = msg.query();
- final int seg = msg.segmentId();
+ final long qryReqId = msg.queryRequestId();
+ final int qry = msg.query();
+ final int seg = msg.segmentId();
- final ReduceQueryRun r = runs.get(qryReqId);
+ final ReduceQueryRun r = runs.get(qryReqId);
- if (r == null) // Already finished with error or canceled.
- return;
+ if (r == null) // Already finished with error or canceled.
+ return;
- final int pageSize = r.pageSize();
+ final int pageSize = r.pageSize();
- Reducer idx = r.reducers().get(msg.query());
+ Reducer idx = r.reducers().get(msg.query());
- ReduceResultPage page;
+ ReduceResultPage page;
- try {
- page = new ReduceResultPage(ctx, node.id(), msg) {
- @Override public void fetchNextPage() {
- if (r.hasErrorOrRetry()) {
- if (r.exception() != null)
- throw r.exception();
+ try {
+ page = new ReduceResultPage(ctx, node.id(), msg) {
+ @Override public void fetchNextPage() {
+ if (r.hasErrorOrRetry()) {
+ if (r.exception() != null)
+ throw r.exception();
- assert r.retryCause() != null;
+ assert r.retryCause() != null;
- throw new CacheException(r.retryCause());
- }
+ throw new CacheException(r.retryCause());
+ }
- try {
- GridQueryNextPageRequest msg0 = new GridQueryNextPageRequest(qryReqId, qry, seg, pageSize,
- (byte)GridH2QueryRequest.setDataPageScanEnabled(0, r.isDataPageScanEnabled()));
+ try {
+ GridQueryNextPageRequest msg0 = new GridQueryNextPageRequest(qryReqId, qry, seg, pageSize,
+ (byte)GridH2QueryRequest.setDataPageScanEnabled(0, r.isDataPageScanEnabled()));
- if (node.isLocal())
- h2.mapQueryExecutor().onNextPageRequest(node, msg0);
- else
- ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, msg0, GridIoPolicy.QUERY_POOL);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException("Failed to fetch data from node: " + node.id(), e);
- }
+ if (node.isLocal())
+ h2.mapQueryExecutor().onNextPageRequest(node, msg0);
+ else
+ ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, msg0, GridIoPolicy.QUERY_POOL);
}
- };
- }
- catch (Exception e) {
- U.error(log, "Error in message.", e);
-
- MTC.span().addTag(ERROR, e::getMessage);
+ catch (IgniteCheckedException e) {
+ throw new CacheException("Failed to fetch data from node: " + node.id(), e);
+ }
+ }
+ };
+ }
+ catch (Exception e) {
+ U.error(log, "Error in message.", e);
- fail(r, node.id(), "Error in message.", GridQueryFailResponse.GENERAL_ERROR);
+ fail(r, node.id(), "Error in message.", GridQueryFailResponse.GENERAL_ERROR);
- return;
- }
+ return;
+ }
- idx.addPage(page);
+ idx.addPage(page);
- if (msg.retry() != null)
- r.setStateOnRetry(node.id(), msg.retry(), msg.retryCause());
- else if (msg.page() == 0) // Count down only on each first page received.
- r.onFirstPage();
- }
+ if (msg.retry() != null)
+ r.setStateOnRetry(node.id(), msg.retry(), msg.retryCause());
+ else if (msg.page() == 0) // Count down only on each first page received.
+ r.onFirstPage();
}
/**
@@ -487,8 +475,7 @@ else if (QueryUtils.wasCancelled(err))
nodes,
r,
qryReqId,
- qry.distributedJoins(),
- ctx.tracing());
+ qry.distributedJoins());
release = false;
@@ -563,8 +550,7 @@ else if (QueryUtils.wasCancelled(err))
r.pageSize(),
log,
h2,
- qryInfo,
- ctx.tracing()
+ qryInfo
);
conn = null;
@@ -1022,7 +1008,7 @@ public UpdateResult update(
* @param msg Message.
*/
public void onDmlResponse(final ClusterNode node, GridH2DmlResponse msg) {
- try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_DML_QRY_RESP, MTC.span()))) {
+ try {
long reqId = msg.requestId();
DmlDistributedUpdateRun r = updRuns.get(reqId);
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceIndexIterator.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceIndexIterator.java
index dc39ac73c7910..5924b7ce8263a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceIndexIterator.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceIndexIterator.java
@@ -23,14 +23,9 @@
import java.util.List;
import java.util.NoSuchElementException;
import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
-import org.apache.ignite.internal.processors.tracing.Tracing;
import org.h2.index.Cursor;
import org.h2.result.Row;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_ITER_CLOSE;
-
/**
* Iterator that transparently and sequentially traverses a bunch of {@link AbstractReduceIndexAdapter} objects.
*/
@@ -62,9 +57,6 @@ public class ReduceIndexIterator implements Iterator>, AutoCloseable {
/** Whether remote resources were released. */
private boolean released;
- /** Tracing processor. */
- private final Tracing tracing;
-
/**
* Constructor.
*
@@ -73,21 +65,18 @@ public class ReduceIndexIterator implements Iterator>, AutoCloseable {
* @param run Query run.
* @param qryReqId Query request ID.
* @param distributedJoins Distributed joins.
- * @param tracing Tracing processor.
*/
public ReduceIndexIterator(GridReduceQueryExecutor rdcExec,
Collection nodes,
ReduceQueryRun run,
long qryReqId,
- boolean distributedJoins,
- Tracing tracing
+ boolean distributedJoins
) {
this.rdcExec = rdcExec;
this.nodes = nodes;
this.run = run;
this.qryReqId = qryReqId;
this.distributedJoins = distributedJoins;
- this.tracing = tracing;
rdcIter = run.reducers().iterator();
@@ -118,9 +107,7 @@ public ReduceIndexIterator(GridReduceQueryExecutor rdcExec,
/** {@inheritDoc} */
@Override public void close() throws Exception {
- try (TraceSurroundings ignored = MTC.support(tracing.create(SQL_ITER_CLOSE, MTC.span()))) {
- releaseIfNeeded();
- }
+ releaseIfNeeded();
}
/**
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/MTC.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/MTC.java
deleted file mode 100644
index eb35d9f08e7cd..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/MTC.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ignite.internal.processors.tracing;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Mapped tracing context.
- *
- * Thread local context which holding the information for tracing.
- */
-public class MTC {
- /***/
- private static final Span NOOP_SPAN = NoopSpan.INSTANCE;
-
- /** Thread local span holder. */
- private static ThreadLocal span = ThreadLocal.withInitial(() -> NOOP_SPAN);
-
- /**
- * @return Span which corresponded to current thread or null if it doesn't not set.
- */
- @NotNull public static Span span() {
- return span.get();
- }
-
- /**
- * Attach given span to current thread if it isn't null or NOOP_SPAN. Detach given span, close
- * it and return previous span when {@link TraceSurroundings#close()} would be called.
- *
- * @param startSpan Span which should be added to current thread.
- * @return {@link TraceSurroundings} for manage span life cycle or null in case of null or no-op span.
- */
- public static TraceSurroundings support(Span startSpan) {
- if (startSpan == null || startSpan == NOOP_SPAN)
- return null;
-
- Span oldSpan = span();
-
- span.set(startSpan);
-
- return new TraceSurroundings(oldSpan, true);
- }
-
- /**
- * Support initial span.
- *
- * @param startSpan Span which should be added to current thread.
- */
- public static void supportInitial(Span startSpan) {
- span.set(startSpan);
- }
-
- /**
- * Attach given span to current thread if it isn't null or NOOP_SPAN.
- *
- * @param startSpan Span which should be added to current thread.
- * @return {@link TraceSurroundings} for manage span life cycle or null in case of null or no-op span.
- */
- public static TraceSurroundings supportContinual(Span startSpan) {
- if (startSpan == null || startSpan == NOOP_SPAN)
- return null;
-
- Span oldSpan = span();
-
- span.set(startSpan);
-
- return new TraceSurroundings(oldSpan, false);
- }
-
- /**
- * Helper for managing of span life cycle. It help to end current span and also reattach previous one to thread after
- * {@link TraceSurroundings#close()} would be call.
- */
- public static class TraceSurroundings implements AutoCloseable {
- /** Span which should be attached to thread when {@code #close} would be called. */
- private final Span oldSpan;
-
- /** {@code true} if current span should be ended at close moment. */
- private final boolean endRequired;
-
- /**
- * @param oldSpan Old span for restoring after close.
- * @param endRequired {@code true} if current span should be ended at close moment.
- */
- private TraceSurroundings(Span oldSpan, boolean endRequired) {
- this.oldSpan = oldSpan;
- this.endRequired = endRequired;
- }
-
- /**
- * Close life cycle of current span.
- */
- @Override public void close() {
- if (endRequired)
- span.get().end();
-
- span.set(oldSpan);
- }
- }
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpan.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpan.java
deleted file mode 100644
index dcbc43132ccc8..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpan.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.tracing;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.function.Supplier;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.SpanStatus;
-
-/**
- * Noop and null-safe implementation of Span.
- */
-public class NoopSpan implements Span {
- /** Instance. */
- public static final Span INSTANCE = new NoopSpan();
-
- /**
- * Constructor.
- */
- private NoopSpan() {
-
- }
-
- /** {@inheritDoc} */
- @Override public Span addTag(String tagName, Supplier tagValSupplier) {
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public Span addLog(Supplier logDescSupplier) {
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public Span setStatus(SpanStatus spanStatus) {
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public Span end() {
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEnded() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public SpanType type() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Set includedScopes() {
- return Collections.emptySet();
- }
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpanManager.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpanManager.java
deleted file mode 100644
index 0d948b5d41fb1..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/NoopSpanManager.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.tracing;
-
-import org.apache.ignite.plugin.extensions.communication.Message;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Noop implementation of {@link SpanManager}.
- */
-public class NoopSpanManager implements SpanManager {
- /** Noop serialized span. */
- public static final byte[] NOOP_SERIALIZED_SPAN = new byte[0];
-
- /** {@inheritDoc} */
- @Override public Span create(@NotNull SpanType spanType, @Nullable Span parentSpan) {
- return NoopSpan.INSTANCE;
- }
-
- /** {@inheritDoc} */
- @Override public Span create(@NotNull SpanType spanType, @Nullable byte[] serializedParentSpan) {
- return NoopSpan.INSTANCE;
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull Span create(
- @NotNull SpanType spanType,
- @Nullable Span parentSpan,
- @Nullable String lb) {
- return NoopSpan.INSTANCE;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] serialize(@NotNull Span span) {
- return NOOP_SERIALIZED_SPAN;
- }
-
- /** {@inheritDoc} */
- @Override public String traceName(Message msg) {
- return null;
- }
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/Span.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/Span.java
deleted file mode 100644
index 3fbeb2300269b..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/Span.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.tracing;
-
-import java.util.Set;
-import java.util.function.Supplier;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.SpanStatus;
-
-/**
- * Logical piece of a trace that represents a single operation.
- * Each unit work is called a Span in a trace.
- * Spans include metadata about the work, including the time spent in the step (latency),
- * status, time events, attributes, links.
- * You can use tracing to debug errors and latency issues in your applications.
- */
-public interface Span {
- /**
- * Adds tag to span with {@code String} value.
- *
- * @param tagName Tag name.
- * @param tagValSupplier Tag value supplier. Supplier is used instead of strict tag value cause of it's lazy nature.
- * So that it's possible not to generate String tag value in case of NoopSpan.
- */
- Span addTag(String tagName, Supplier tagValSupplier);
-
- /**
- * Logs work to span.
- *
- * @param logDescSupplier Log description supplier.
- * Supplier is used instead of strict log description cause of it's lazy nature.
- * So that it's possible not to generate String log description in case of NoopSpan.
- */
- Span addLog(Supplier logDescSupplier);
-
- /**
- * Explicitly set status for span.
- *
- * @param spanStatus Status.
- */
- Span setStatus(SpanStatus spanStatus);
-
- /**
- * Ends span. This action sets default status if not set and mark the span as ready to be exported.
- */
- Span end();
-
- /**
- * @return {@code true} if span has already ended.
- */
- boolean isEnded();
-
- /**
- * @return Type of given span.
- */
- SpanType type();
-
- /**
- * @return Set of included scopes.
- */
- Set includedScopes();
-
- /**
- * @param scope Chainable scope candidate.
- * @return {@code true} if given span is chainable with other spans with specified scope.
- */
- default boolean isChainable(Scope scope) {
- return type().scope() == scope || includedScopes().contains(scope);
- }
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanManager.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanManager.java
deleted file mode 100644
index be43ec4cabb7c..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanManager.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.tracing;
-
-import org.apache.ignite.plugin.extensions.communication.Message;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Manager for {@link Span} instances.
- */
-public interface SpanManager {
- /**
- * Creates Span with given name.
- *
- * @param spanType Type of span to create.
- */
- default Span create(@NotNull SpanType spanType) {
- return create(spanType, (Span)null);
- }
-
- /**
- * Creates Span given name and explicit parent.
- *
- * @param spanType Type of span to create.
- * @param parentSpan Parent span.
- * @return Created span.
- */
- Span create(@NotNull SpanType spanType, @Nullable Span parentSpan);
-
- /**
- * Creates Span given name and explicit parent.
- *
- * @param spanType Type of span to create.
- * @param serializedParentSpan Parent span as serialized bytes.
- * @return Created span.
- */
- Span create(@NotNull SpanType spanType, @Nullable byte[] serializedParentSpan);
-
- /**
- * Creates Span given name and explicit parent.
- *
- * @param spanType Type of span to create.
- * @param parentSpan Parent span.
- * @param lb Label.
- * @return Created span.
- */
- @NotNull Span create(
- @NotNull SpanType spanType,
- @Nullable Span parentSpan,
- @Nullable String lb);
-
- /**
- * Serializes span to byte array to send context over network.
- *
- * @param span Span.
- */
- byte[] serialize(@NotNull Span span);
-
- /**
- * @param msg Message to resolve a trace name for.
- * @return Trace name of the message, or {@code null} if tracing is disabled.
- */
- @Nullable String traceName(Message msg);
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanTags.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanTags.java
deleted file mode 100644
index 76d8100e1c4e0..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanTags.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.tracing;
-
-/**
- * List of tags that can be used to decorate spans.
- */
-public class SpanTags {
- /** Tag parts default delimiter. */
- private static final String TAG_PARTS_DELIMITER = ".";
-
- /**
- * List of basic tags. Can be combined together to get more composite tags.
- * Don't forget to add new tags here and use constant reference instead of raw string creation.
- * Frequently used composite tags can be also declared here.
- */
-
- /** */
- public static final String NODE = "node";
-
- /** */
- public static final String ID = "id";
-
- /** */
- public static final String ORDER = "order";
-
- /** */
- public static final String EVENT = "event";
-
- /** */
- public static final String NAME = "name";
-
- /** */
- public static final String TYPE = "type";
-
- /** */
- public static final String INITIAL = "initial";
-
- /** */
- public static final String RESULT = "result";
-
- /** */
- public static final String ERROR = "error";
-
- /** */
- public static final String EXCHANGE = "exchange";
-
- /** */
- public static final String CONSISTENT_ID = "consistent.id";
-
- /** */
- public static final String TOPOLOGY_VERSION = "topology.version";
-
- /** */
- public static final String MAJOR = "major";
-
- /** */
- public static final String MINOR = "minor";
-
- /** */
- public static final String EVENT_NODE = tag(EVENT, NODE);
-
- /** */
- public static final String NODE_ID = tag(NODE, ID);
-
- /** */
- public static final String MESSAGE = "message";
-
- /** Number of bytes that were written to the socket. */
- public static final String SOCKET_WRITE_BYTES = "socket.write.bytes";
-
- /** */
- public static final String MESSAGE_CLASS = "message.class";
-
- /** Text of SQL query. */
- public static final String SQL_QRY_TEXT = "sql.query.text";
-
- /** SQL schema. */
- public static final String SQL_SCHEMA = "sql.schema";
-
- /** Number of rows that result page contains. */
- public static final String SQL_PAGE_ROWS = "sql.page.rows";
-
- /** Number of rows that index range request contains. */
- public static final String SQL_IDX_RANGE_ROWS = "sql.index.range.rows";
-
- /** Name of SQL table. */
- public static final String SQL_TABLE = "sql.table";
-
- /** Name of SQL index. */
- public static final String SQL_IDX = "sql.index";
-
- /** Number of cache entries to be updated as a result of DML query. */
- public static final String SQL_CACHE_UPDATES = "sql.cache.updates";
-
- /** Whether parsing of the SQL query was skipped due to the cached result. */
- public static final String SQL_PARSER_CACHE_HIT = "sql.parser.cache.hit";
-
- /** Query identifier. */
- public static final String SQL_QRY_ID = "sql.query.id";
-
- /** */
- private SpanTags() {}
-
- /**
- * @param tagParts String parts of composite tag.
- * @return Composite tag with given parts joined using delimiter.
- */
- public static String tag(String... tagParts) {
- return String.join(TAG_PARTS_DELIMITER, tagParts);
- }
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanType.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanType.java
deleted file mode 100644
index 693bb9630e495..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/SpanType.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.tracing;
-
-import org.apache.ignite.spi.tracing.Scope;
-
-/**
- * List of span type names used in appropriate sub-systems.
- */
-public enum SpanType {
- // Discovery traces.
- /** Node join request. */
- DISCOVERY_NODE_JOIN_REQUEST(Scope.DISCOVERY, "discovery.node.join.request", 1, true),
-
- /** Node join add. */
- DISCOVERY_NODE_JOIN_ADD(Scope.DISCOVERY, "discovery.node.join.add", 2),
-
- /** Node join finish. */
- DISCOVERY_NODE_JOIN_FINISH(Scope.DISCOVERY, "discovery.node.join.finish", 3),
-
- /** Node failed. */
- DISCOVERY_NODE_FAILED(Scope.DISCOVERY, "discovery.node.failed", 4, true),
-
- /** Node left. */
- DISCOVERY_NODE_LEFT(Scope.DISCOVERY, "discovery.node.left", 5, true),
-
- /** Custom event. */
- DISCOVERY_CUSTOM_EVENT(Scope.DISCOVERY, "discovery.custom.event", 6, true),
-
- /** Exchange future. */
- EXCHANGE_FUTURE(Scope.DISCOVERY, "exchange.future", 7),
-
- /** Affinity calculation. */
- AFFINITY_CALCULATION(Scope.DISCOVERY, "affinity.calculation", 8),
-
- // Communication traces.
- /** Job execution request. */
- COMMUNICATION_JOB_EXECUTE_REQUEST(Scope.COMMUNICATION, "communication.job.execute.request", 9),
-
- /** Job execution response. */
- COMMUNICATION_JOB_EXECUTE_RESPONSE(Scope.COMMUNICATION, "communication.job.execute.response", 10),
-
- /** Socket write action. */
- COMMUNICATION_SOCKET_WRITE(Scope.COMMUNICATION, "socket.write", 11, true),
-
- /** Socket read action. */
- COMMUNICATION_SOCKET_READ(Scope.COMMUNICATION, "socket.read", 12),
-
- /** Process regular. */
- COMMUNICATION_REGULAR_PROCESS(Scope.COMMUNICATION, "process.regular", 13),
-
- /** Process ordered. */
- COMMUNICATION_ORDERED_PROCESS(Scope.COMMUNICATION, "process.ordered", 14),
-
- // Tx traces.
- /** Transaction start. */
- TX(Scope.TX, "transaction", 15, true),
-
- /** Transaction commit. */
- TX_COMMIT(Scope.TX, "transactions.commit", 16),
-
- /** Transaction rollback. */
- TX_ROLLBACK(Scope.TX, "transactions.rollback", 17),
-
- /** Transaction close. */
- TX_CLOSE(Scope.TX, "transactions.close", 18),
-
- /** Transaction suspend. */
- TX_SUSPEND(Scope.TX, "transactions.suspend", 19),
-
- /** Transaction resume. */
- TX_RESUME(Scope.TX, "transactions.resume", 20),
-
- /** Transaction near prepare. */
- TX_NEAR_PREPARE(Scope.TX, "transactions.near.prepare", 21),
-
- /** Transaction near prepare ondone. */
- TX_NEAR_PREPARE_ON_DONE(Scope.TX, "transactions.near.prepare.ondone", 22),
-
- /** Transaction near prepare onerror. */
- TX_NEAR_PREPARE_ON_ERROR(Scope.TX, "transactions.near.prepare.onerror", 23),
-
- /** Transaction near prepare ontimeout. */
- TX_NEAR_PREPARE_ON_TIMEOUT(Scope.TX, "transactions.near.prepare.ontimeout", 24),
-
- /** Transaction dht prepare. */
- TX_DHT_PREPARE(Scope.TX, "transactions.dht.prepare", 25),
-
- /** Transaction dht prepare ondone. */
- TX_DHT_PREPARE_ON_DONE(Scope.TX, "transactions.dht.prepare.ondone", 26),
-
- /** Transaction near finish. */
- TX_NEAR_FINISH(Scope.TX, "transactions.near.finish", 27),
-
- /** Transaction near finish ondone. */
- TX_NEAR_FINISH_ON_DONE(Scope.TX, "transactions.near.finish.ondone", 28),
-
- /** Transaction dht finish. */
- TX_DHT_FINISH(Scope.TX, "transactions.dht.finish", 29),
-
- /** Transaction dht finish ondone. */
- TX_DHT_FINISH_ON_DONE(Scope.TX, "transactions.dht.finish.ondone", 30),
-
- /** Transaction map proceed. */
- TX_MAP_PROCEED(Scope.TX, "transactions.lock.map.proceed", 31),
-
- /** Transaction map proceed. */
- TX_COLOCATED_LOCK_MAP(Scope.TX, "transactions.colocated.lock.map", 32),
-
- /** Transaction lock map. */
- TX_DHT_LOCK_MAP(Scope.TX, "transactions.dht.lock.map", 33),
-
- /** Transaction near enlist read. */
- TX_NEAR_ENLIST_READ(Scope.TX, "transactions.near.enlist.read", 34),
-
- /** Transaction near enlist write. */
- TX_NEAR_ENLIST_WRITE(Scope.TX, "transactions.near.enlist.write", 35),
-
- /** Transaction dht process prepare request. */
- TX_PROCESS_DHT_PREPARE_REQ(Scope.TX, "tx.dht.process.prepare.req", 36),
-
- /** Transaction dht process finish request. */
- TX_PROCESS_DHT_FINISH_REQ(Scope.TX, "tx.dht.process.finish.req", 37),
-
- /** Transaction dht finish response. */
- TX_PROCESS_DHT_FINISH_RESP(Scope.TX, "tx.dht.process.finish.resp", 38),
-
- /** Transaction dht one phase commit ack request. */
- TX_PROCESS_DHT_ONE_PHASE_COMMIT_ACK_REQ(Scope.TX, "tx.dht.process.one-phase-commit-ack.req", 39),
-
- /** Transaction dht prepare response. */
- TX_PROCESS_DHT_PREPARE_RESP(Scope.TX, "tx.dht.process.prepare.response", 40),
-
- /** Transaction near finish request. */
- TX_NEAR_FINISH_REQ(Scope.TX, "tx.near.process.finish.request", 41),
-
- /** Transaction near finish response. */
- TX_NEAR_FINISH_RESP(Scope.TX, "tx.near.process.finish.response", 42),
-
- /** Transaction near prepare request. */
- TX_NEAR_PREPARE_REQ(Scope.TX, "tx.near.process.prepare.request", 43),
-
- /** Transaction near prepare response. */
- TX_NEAR_PREPARE_RESP(Scope.TX, "tx.near.process.prepare.response", 44),
-
- /** Custom job call. */
- CUSTOM_JOB_CALL(Scope.COMMUNICATION, "job.call", 45, true),
-
- /** The overall execution of SQL query. */
- SQL_QRY(Scope.SQL, "sql.query", 46, true),
-
- /** Opening SQL query cursor. */
- SQL_CURSOR_OPEN(Scope.SQL, "sql.cursor.open", 47),
-
- /** Closing SQL query cursor. */
- SQL_CURSOR_CLOSE(Scope.SQL, "sql.cursor.close", 48),
-
- /** Cancellation SQL query cursor. */
- SQL_CURSOR_CANCEL(Scope.SQL, "sql.cursor.cancel", 49),
-
- /** Parsing SQL query. */
- SQL_QRY_PARSE(Scope.SQL, "sql.query.parse", 50),
-
- /** Processing SQL query execution request. */
- SQL_QRY_EXEC_REQ(Scope.SQL, "sql.query.execute.request", 51),
-
- /** Processing SQL next result page request. */
- SQL_NEXT_PAGE_REQ(Scope.SQL, "sql.next.page.request", 52),
-
- /** Processing mapped node response with requested SQL result page. */
- SQL_PAGE_RESP(Scope.SQL, "sql.page.response", 53),
-
- /** Execution SQL query by H2. */
- SQL_QRY_EXECUTE(Scope.SQL, "sql.query.execute", 54),
-
- /** Reading rows from cursor and preparing result page. */
- SQL_PAGE_PREPARE(Scope.SQL, "sql.page.prepare", 55),
-
- /** Processing SQL query fail response. */
- SQL_FAIL_RESP(Scope.SQL, "sql.fail.response", 56),
-
- /** Processing DML query request. */
- SQL_DML_QRY_EXEC_REQ(Scope.SQL, "sql.dml.query.execute.request", 57),
-
- /** Processing DML query response. */
- SQL_DML_QRY_RESP(Scope.SQL, "sql.dml.query.response", 58),
-
- /** Processing query cancellation request. */
- SQL_QRY_CANCEL_REQ(Scope.SQL, "sql.query.cancel.request", 59),
-
- /** Opening cursor iterator. */
- SQL_ITER_OPEN(Scope.SQL, "sql.iterator.open", 60),
-
- /** Opening cursor iterator. */
- SQL_ITER_CLOSE(Scope.SQL, "sql.iterator.close", 61),
-
- /** Fetching SQL query result page. */
- SQL_PAGE_FETCH(Scope.SQL, "sql.page.fetch", 62),
-
- /** Waiting for SQL query results page to be received. */
- SQL_PAGE_WAIT(Scope.SQL, "sql.page.wait", 63),
-
- /** Processing SQL index range request. */
- SQL_IDX_RANGE_REQ(Scope.SQL, "sql.index.range.request", 64),
-
- /** Processing SQL index range response. */
- SQL_IDX_RANGE_RESP(Scope.SQL, "sql.index.range.response", 65),
-
- /** Execution of SQL DML query. */
- SQL_DML_QRY_EXECUTE(Scope.SQL, "sql.dml.query.execute", 66),
-
- /** Execution of SQL command query which either DDL SQL queries or Ignite native SQL commands. */
- SQL_CMD_QRY_EXECUTE(Scope.SQL, "sql.command.query.execute", 67),
-
- /** SQL query partitions reservation. */
- SQL_PARTITIONS_RESERVE(Scope.SQL, "sql.partitions.reserve", 68),
-
- /** Update of cache as a result of the SQL DML query. */
- SQL_CACHE_UPDATE(Scope.SQL, "sql.cache.update", 69),
-
- /** Processing of incoming batch. */
- SQL_BATCH_PROCESS(Scope.SQL, "sql.batch.process", 70);
-
- /** Scope */
- private Scope scope;
-
- /** Trace name. */
- private String spanName;
-
- /** Index. */
- private int idx;
-
- /** Values. */
- private static final SpanType[] VALS;
-
- /** {@code true} if given span is a root span within it's scope. */
- private boolean rootSpan;
-
- /**
- * Constructor.
- *
- * @param scope Scope.
- * @param spanName Span name.
- * @param idx Index.
- */
- SpanType(Scope scope, String spanName, int idx) {
- this.scope = scope;
- this.spanName = spanName;
- this.idx = idx;
- }
-
- /**
- * Constructor.
- *
- * @param scope Scope.
- * @param spanName Span name.
- * @param idx Index.
- * @param rootSpan Boolean flag, that indicates whether given span is root within it's scope or not.
- */
- SpanType(Scope scope, String spanName, int idx, boolean rootSpan) {
- this(scope, spanName, idx);
- this.rootSpan = rootSpan;
- }
-
- /**
- * @return Scope.
- */
- public Scope scope() {
- return scope;
- }
-
- /**
- * @return Trace name.
- */
- public String spanName() {
- return spanName;
- }
-
- /**
- * @return idx.
- */
- public int index() {
- return idx;
- }
-
- /**
- * @return Root span.
- */
- public boolean rootSpan() {
- return rootSpan;
- }
-
- static {
- SpanType[] spanTypes = SpanType.values();
-
- int maxIdx = 0;
-
- for (SpanType spanType : spanTypes)
- maxIdx = Math.max(maxIdx, spanType.idx);
-
- VALS = new SpanType[maxIdx + 1];
-
- for (SpanType spanType : spanTypes)
- VALS[spanType.idx] = spanType;
- }
-
- /**
- * @param idx Index.
- * @return Enum instance based on specified index.
- */
- public static SpanType fromIndex(int idx) {
- return idx < 0 || idx >= VALS.length ? null : VALS[idx];
- }
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/messages/SpanTransport.java b/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/messages/SpanTransport.java
deleted file mode 100644
index 6466be62eeb64..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/processors/tracing/messages/SpanTransport.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.tracing.messages;
-
-/**
- * This interface indicates class which able to transfer span.
- */
-public interface SpanTransport {
- /**
- * Stored span for transferring.
- *
- * @param span Binary view of span.
- */
- void span(byte[] span);
-
- /**
- * @return Binary view of span.
- */
- byte[] span();
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index fa23121fd1675..b0c73f5e8e84a 100644
--- a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -55,14 +55,6 @@
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.odbc.ClientMessage;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
-import org.apache.ignite.internal.processors.tracing.NoopSpan;
-import org.apache.ignite.internal.processors.tracing.NoopSpanManager;
-import org.apache.ignite.internal.processors.tracing.Span;
-import org.apache.ignite.internal.processors.tracing.SpanManager;
-import org.apache.ignite.internal.processors.tracing.SpanTags;
-import org.apache.ignite.internal.processors.tracing.SpanType;
import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.GridUnsafe;
@@ -92,8 +84,6 @@
import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR;
import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SOCKET_WRITE_BYTES;
-import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_WRITE;
import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.MSG_WRITER;
import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.NIO_OPERATION;
@@ -291,9 +281,6 @@ public class GridNioServer {
*/
private final boolean readWriteSelectorsAssign;
- /** Span manager. */
- private SpanManager tracing;
-
/** Message factory. */
private final MessageFactory msgFactory;
@@ -354,7 +341,6 @@ private GridNioServer(
@Nullable LongConsumer sentBytesCntMetric,
@Nullable LongConsumer outboundMessagesQueueSizeMetric,
@Nullable LongConsumer maxMessagesQueueSizeMetric,
- SpanManager tracing,
MessageFactory msgFactory,
GridNioFilter... filters
) throws IgniteCheckedException {
@@ -386,7 +372,6 @@ private GridNioServer(
this.sentBytesCntMetric = sentBytesCntMetric;
this.outboundMessagesQueueSizeMetric = outboundMessagesQueueSizeMetric;
this.maxMessagesQueueSizeMetric = maxMessagesQueueSizeMetric;
- this.tracing = tracing == null ? new NoopSpanManager() : tracing;
this.msgFactory = msgFactory;
filterChain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters);
@@ -1298,21 +1283,15 @@ else if (cnt == 0)
}
if (!skipWrite) {
- Span span = tracing.create(COMMUNICATION_SOCKET_WRITE, req.span());
-
- try (TraceSurroundings ignore = span.equals(NoopSpan.INSTANCE) ? null : MTC.support(span)) {
- int cnt = sockCh.write(buf);
-
- if (log.isTraceEnabled())
- log.trace("Bytes sent [sockCh=" + sockCh + ", cnt=" + cnt + ']');
+ int cnt = sockCh.write(buf);
- span.addTag(SOCKET_WRITE_BYTES, () -> Integer.toString(cnt));
+ if (log.isTraceEnabled())
+ log.trace("Bytes sent [sockCh=" + sockCh + ", cnt=" + cnt + ']');
- if (sentBytesCntMetric != null)
- sentBytesCntMetric.accept(cnt);
+ if (sentBytesCntMetric != null)
+ sentBytesCntMetric.accept(cnt);
- ses.bytesSent(cnt);
- }
+ ses.bytesSent(cnt);
}
else {
// For test purposes only (skipWrite is set to true in tests only).
@@ -1626,39 +1605,29 @@ private boolean writeToBuffer(
boolean finished;
msg = (Message)req.message();
- Span span = tracing.create(SpanType.COMMUNICATION_SOCKET_WRITE, req.span());
-
- try (TraceSurroundings ignore = span.equals(NoopSpan.INSTANCE) ? null : MTC.support(span)) {
- span.addTag(SpanTags.MESSAGE, () -> tracing.traceName(msg));
-
- assert msg != null;
-
- int startPos = buf.position();
-
- if (messageFactory() == null) {
- assert msg instanceof ClientMessage; // TODO: Will refactor in IGNITE-26554.
-
- finished = ((ClientMessage)msg).writeTo(buf);
- }
- else {
- MessageSerializer msgSer = messageFactory().serializer(msg.directType());
+ assert msg != null;
- writer.setBuffer(buf);
+ if (messageFactory() == null) {
+ assert msg instanceof ClientMessage; // TODO: Will refactor in IGNITE-26554.
- finished = msgSer.writeTo(msg, writer);
- }
+ finished = ((ClientMessage)msg).writeTo(buf);
+ }
+ else {
+ MessageSerializer msgSer = messageFactory().serializer(msg.directType());
- span.addTag(SOCKET_WRITE_BYTES, () -> Integer.toString(buf.position() - startPos));
+ writer.setBuffer(buf);
- if (finished) {
- pendingRequests.add(req);
+ finished = msgSer.writeTo(msg, writer);
+ }
- if (writer != null)
- writer.reset();
- }
+ if (finished) {
+ pendingRequests.add(req);
- return finished;
+ if (writer != null)
+ writer.reset();
}
+
+ return finished;
}
/**
@@ -1829,37 +1798,27 @@ private boolean writeToBuffer(GridSelectorNioSessionImpl ses, ByteBuffer buf, Se
assert msg != null : req;
- Span span = tracing.create(SpanType.COMMUNICATION_SOCKET_WRITE, req.span());
-
- try (TraceSurroundings ignore = span.equals(NoopSpan.INSTANCE) ? null : MTC.support(span)) {
- span.addTag(SpanTags.MESSAGE, () -> tracing.traceName(msg));
-
- int startPos = buf.position();
-
- if (msgFactory == null) {
- assert msg instanceof ClientMessage; // TODO: Will refactor in IGNITE-26554.
-
- finished = ((ClientMessage)msg).writeTo(buf);
- }
- else {
- MessageSerializer msgSer = msgFactory.serializer(msg.directType());
+ if (msgFactory == null) {
+ assert msg instanceof ClientMessage; // TODO: Will refactor in IGNITE-26554.
- writer.setBuffer(buf);
-
- finished = msgSer.writeTo(msg, writer);
- }
+ finished = ((ClientMessage)msg).writeTo(buf);
+ }
+ else {
+ MessageSerializer msgSer = msgFactory.serializer(msg.directType());
- span.addTag(SOCKET_WRITE_BYTES, () -> Integer.toString(buf.position() - startPos));
+ writer.setBuffer(buf);
- if (finished) {
- onMessageWritten(ses, msg);
+ finished = msgSer.writeTo(msg, writer);
+ }
- if (writer != null)
- writer.reset();
- }
+ if (finished) {
+ onMessageWritten(ses, msg);
- return finished;
+ if (writer != null)
+ writer.reset();
}
+
+ return finished;
}
/** {@inheritDoc} */
@@ -2777,7 +2736,6 @@ private void register(NioOperationFuture fut) {
sndQueueLimit,
outboundMessagesQueueSizeMetric,
maxMessagesQueueSizeMetric,
- tracing,
writeBuf,
readBuf);
@@ -3309,9 +3267,6 @@ private static final class WriteRequestSystemImpl implements SessionWriteRequest
/** */
private final GridNioSession ses;
- /** */
- private Span span;
-
/** @param ses Session. */
WriteRequestSystemImpl(GridNioSession ses) {
this(ses, null);
@@ -3324,7 +3279,6 @@ private static final class WriteRequestSystemImpl implements SessionWriteRequest
WriteRequestSystemImpl(GridNioSession ses, Object msg) {
this.ses = ses;
this.msg = msg;
- this.span = MTC.span();
}
/** {@inheritDoc} */
@@ -3377,11 +3331,6 @@ private static final class WriteRequestSystemImpl implements SessionWriteRequest
return NioOperation.REQUIRE_WRITE;
}
- /** {@inheritDoc} */
- @Override public Span span() {
- return span;
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(WriteRequestSystemImpl.class, this);
@@ -3407,9 +3356,6 @@ static final class WriteRequestImpl implements SessionWriteRequest, SessionChang
/** */
private final IgniteInClosure ackC;
- /** Span for tracing. */
- private Span span;
-
/**
* @param ses Session.
* @param msg Message.
@@ -3424,7 +3370,6 @@ static final class WriteRequestImpl implements SessionWriteRequest, SessionChang
this.msg = msg;
this.skipRecovery = skipRecovery;
this.ackC = ackC;
- this.span = MTC.span();
}
/** {@inheritDoc} */
@@ -3477,11 +3422,6 @@ static final class WriteRequestImpl implements SessionWriteRequest, SessionChang
return NioOperation.REQUIRE_WRITE;
}
- /** {@inheritDoc} */
- @Override public Span span() {
- return span;
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(WriteRequestImpl.class, this);
@@ -3519,9 +3459,6 @@ private static class NioOperationFuture extends GridFutureAdapter implemen
@GridToStringExclude
private boolean skipRecovery;
- /** */
- private Span span;
-
/** */
private boolean msgThread;
@@ -3543,7 +3480,6 @@ private static class NioOperationFuture extends GridFutureAdapter implemen
this.sockCh = sockCh;
this.accepted = accepted;
this.meta = meta;
- this.span = MTC.span();
}
/**
@@ -3559,7 +3495,6 @@ private static class NioOperationFuture extends GridFutureAdapter implemen
this.ses = ses;
this.op = op;
- this.span = MTC.span();
}
/**
@@ -3582,7 +3517,6 @@ private static class NioOperationFuture extends GridFutureAdapter implemen
this.ses = ses;
this.op = op;
this.msg = msg;
- this.span = MTC.span();
this.ackC = ackC;
}
@@ -3609,7 +3543,6 @@ private static class NioOperationFuture extends GridFutureAdapter implemen
this.op = op;
this.msg = commMsg;
this.skipRecovery = skipRecovery;
- this.span = MTC.span();
this.ackC = ackC;
}
@@ -3623,11 +3556,6 @@ private static class NioOperationFuture extends GridFutureAdapter implemen
return op;
}
- /** {@inheritDoc} */
- @Override public Span span() {
- return span;
- }
-
/** {@inheritDoc} */
@Override public Object message() {
return msg;
@@ -3941,9 +3869,6 @@ public static class Builder {
/** Per-session maximum outbound messages queue size metric. */
private LongConsumer maxMessagesQueueSizeMetric;
- /** Span manager */
- private SpanManager tracing;
-
/** Message factory. */
private MessageFactory msgFactory;
@@ -3980,7 +3905,6 @@ public GridNioServer build() throws IgniteCheckedException {
sentBytesCntMetric,
outboundMessagesQueueSizeMetric,
maxMessagesQueueSizeMetric,
- tracing,
msgFactory,
filters != null ? Arrays.copyOf(filters, filters.length) : EMPTY_FILTERS
);
@@ -4004,16 +3928,6 @@ public Builder readWriteSelectorsAssign(boolean readWriteSelectorsAssign) {
return this;
}
- /**
- * @param tracing Span manager.
- * @return This for chaining.
- */
- public Builder tracing(SpanManager tracing) {
- this.tracing = tracing;
-
- return this;
- }
-
/**
* @param addr Local address.
* @return This for chaining.
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
deleted file mode 100644
index 47644636def68..0000000000000
--- a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.util.nio;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.NoopSpan;
-import org.apache.ignite.internal.processors.tracing.NoopSpanManager;
-import org.apache.ignite.internal.processors.tracing.Span;
-import org.apache.ignite.internal.processors.tracing.SpanManager;
-import org.apache.ignite.internal.processors.tracing.messages.SpanTransport;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteInClosure;
-
-import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_READ;
-
-/**
- * Filter that inject and extract tracing span from/to process.
- */
-public class GridNioTracerFilter extends GridNioFilterAdapter {
- /** Grid logger. */
- @GridToStringExclude
- private IgniteLogger log;
-
- /** Tracing processor. */
- private final SpanManager tracer;
-
- /**
- * Creates a tracer filter.
- *
- * @param log Log instance to use.
- * @param tracer Tracing processor.
- */
- public GridNioTracerFilter(IgniteLogger log, SpanManager tracer) {
- super("GridNioTracerFilter");
-
- this.log = log;
- this.tracer = tracer == null ? new NoopSpanManager() : tracer;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridNioTracerFilter.class, this);
- }
-
- /** {@inheritDoc} */
- @Override public void onSessionOpened(GridNioSession ses) throws IgniteCheckedException {
- proceedSessionOpened(ses);
- }
-
- /** {@inheritDoc} */
- @Override public void onSessionClosed(GridNioSession ses) throws IgniteCheckedException {
- proceedSessionClosed(ses);
- }
-
- /** {@inheritDoc} */
- @Override public void onExceptionCaught(
- GridNioSession ses,
- IgniteCheckedException ex
- ) throws IgniteCheckedException {
- proceedExceptionCaught(ses, ex);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture> onSessionWrite(
- GridNioSession ses,
- Object msg,
- boolean fut,
- IgniteInClosure ackC
- ) throws IgniteCheckedException {
- if (msg instanceof SpanTransport && MTC.span() != NoopSpan.INSTANCE)
- ((SpanTransport)msg).span(tracer.serialize(MTC.span()));
-
- return proceedSessionWrite(ses, msg, fut, ackC);
-
- }
-
- /** {@inheritDoc} */
- @Override public void onMessageReceived(GridNioSession ses, Object msg) throws IgniteCheckedException {
- byte[] serializedSpan = msg instanceof SpanTransport ? ((SpanTransport)msg).span() : null;
-
- if (serializedSpan != null && serializedSpan.length != 0) {
- Span span = tracer.create(COMMUNICATION_SOCKET_READ, serializedSpan);
-
- try (MTC.TraceSurroundings ignore = MTC.support(span)) {
- proceedMessageReceived(ses, msg);
- }
- }
- else
- proceedMessageReceived(ses, msg);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture onSessionClose(GridNioSession ses) throws IgniteCheckedException {
- return proceedSessionClose(ses);
- }
-
- /** {@inheritDoc} */
- @Override public void onSessionIdleTimeout(GridNioSession ses) throws IgniteCheckedException {
- proceedSessionIdleTimeout(ses);
- }
-
- /** {@inheritDoc} */
- @Override public void onSessionWriteTimeout(GridNioSession ses) throws IgniteCheckedException {
- proceedSessionWriteTimeout(ses);
- }
-}
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
index 267851bac0f57..3874c5277e524 100644
--- a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
@@ -30,12 +30,9 @@
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.SpanManager;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.util.deque.FastSizeDeque;
import org.jetbrains.annotations.Nullable;
@@ -92,9 +89,6 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
/** Maximum outbound messages queue size metric. */
@Nullable private final LongConsumer maxMessagesQueueSizeMetric;
- /** Span manager used to resolve trace names for logging. */
- private final SpanManager tracing;
-
/**
* Creates session instance.
*
@@ -107,7 +101,6 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
* @param sndQueueLimit Send queue limit.
* @param outboundMessagesQueueSizeMetric Outbound messages queue size metric, or {@code null} if metrics disabled.
* @param maxMessagesQueueSizeMetric Maximum outbound messages queue size metric, or {@code null} if metrics disabled.
- * @param tracing Span manager used to resolve trace names for logging.
* @param writeBuf Write buffer.
* @param readBuf Read buffer.
*/
@@ -121,7 +114,6 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
int sndQueueLimit,
@Nullable LongConsumer outboundMessagesQueueSizeMetric,
@Nullable LongConsumer maxMessagesQueueSizeMetric,
- SpanManager tracing,
@Nullable ByteBuffer writeBuf,
@Nullable ByteBuffer readBuf
) {
@@ -156,8 +148,6 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
this.outboundMessagesQueueSizeMetric = outboundMessagesQueueSizeMetric;
this.maxMessagesQueueSizeMetric = maxMessagesQueueSizeMetric;
-
- this.tracing = tracing;
}
/** {@inheritDoc} */
@@ -319,8 +309,6 @@ int offerSystemFuture(SessionWriteRequest writeFut) {
boolean res = queue.offerFirst(writeFut);
- MTC.span().addLog(() -> "Added to system queue - " + tracing.traceName((Message)writeFut.message()));
-
assert res : "Future was not added to queue";
if (outboundMessagesQueueSizeMetric != null)
@@ -357,8 +345,6 @@ int offerFuture(SessionWriteRequest writeFut) {
boolean res = queue.offer(writeFut);
- MTC.span().addLog(() -> "Added to queue - " + tracing.traceName((Message)writeFut.message()));
-
assert res : "Future was not added to queue";
if (outboundMessagesQueueSizeMetric != null)
diff --git a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java
index 8f86dc02c227b..7b9ca9c3e3162 100644
--- a/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.util.nio;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.processors.tracing.Span;
import org.apache.ignite.lang.IgniteInClosure;
/**
@@ -71,11 +70,4 @@ public interface SessionWriteRequest {
*
*/
public void onMessageWritten();
-
- /**
- * Stored span for tracing.
- *
- * @return Span.
- */
- Span span();
}
diff --git a/modules/opencensus/pom.xml b/modules/opencensus/pom.xml
index 8bd8bf01e28aa..3b0d5e3951cf5 100644
--- a/modules/opencensus/pom.xml
+++ b/modules/opencensus/pom.xml
@@ -88,13 +88,6 @@
${grpc-context.version}
-
- io.opencensus
- opencensus-exporter-trace-zipkin
- ${opencensus.version}
- test
-
-
io.opencensusopencensus-exporter-stats-prometheus
@@ -115,12 +108,6 @@
${commons.io.version}test
-
-
- ${project.groupId}
- ignite-indexing
- test
-
diff --git a/modules/opencensus/src/main/java/io/opencensus/exporter/trace/TimeLimitedHandler.java b/modules/opencensus/src/main/java/io/opencensus/exporter/trace/TimeLimitedHandler.java
deleted file mode 100644
index 5cf26c3cd22e2..0000000000000
--- a/modules/opencensus/src/main/java/io/opencensus/exporter/trace/TimeLimitedHandler.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.opencensus.exporter.trace;
-
-import java.util.Collection;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import com.google.common.util.concurrent.SimpleTimeLimiter;
-import com.google.common.util.concurrent.TimeLimiter;
-import com.google.errorprone.annotations.MustBeClosed;
-import io.opencensus.common.Duration;
-import io.opencensus.common.Scope;
-import io.opencensus.trace.Sampler;
-import io.opencensus.trace.Span;
-import io.opencensus.trace.Status;
-import io.opencensus.trace.TraceOptions;
-import io.opencensus.trace.Tracer;
-import io.opencensus.trace.export.SpanData;
-import io.opencensus.trace.export.SpanExporter;
-import io.opencensus.trace.export.SpanExporter.Handler;
-import io.opencensus.trace.samplers.Samplers;
-
-/**
- * Copy-pasted from OpenCensus library handler to avoid package-private access.
- *
- * An abstract class that allows different tracing services to export recorded data for sampled
- * spans in their own format within a given time frame. If export does not complete within the time
- * frame, spans will be dropped and no retries will be performed.
- *
- *
Only extend this class if the client APIs don't support timeout natively. If there is a
- * timeout option in the client APIs (for example Stackdriver Trace V2 API allows you to set
- * timeout), use that instead.
- *
- *
To export data this MUST be register to to the ExportComponent using {@link
- * SpanExporter#registerHandler(String, Handler)}.
- *
- * @since 0.22
- */
-public abstract class TimeLimitedHandler extends SpanExporter.Handler {
- /** Logger. */
- private static final Logger logger = Logger.getLogger(TimeLimitedHandler.class.getName());
-
- /** Low probability sampler. */
- private static final Sampler lowProbabilitySampler = Samplers.probabilitySampler(0.0001);
-
- /** Tracer. */
- private final Tracer tracer;
-
- /** Deadline. */
- private final Duration deadline;
-
- /** Export span name. */
- private final String exportSpanName;
-
- /**
- * @param tracer Tracer.
- * @param deadline Deadline.
- * @param exportSpanName Export span name.
- */
- protected TimeLimitedHandler(Tracer tracer, Duration deadline, String exportSpanName) {
- this.tracer = tracer;
- this.deadline = deadline;
- this.exportSpanName = exportSpanName;
- }
-
- /**
- * Exports a list of sampled (see {@link TraceOptions#isSampled()}) {@link Span}s using the
- * immutable representation {@link SpanData}, within the given {@code deadline} of this {@link
- * TimeLimitedHandler}.
- *
- * @param spanDataList a list of {@code SpanData} objects to be exported.
- * @throws Exception throws exception when failed to export.
- * @since 0.22
- */
- public abstract void timeLimitedExport(Collection spanDataList) throws Exception;
-
- /** {@inheritDoc} */
- @Override public void export(final Collection spanDataList) {
- final Scope exportScope = newExportScope();
- try {
- TimeLimiter timeLimiter = SimpleTimeLimiter.create(Executors.newSingleThreadExecutor());
- timeLimiter.callWithTimeout(
- new Callable() {
- @Override public Void call() throws Exception {
- timeLimitedExport(spanDataList);
- return null;
- }
- },
- deadline.toMillis(),
- TimeUnit.MILLISECONDS);
- }
- catch (TimeoutException e) {
- handleException(e, "Timeout when exporting traces: " + e);
- }
- catch (InterruptedException e) {
- handleException(e, "Interrupted when exporting traces: " + e);
- }
- catch (Exception e) {
- handleException(e, "Failed to export traces: " + e);
- }
- finally {
- exportScope.close();
- }
- }
-
- /**
- *
- */
- @MustBeClosed
- private Scope newExportScope() {
- return tracer.spanBuilder(exportSpanName).setSampler(lowProbabilitySampler).startScopedSpan();
- }
-
- /**
- * @param e Exception.
- * @param logMessage Logger message.
- */
- private void handleException(Exception e, String logMessage) {
- Status status = e instanceof TimeoutException ? Status.DEADLINE_EXCEEDED : Status.UNKNOWN;
- tracer
- .getCurrentSpan()
- .setStatus(
- status.withDescription(
- e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage()));
- logger.log(Level.WARNING, logMessage);
- }
-}
diff --git a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusSpanAdapter.java b/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusSpanAdapter.java
deleted file mode 100644
index 14c577ec5de8a..0000000000000
--- a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusSpanAdapter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.spi.tracing.opencensus;
-
-import io.opencensus.trace.AttributeValue;
-import org.apache.ignite.spi.tracing.SpanStatus;
-import org.apache.ignite.spi.tracing.SpiSpecificSpan;
-
-/**
- * Span implementation based on OpenCensus library.
- */
-public class OpenCensusSpanAdapter implements SpiSpecificSpan {
- /** OpenCensus span delegate. */
- private final io.opencensus.trace.Span span;
-
- /** Flag indicates that span is ended. */
- private volatile boolean ended;
-
- /**
- * @param span OpenCensus span delegate.
- */
- OpenCensusSpanAdapter(io.opencensus.trace.Span span) {
- this.span = span;
- }
-
- /** @return Implementation object. */
- public io.opencensus.trace.Span impl() {
- return span;
- }
-
- /** {@inheritDoc} */
- @Override public OpenCensusSpanAdapter addTag(String tagName, String tagVal) {
- tagVal = tagVal != null ? tagVal : "null";
-
- span.putAttribute(tagName, AttributeValue.stringAttributeValue(tagVal));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public OpenCensusSpanAdapter addLog(String logDesc) {
- span.addAnnotation(logDesc);
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public OpenCensusSpanAdapter setStatus(SpanStatus spanStatus) {
- span.setStatus(StatusMatchTable.match(spanStatus));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public OpenCensusSpanAdapter end() {
- span.end();
-
- ended = true;
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEnded() {
- return ended;
- }
-}
diff --git a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTraceExporter.java b/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTraceExporter.java
deleted file mode 100644
index 28a0c44bb44cc..0000000000000
--- a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTraceExporter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.spi.tracing.opencensus;
-
-import io.opencensus.trace.Tracing;
-import io.opencensus.trace.export.SpanExporter;
-import org.apache.ignite.spi.IgniteSpiException;
-
-/**
- * Wrapper of OpenCensus trace exporters adopted for Ignite lifecycle.
- */
-public class OpenCensusTraceExporter {
- /** Span exporter handler. */
- private final SpanExporter.Handler hnd;
-
- /** Trace exporter handler name. */
- private String hndName;
-
- /**
- * @param hnd Span exporter handler.
- */
- public OpenCensusTraceExporter(SpanExporter.Handler hnd) {
- this.hnd = hnd;
- }
-
- /**
- * Starts trace exporter on given node with name {@code igniteInstanceName}.
- *
- * @param igniteInstanceName Name of ignite instance.
- */
- public void start(String igniteInstanceName) {
- try {
- hndName = hnd.getClass().getName() + "-" + igniteInstanceName;
-
- Tracing.getExportComponent().getSpanExporter().registerHandler(hndName, hnd);
- }
- catch (Exception e) {
- throw new IgniteSpiException("Failed to start " + this, e);
- }
- }
-
- /**
- * Stops trace exporter.
- */
- public void stop() {
- Tracing.getExportComponent().getSpanExporter().unregisterHandler(hndName);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "OpenCensus trace exporter [hndName=" + hndName + ", hnd=" + hnd + "]";
- }
-}
diff --git a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTracingSpi.java b/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTracingSpi.java
deleted file mode 100644
index 85f0c0ca5ec61..0000000000000
--- a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/OpenCensusTracingSpi.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.spi.tracing.opencensus;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-import io.opencensus.trace.Tracing;
-import io.opencensus.trace.export.SpanExporter;
-import io.opencensus.trace.samplers.Samplers;
-import org.apache.ignite.internal.tracing.TracingSpiType;
-import org.apache.ignite.spi.IgniteSpiAdapter;
-import org.apache.ignite.spi.IgniteSpiConsistencyChecked;
-import org.apache.ignite.spi.IgniteSpiException;
-import org.apache.ignite.spi.IgniteSpiMultipleInstancesSupport;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Tracing SPI implementation based on OpenCensus library.
- *
- * If you have OpenCensus Tracing in your environment use the following code for configuration:
- *
- * IgniteConfiguration cfg;
- *
- * cfg.setTracingSpi(new OpenCensusTracingSpi());
- *
- * If you don't have OpenCensus Tracing:
- *
- * IgniteConfiguration cfg;
- *
- * cfg.setTracingSpi(new OpenCensusTracingSpi(new ZipkinExporterHandler(...)));
- *
- *
- * See constructors description for detailed explanation.
- */
-@IgniteSpiMultipleInstancesSupport(value = true)
-@IgniteSpiConsistencyChecked(optional = true)
-public class OpenCensusTracingSpi extends IgniteSpiAdapter implements TracingSpi {
- /** Configured exporters. */
- private final List exporters;
-
- /** Flag indicates that external Tracing is used in environment. In this case no exporters will be started. */
- private final boolean externalProvider;
-
- /**
- * This constructor is used if environment (JVM) already has OpenCensus tracing.
- * In this case traces from the node will go trough externally registered exporters by an user himself.
- *
- * @see Tracing#getExportComponent()
- */
- public OpenCensusTracingSpi() {
- exporters = null;
-
- externalProvider = true;
- }
-
- /**
- * This constructor is used if environment (JVM) hasn't OpenCensus tracing.
- * In this case provided exporters will start and traces from the node will go through it.
- *
- * @param exporters Exporters.
- */
- public OpenCensusTracingSpi(SpanExporter.Handler... exporters) {
- this.exporters = Arrays.stream(exporters).map(OpenCensusTraceExporter::new).collect(Collectors.toList());
-
- externalProvider = false;
- }
-
- /** {@inheritDoc} */
- @Override public OpenCensusSpanAdapter create(
- @NotNull String name,
- @Nullable byte[] parentSerializedSpan
- ) throws Exception {
- return new OpenCensusSpanAdapter(
- Tracing.getTracer().spanBuilderWithRemoteParent(
- name,
- Tracing.getPropagationComponent().getBinaryFormat().fromByteArray(parentSerializedSpan)
- )
- .setSampler(Samplers.alwaysSample())
- .startSpan()
- );
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull OpenCensusSpanAdapter create(
- @NotNull String name,
- @Nullable OpenCensusSpanAdapter parentSpan) {
- try {
- io.opencensus.trace.Span openCensusParent = null;
-
- if (parentSpan != null)
- openCensusParent = parentSpan.impl();
-
- return new OpenCensusSpanAdapter(
- Tracing.getTracer().spanBuilderWithExplicitParent(
- name,
- openCensusParent
- )
- .setSampler(Samplers.alwaysSample())
- .startSpan()
- );
- }
- catch (Exception e) {
- throw new IgniteSpiException("Failed to create span from parent " +
- "[spanName=" + name + ", parentSpan=" + parentSpan + "]", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public byte[] serialize(@NotNull OpenCensusSpanAdapter span) {
- return Tracing.getPropagationComponent().getBinaryFormat().toByteArray(span.impl().getContext());
- }
-
- /** {@inheritDoc} */
- @Override public String getName() {
- return "OpenCensusTracingSpi";
- }
-
- /** {@inheritDoc} */
- @Override public void spiStart(String igniteInstanceName) throws IgniteSpiException {
- if (!externalProvider && exporters != null)
- for (OpenCensusTraceExporter exporter : exporters)
- exporter.start(igniteInstanceName);
- }
-
- /** {@inheritDoc} */
- @Override public void spiStop() throws IgniteSpiException {
- if (!externalProvider && exporters != null)
- for (OpenCensusTraceExporter exporter : exporters)
- exporter.stop();
- }
-
- /** {@inheritDoc} */
- @Override public byte type() {
- return TracingSpiType.OPEN_CENSUS_TRACING_SPI.index();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "OpenCensusTracingSpi";
- }
-}
diff --git a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/StatusMatchTable.java b/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/StatusMatchTable.java
deleted file mode 100644
index 408763327c919..0000000000000
--- a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/StatusMatchTable.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.spi.tracing.opencensus;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.spi.tracing.SpanStatus;
-
-/**
- * Table to match OpenCensus span statuses with declared in Tracing SPI.
- */
-public class StatusMatchTable {
- /** Table. */
- private static final Map table = new ConcurrentHashMap<>();
-
- static {
- table.put(SpanStatus.OK, io.opencensus.trace.Status.OK);
- table.put(SpanStatus.CANCELLED, io.opencensus.trace.Status.CANCELLED);
- table.put(SpanStatus.ABORTED, io.opencensus.trace.Status.ABORTED);
- }
-
- /**
- * Default constructor.
- */
- private StatusMatchTable() {
- }
-
- /**
- * @param spanStatus Span status.
- * @return Opencensus analog ot the specified span status.
- */
- public static io.opencensus.trace.Status match(SpanStatus spanStatus) {
- io.opencensus.trace.Status res = table.get(spanStatus);
-
- if (res == null)
- throw new IgniteException("Unknown span status (no matching with OpenCensus): " + spanStatus);
-
- return res;
- }
-}
diff --git a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/package-info.java b/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/package-info.java
deleted file mode 100644
index 412d8a8d726e7..0000000000000
--- a/modules/opencensus/src/main/java/org/apache/ignite/spi/tracing/opencensus/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- *
- * Contains API for OpenCensus Tracing framework integration.
- */
-package org.apache.ignite.spi.tracing.opencensus;
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/TracingConfigurationValidationTest.java b/modules/opencensus/src/test/java/org/apache/ignite/TracingConfigurationValidationTest.java
deleted file mode 100644
index a66792120bc57..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/TracingConfigurationValidationTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Stream;
-
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.Test;
-
-import static org.apache.ignite.spi.tracing.Scope.COMMUNICATION;
-import static org.apache.ignite.spi.tracing.Scope.DISCOVERY;
-import static org.apache.ignite.spi.tracing.Scope.EXCHANGE;
-import static org.apache.ignite.spi.tracing.Scope.TX;
-
-/**
- * Tests for tracing configuration validation rules.
- */
-@SuppressWarnings("ThrowableNotThrown")
-public class TracingConfigurationValidationTest extends GridCommonAbstractTest {
- /**
- * Ensure that in case of null scope as part of tracing coordinates {@code IllegalArgumentException} is thrown with
- * message "Null scope is not valid for tracing coordinates."
- */
- @Test
- public void testThatItsNotPossibleToSetNullAsScopeForTracingCoordinates() {
- GridTestUtils.assertThrows(
- log,
- () -> new TracingConfigurationCoordinates.Builder(null).build(),
- IllegalArgumentException.class,
- "Null scope is not valid for tracing coordinates.");
- }
-
- /**
- * Ensure that it's possible to set any non-null {@link Scope} as part of TracingConfigurationCoordinates.
- */
- @Test
- public void testThatItsPossibleToSpecifyAnyScopeAsPartOfTracingConfigurationCoordinates() {
- for (Scope scope : Scope.values())
- new TracingConfigurationCoordinates.Builder(scope).build();
- }
-
- /**
- * Ensure that it's possible to set any string as label as part of TracingConfigurationCoordinates.
- */
- @Test
- public void testThatItsPossibleToSpecifyAnyStringAsLabelAsPartOfTracingConfigurationCoordinates() {
- Stream.of(
- null,
- "",
- "label", "Some really long label with spaces, Some really long label with spaces," +
- " Some really long label with spaces, Some really long label with spaces," +
- " Some really long label with spaces"
- ).forEach(lb -> new TracingConfigurationCoordinates.Builder(TX).withLabel(lb).build());
- }
-
- /**
- * Ensure that it's possible to set any 0<= double <= 1 as sampling rate as part of TracingConfigurationParameters.
- */
- @Test
- public void testThatItsPossibleToSpecifyAnyDoubleBetweenZeroAndOneIncludingAsSamplingRate() {
- for (double validSamplingRate : new double[] {
- 0,
- 0.1,
- 0.11,
- 0.1234567890,
- 1})
- new TracingConfigurationParameters.Builder().withSamplingRate(validSamplingRate).build();
- }
-
- /**
- * Ensure that in case of invalid sampling rate {@code IllegalArgumentException} is thrown with message "Specified
- * sampling rate=[invalidVal] has invalid value.Should be between 0 and 1 including boundaries."
- */
- @Test
- public void testThatItsPossibleToSpecifyOnlyValidSamplingRate() {
- for (Double invalidSamplingRate : new double[] {-1d, 10d}) {
- GridTestUtils.assertThrows(
- log,
- () -> new TracingConfigurationParameters.Builder().withSamplingRate(invalidSamplingRate).build(),
- IllegalArgumentException.class,
- "Specified sampling rate=[" + invalidSamplingRate +
- "] has invalid value. Should be between 0 and 1 including boundaries.");
- }
- }
-
- /**
- * Ensure that it's possible to set any set of {@code Scope} as included scopes as part of
- * {@link TracingConfigurationParameters}.
- */
- @Test @SuppressWarnings("unchecked")
- public void testThatItsPossibleToSpecifyAnySetincludedScopesAsPartOfTracingConfigurationParameters() {
- for (Set validincludedScopes : new Set[] {
- null,
- Collections.emptySet(),
- Collections.singleton(COMMUNICATION),
- new HashSet<>(Arrays.asList(COMMUNICATION, DISCOVERY, TX, EXCHANGE))})
- new TracingConfigurationParameters.Builder().withIncludedScopes(validincludedScopes).build();
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/AbstractTracingTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/AbstractTracingTest.java
deleted file mode 100644
index ba03562dce3be..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/AbstractTracingTest.java
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import io.opencensus.common.Functions;
-import io.opencensus.trace.AttributeValue;
-import io.opencensus.trace.SpanId;
-import io.opencensus.trace.Tracing;
-import io.opencensus.trace.export.SpanData;
-import io.opencensus.trace.export.SpanExporter;
-import io.opencensus.trace.samplers.Samplers;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
-import org.apache.ignite.internal.processors.tracing.SpanType;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationManager;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTraceExporter;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-import static io.opencensus.trace.AttributeValue.stringAttributeValue;
-import static org.apache.ignite.spi.tracing.Scope.COMMUNICATION;
-import static org.apache.ignite.spi.tracing.Scope.EXCHANGE;
-import static org.apache.ignite.spi.tracing.Scope.TX;
-import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
-
-/**
- * Abstract class for open census tracing tests.
- */
-public abstract class AbstractTracingTest extends GridCommonAbstractTest {
- /** Grid count. */
- static final int GRID_CNT = 3;
-
- /**
- * Span buffer count - hardcode in open census.
- * @see ExportComponentImpl
- */
- private static final int SPAN_BUFFER_COUNT = 2500;
-
- /**
- * Enforces that trace export exports data at least once every 5 seconds - hardcode in open census.
- * @see ExportComponentImpl
- */
- private static final long EXPORTER_SCHEDULE_DELAY = 5_000;
-
- /** Default configuration map. */
- static final Map DFLT_CONFIG_MAP =
- new HashMap<>();
-
- /** TX scope specific coordinates to be used within several tests. */
- static final TracingConfigurationCoordinates TX_SCOPE_SPECIFIC_COORDINATES =
- new TracingConfigurationCoordinates.Builder(TX).build();
-
- /** EXCHANGE scope specific coordinates to be used within several tests. */
- static final TracingConfigurationCoordinates EXCHANGE_SCOPE_SPECIFIC_COORDINATES =
- new TracingConfigurationCoordinates.Builder(EXCHANGE).build();
-
- /** Updated scope specific parameters to be used within several tests. */
- static final TracingConfigurationParameters SOME_SCOPE_SPECIFIC_PARAMETERS =
- new TracingConfigurationParameters.Builder().withSamplingRate(0.75).
- withIncludedScopes(Collections.singleton(COMMUNICATION)).build();
-
- /** TX Label specific coordinates to be used within several tests. */
- static final TracingConfigurationCoordinates TX_LABEL_SPECIFIC_COORDINATES =
- new TracingConfigurationCoordinates.Builder(TX).withLabel("label").build();
-
- /** Updated label specific parameters to be used within several tests. */
- static final TracingConfigurationParameters SOME_LABEL_SPECIFIC_PARAMETERS =
- new TracingConfigurationParameters.Builder().withSamplingRate(0.111).
- withIncludedScopes(Collections.singleton(EXCHANGE)).build();
-
- static {
- DFLT_CONFIG_MAP.put(
- new TracingConfigurationCoordinates.Builder(Scope.TX).build(),
- TracingConfigurationManager.DEFAULT_TX_CONFIGURATION);
-
- DFLT_CONFIG_MAP.put(
- new TracingConfigurationCoordinates.Builder(Scope.COMMUNICATION).build(),
- TracingConfigurationManager.DEFAULT_COMMUNICATION_CONFIGURATION);
-
- DFLT_CONFIG_MAP.put(
- new TracingConfigurationCoordinates.Builder(Scope.EXCHANGE).build(),
- TracingConfigurationManager.DEFAULT_EXCHANGE_CONFIGURATION);
-
- DFLT_CONFIG_MAP.put(
- new TracingConfigurationCoordinates.Builder(Scope.DISCOVERY).build(),
- TracingConfigurationManager.DEFAULT_DISCOVERY_CONFIGURATION);
-
- DFLT_CONFIG_MAP.put(
- new TracingConfigurationCoordinates.Builder(Scope.SQL).build(),
- TracingConfigurationManager.DEFAULT_SQL_CONFIGURATION);
- }
-
- /** Test trace exporter handler. */
- private OpenCensusTxTracingTest.TraceExporterTestHandler hnd;
-
- /** Wrapper of test exporter handler. */
- private OpenCensusTraceExporter exporter;
-
- /**
- * @return Tracing SPI to be used within tests.
- */
- protected abstract TracingSpi getTracingSpi();
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setConsistentId(igniteInstanceName);
-
- if (igniteInstanceName.contains("client"))
- cfg.setClientMode(true);
-
- cfg.setTracingSpi(getTracingSpi());
-
- CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
-
- ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
- ccfg.setBackups(2);
-
- cfg.setCacheConfiguration(ccfg);
-
- return cfg;
- }
-
- /**
- *
- */
- @BeforeClass
- public static void beforeTests() {
- /* Uncomment following code to see visualisation on local Zipkin: */
-
-// ZipkinTraceExporter.createAndRegister(ZipkinExporterConfiguration.builder()
-// .setV2Url("http://localhost:9411/api/v2/spans")
-// .setServiceName("ignite")
-// .build());
- }
-
- /**
- *
- */
- @Before
- public void before() throws Exception {
- stopAllGrids();
-
- hnd = new OpenCensusTxTracingTest.TraceExporterTestHandler();
-
- exporter = new OpenCensusTraceExporter(hnd);
-
- exporter.start("test");
-
- startGrids(GRID_CNT);
- }
-
- /**
- *
- */
- @After
- public void after() {
- exporter.stop();
-
- stopAllGrids();
- }
-
- /**
- * @return Handler.
- */
- OpenCensusTxTracingTest.TraceExporterTestHandler handler() {
- return hnd;
- }
-
- /**
- * Check span.
- *
- * @param spanType Span type.
- * @param parentSpanId Parent span id.
- * @param expSpansCnt expected spans count.
- * @param expAttrs Attributes to check.
- * @return List of founded span ids.
- */
- List checkSpan(
- SpanType spanType,
- SpanId parentSpanId,
- int expSpansCnt,
- /* tagName: tagValue*/ Map expAttrs
- ) {
- return checkSpan(spanType, parentSpanId, expSpansCnt, expAttrs, CheckAttributes.EQUALS);
- }
-
- /**
- * Check span.
- *
- * @param spanType Span type.
- * @param parentSpanId Parent span id.
- * @param expSpansCnt expected spans count.
- * @param expAttrs Attributes to check.
- * @return List of founded span ids.
- */
- List checkSpan(
- SpanType spanType,
- SpanId parentSpanId,
- int expSpansCnt,
- /* tagName: tagValue*/ Map expAttrs,
- CheckAttributes attrCheckType
- ) {
- List gotSpans = findChildSpans(spanType, parentSpanId);
-
- assertEquals(expSpansCnt, gotSpans.size());
-
- List spanIds = new ArrayList<>();
-
- gotSpans.forEach(spanData -> {
- spanIds.add(spanData.getContext().getSpanId());
-
- checkSpanAttributes(spanData, expAttrs, attrCheckType);
- });
-
- return spanIds;
- }
-
- /**
- * Waits until parent span has expected child spans with specified type.
- *
- * @param type Span type.
- * @param parentSpan Parent span id.
- * @param expSpansCnt Expected spans count.
- * @return Ids of the child spans.
- * @throws IgniteInterruptedCheckedException If interrupted.
- */
- List waitForSpan(
- SpanType type,
- SpanId parentSpan,
- int expSpansCnt
- ) throws IgniteInterruptedCheckedException {
- assertTrue("Span was not exported [type=" + type + ", parent=" + parentSpan + ", expCnt=" + expSpansCnt + ']',
- waitForCondition(() -> findChildSpans(type, parentSpan).size() == expSpansCnt, getTestTimeout()));
-
- return findChildSpanIds(type, parentSpan);
- }
-
- /**
- * Finds child spans with specified type and parent span.
- *
- * @param type Span type.
- * @param parentSpan Parent span id.
- * @return Ids of the found spans.
- */
- List findChildSpanIds(SpanType type, SpanId parentSpan) {
- return findChildSpans(type, parentSpan).stream()
- .map(span -> span.getContext().getSpanId())
- .collect(Collectors.toList());
- }
-
- /**
- * Finds child spans with specified type and parent span.
- *
- * @param type Span type.
- * @param parentSpan Parent span id.
- * @return List of spans data.
- */
- List findChildSpans(SpanType type, SpanId parentSpan) {
- return hnd.allSpans()
- .filter(span -> parentSpan != null ?
- parentSpan.equals(span.getParentSpanId()) && type.spanName().equals(span.getName()) :
- type.spanName().equals(span.getName()))
- .collect(Collectors.toList());
- }
-
- /**
- * Checks that there's at least one span with given spanType and attributes.
- *
- * @param spanType Span type to be found.
- * @param expAttrs Expected attributes.
- * @return {@code true} if Span with given type and attributes was found, false otherwise.
- */
- boolean checkSpanExistences(
- SpanType spanType,
- /* tagName: tagValue*/ Map expAttrs
- ) {
- List gotSpans = hnd.allSpans()
- .filter(span -> spanType.spanName().equals(span.getName())).collect(Collectors.toList());
-
- for (SpanData specificTypeSpans : gotSpans) {
- Map attrs = specificTypeSpans.getAttributes().getAttributeMap();
-
- boolean matchFound = true;
-
- for (Map.Entry entry : expAttrs.entrySet()) {
- if (!entry.getValue().equals(attributeValueToString(attrs.get(entry.getKey())))) {
- matchFound = false;
-
- break;
- }
- }
- if (matchFound && expAttrs.size() == attrs.size())
- return true;
- }
-
- return false;
- }
-
- /**
- * Verify that given spanData contains all (and only) propagated expected attributes.
- * @param spanData Span data to check.
- * @param expAttrs Attributes to check.
- */
- private void checkSpanAttributes(
- SpanData spanData,
- /* tagName: tagValue*/ Map expAttrs,
- CheckAttributes attrCheckType
- ) {
- Map attrs = spanData.getAttributes().getAttributeMap();
-
- if (expAttrs != null) {
- switch (attrCheckType) {
- case EQUALS:
- assertEquals(expAttrs.size(), attrs.size());
-
- break;
-
- case CONTAINS:
- assertTrue(expAttrs.size() <= attrs.size());
-
- break;
-
- default:
- fail("Unexpected attributes check: " + attrCheckType);
- }
-
- for (Map.Entry entry : expAttrs.entrySet())
- assertEquals(entry.getValue(), attributeValueToString(attrs.get(entry.getKey())));
- }
- }
-
- /**
- * @param attributeVal Attribute value.
- */
- protected static String attributeValueToString(AttributeValue attributeVal) {
- if (attributeVal == null)
- return null;
-
- return attributeVal.match(
- Functions.returnToString(),
- Functions.returnToString(),
- Functions.returnToString(),
- Functions.returnToString(),
- Functions.returnConstant(""));
- }
-
- /**
- * Test span exporter handler.
- */
- static class TraceExporterTestHandler extends SpanExporter.Handler {
- /** Collected spans. */
- private final Map collectedSpans = new ConcurrentHashMap<>();
-
- /** */
- private final Map> collectedSpansByParents = new ConcurrentHashMap<>();
-
- /** {@inheritDoc} */
- @Override public void export(Collection spanDataList) {
- for (SpanData data : spanDataList) {
- collectedSpans.put(data.getContext().getSpanId(), data);
-
- if (data.getParentSpanId() != null)
- collectedSpansByParents.computeIfAbsent(data.getParentSpanId(), (k) -> new ArrayList<>()).add(data);
- }
- }
-
- /**
- * @return Stream of all exported spans.
- */
- Stream allSpans() {
- return collectedSpans.values().stream();
- }
-
- /**
- * @param id Span id.
- * @return Exported span by given id.
- */
- SpanData spanById(SpanId id) {
- return collectedSpans.get(id);
- }
-
- /**
- * @param name Span name for search.
- * @return Span with given name.
- */
- SpanData spanByName(String name) {
- return allSpans()
- .filter(span -> span.getName().contains(name))
- .findFirst()
- .orElse(null);
- }
-
- /**
- * @param parentId Parent id.
- * @return All spans by parent id.
- */
- List spanByParentId(SpanId parentId) {
- return collectedSpansByParents.get(parentId);
- }
-
- /**
- * @param parentSpan Top span.
- * @return All span which are child of parentSpan in any generation.
- */
- List unrollByParent(SpanData parentSpan) {
- ArrayList spanChain = new ArrayList<>();
-
- LinkedList queue = new LinkedList<>();
-
- queue.add(parentSpan);
-
- spanChain.add(parentSpan);
-
- while (!queue.isEmpty()) {
- SpanData cur = queue.pollFirst();
-
- assert cur != null;
-
- List child = spanByParentId(cur.getContext().getSpanId());
-
- if (child != null) {
- spanChain.addAll(child);
-
- queue.addAll(child);
- }
- }
-
- return spanChain;
- }
-
- /**
- * @param igniteInstanceName Ignite instance name.
- * @return Stream of SpanData.
- */
- Stream spansReportedByNode(String igniteInstanceName) {
- return collectedSpans.values().stream()
- .filter(spanData -> stringAttributeValue(igniteInstanceName)
- .equals(spanData.getAttributes().getAttributeMap().get("node.name")));
- }
-
- /**
- * Forces to flush ended spans that not passed to exporter yet.
- */
- void flush() throws IgniteInterruptedCheckedException {
- // There is hardcoded invariant, that ended spans will be passed to exporter in 2 cases:
- // By {@code EXPORTER_SCHEDULE_DELAY} seconds timeout and if buffer size exceeds {@code SPAN_BUFFER_COUNT} spans.
- // There is no ability to change this behavior in Opencensus, so this hack is needed to "flush" real spans to exporter.
- // @see io.opencensus.implcore.trace.export.ExportComponentImpl.
- for (int i = 0; i < SPAN_BUFFER_COUNT; i++)
- Tracing.getTracer().spanBuilder("test-" + i).setSampler(Samplers.alwaysSample()).startSpan().end();
-
- assertTrue(waitForCondition(
- () -> allSpans().anyMatch(span -> span.getName().equals("test-" + (SPAN_BUFFER_COUNT - 1))),
- 2 * EXPORTER_SCHEDULE_DELAY));
- }
-
- /** Clears collected spans. */
- void clearCollectedSpans() {
- collectedSpans.clear();
- collectedSpansByParents.clear();
- }
- }
-
- /** */
- public enum CheckAttributes {
- /** */
- EQUALS,
-
- /** */
- CONTAINS
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/IgniteOpenCensusSuite.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/IgniteOpenCensusSuite.java
index 1510bcacf103b..c55c8fe78f6d8 100644
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/IgniteOpenCensusSuite.java
+++ b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/IgniteOpenCensusSuite.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.processors.monitoring.opencensus;
-import org.apache.ignite.TracingConfigurationValidationTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -26,19 +25,7 @@
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- OpenCensusMetricExporterSpiTest.class,
- OpenCensusTracingSpiTest.class,
- OpenCensusTxTracingTest.class,
- MixedTracingSpiTest.class,
- TracingConfigurationValidationTest.class,
- OpenCensusTxTracingConfigurationTest.class,
- OpenCensusTracingConfigurationGetTest.class,
- OpenCensusTracingConfigurationGetAllTest.class,
- OpenCensusTracingConfigurationResetTest.class,
- OpenCensusTracingConfigurationResetAllTest.class,
- OpenCensusDiscoveryTracingTest.class,
- OpenCensusSqlJdbcTracingTest.class,
- OpenCensusSqlNativeTracingTest.class
+ OpenCensusMetricExporterSpiTest.class
})
public class IgniteOpenCensusSuite {
}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/MixedTracingSpiTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/MixedTracingSpiTest.java
deleted file mode 100644
index 5522182e51646..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/MixedTracingSpiTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.ignite.spi.tracing.NoopTracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.apache.ignite.testframework.ListeningTestLogger;
-import org.apache.ignite.testframework.LogListener;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.Test;
-
-/**
- * Tests for mixed tracing spi instances.
- */
-public class MixedTracingSpiTest extends GridCommonAbstractTest {
-
- /** */
- private ListeningTestLogger testLog = new ListeningTestLogger(log);
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
-
- super.afterTest();
- }
-
- /**
- * Prepares log listeners list.
- *
- * @return List of prepared log listeners.
- */
- private List prepareLogListeners() {
- testLog.clearListeners();
-
- List listeners = new ArrayList<>();
-
- listeners.add(LogListener.matches(
- ">>> Remote SPI with the same name is not configured: OpenCensusTracingSpi").build());
-
- listeners.add(LogListener.matches(
- ">>> Remote SPI with the same name is not configured: NoopTracingSpi").build());
-
- listeners.forEach(testLog::registerListener);
-
- return listeners;
- }
-
- /**
- * Start two nodes: one with noop tracing spi and another one with open census tracing spi.
- *
- * Cause both tracing spi instances are annotated with {@code @IgniteSpiConsistencyChecked(optional = true)}
- * 'Remote SPI with the same name is not configured: >' warning message is expected on
- * node start.
- *
- * Besides that 'Failed to create span from serialized value' is expected, cause it's not possible
- * to deserialize {@code NoopSpan.INSTANCE} from {@link NoopTracingSpi} on the node
- * with {@link OpenCensusTracingSpi}.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testNodesWithDifferentTracingSpiPrintsWarningOnConsistencyCheck() throws Exception {
- List listeners = prepareLogListeners();
-
- startGrid(getConfiguration(getTestIgniteInstanceName(0) +
- "node-with-noop-tracing").setTracingSpi(new NoopTracingSpi()).setGridLogger(testLog));
-
- startGrid(getConfiguration(getTestIgniteInstanceName(1) +
- "node-with-open-census-tracing").setTracingSpi(new OpenCensusTracingSpi()).setGridLogger(testLog));
-
- listeners.forEach(lsnr -> assertTrue(lsnr.check()));
- }
-
- /**
- * Start two nodes, both with noop tracing spi instances. No warning messages are expected.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testNodesWithNoopTracingSpiPrintsNothingOnConsistencyCheck() throws Exception {
- List listeners = prepareLogListeners();
-
- startGrid(getConfiguration(getTestIgniteInstanceName(0) +
- "node-with-noop-tracing").setTracingSpi(new NoopTracingSpi()).setGridLogger(testLog));
-
- startGrid(getConfiguration(getTestIgniteInstanceName(1) +
- "node-with-noop-tracing").setTracingSpi(new NoopTracingSpi()).setGridLogger(testLog));
-
- listeners.forEach(lsnr -> assertFalse(lsnr.check()));
- }
-
- /**
- * Start two nodes, both with open census tracing spi instances. No warning messages are expected.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testNodesWithOpenCensusTracingSpiPrintsNothingOnConsistencyCheck() throws Exception {
- List listeners = prepareLogListeners();
-
- startGrid(getConfiguration(getTestIgniteInstanceName(0) +
- "node-with-open-census-tracing").setTracingSpi(new OpenCensusTracingSpi()).setGridLogger(testLog));
-
- startGrid(getConfiguration(getTestIgniteInstanceName(1) +
- "node-with-open-census-tracing").setTracingSpi(new OpenCensusTracingSpi()).setGridLogger(testLog));
-
- listeners.forEach(lsnr -> assertFalse(lsnr.check()));
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusDiscoveryTracingTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusDiscoveryTracingTest.java
deleted file mode 100644
index 40ed64ccc94d0..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusDiscoveryTracingTest.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.HashMap;
-import java.util.Map;
-import com.google.common.collect.ImmutableMap;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.junit.Test;
-
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_CUSTOM_EVENT;
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_JOIN_REQUEST;
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_LEFT;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER;
-
-/**
- * Test to check tracing for operations that were started on client node.
- */
-public class OpenCensusDiscoveryTracingTest extends AbstractTracingTest {
- /** */
- private static final String CACHE_NAME = "CacheName";
-
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /** {@inheritDoc} */
- @Override public void before() throws Exception {
- super.before();
-
- awaitPartitionMapExchange();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() {
- stopGrid(GRID_CNT);
- }
-
- /**
- * Checks that there's DISCOVERY_NODE_JOIN_REQUEST on coordinator with corresponding 'event.node.id'
- * that matches started client node.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testClientNodeStartTracing() throws Exception {
- performClientBasedOperation(
- null,
- () -> {
- try {
- startClientGrid(GRID_CNT);
- }
- catch (Exception e) {
- fail("Unable to start client grid.");
- }
- }
- );
-
- assertTrue(
- checkSpanExistences(
- DISCOVERY_NODE_JOIN_REQUEST,
- ImmutableMap.builder()
- .put("node.id", grid(0).localNode().id().toString())
- .put("node.consistent.id", grid(0).localNode().consistentId().toString())
- .put("node.name", grid(0).name())
- .put("event.node.id", grid(GRID_CNT).localNode().id().toString())
- .put("event.node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .build()
- )
- );
- }
-
- /**
- * Checks that creating cache produces DISCOVERY_CUSTOM_EVENT span
- * with corresponding 'DynamicCacheChangeBatch' message class on client grid.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testClientNodeCacheCreateTracing() throws Exception {
- performClientBasedOperation(
- () -> {
- try {
- startClientGrid(GRID_CNT);
- }
- catch (Exception e) {
- fail("Unable to start client grid.");
- }
- },
- () -> {
- try {
- grid(GRID_CNT).getOrCreateCache(CACHE_NAME);
- }
- catch (Exception e) {
- fail("Unable to create cache.");
- }
- }
- );
-
- assertTrue(
- checkSpanExistences(
- DISCOVERY_CUSTOM_EVENT,
- ImmutableMap.builder()
- .put("node.id", grid(GRID_CNT).localNode().id().toString())
- .put("node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .put("node.name", grid(GRID_CNT).name())
- .put("event.node.id", grid(GRID_CNT).localNode().id().toString())
- .put("message.class", "DynamicCacheChangeBatch")
- .put("event.node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .build()
- )
- );
- }
-
- /**
- * Checks that binary type registration produces two DISCOVERY_CUSTOM_EVENT spans
- * with corresponding 'MappingProposedMessage' and 'MetadataUpdateProposedMessage' message classes on client grid.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testClientNodeBinaryTypeRegistrationTracing() throws Exception {
- performClientBasedOperation(
- () -> {
- try {
- startClientGrid(GRID_CNT);
-
- grid(GRID_CNT).getOrCreateCache(CACHE_NAME);
- }
- catch (Exception e) {
- fail("Unable to either start client grid or create cache.");
- }
- },
- () -> {
- try {
- grid(GRID_CNT).cache(CACHE_NAME).put(1, new Value(1));
- }
- catch (Exception e) {
- fail("Unable to create cache.");
- }
- });
-
- assertTrue(
- checkSpanExistences(
- DISCOVERY_CUSTOM_EVENT,
- ImmutableMap.builder()
- .put("node.id", grid(GRID_CNT).localNode().id().toString())
- .put("node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .put("node.name", grid(GRID_CNT).name())
- .put("event.node.id", grid(GRID_CNT).localNode().id().toString())
- .put("message.class", "MappingProposedMessage")
- .put("event.node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .build()
- )
- );
-
- assertTrue(
- checkSpanExistences(
- DISCOVERY_CUSTOM_EVENT,
- ImmutableMap.builder()
- .put("node.id", grid(GRID_CNT).localNode().id().toString())
- .put("node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .put("node.name", grid(GRID_CNT).name())
- .put("event.node.id", grid(GRID_CNT).localNode().id().toString())
- .put("message.class", "MetadataUpdateProposedMessage")
- .put("event.node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .build()
- )
- );
- }
-
- /**
- * Checks that cache destruction produces DISCOVERY_CUSTOM_EVENT span
- * with corresponding 'DynamicCacheChangeBatch' message class on client grid.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testClientNodeCacheDestructionTracing() throws Exception {
- performClientBasedOperation(
- () -> {
- try {
- startClientGrid(GRID_CNT);
-
- grid(GRID_CNT).getOrCreateCache(CACHE_NAME);
- }
- catch (Exception e) {
- fail("Unable to either start client grid or create cache.");
- }
- },
- () -> {
- try {
- grid(GRID_CNT).destroyCache(CACHE_NAME);
- }
- catch (Exception e) {
- fail("Unable to create cache.");
- }
- });
-
- assertTrue(
- checkSpanExistences(
- DISCOVERY_CUSTOM_EVENT,
- ImmutableMap.builder()
- .put("node.id", grid(GRID_CNT).localNode().id().toString())
- .put("node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .put("node.name", grid(GRID_CNT).name())
- .put("event.node.id", grid(GRID_CNT).localNode().id().toString())
- .put("message.class", "DynamicCacheChangeBatch")
- .put("event.node.consistent.id", grid(GRID_CNT).localNode().consistentId().toString())
- .build()
- )
- );
- }
-
- /**
- * Checks that cache destruction produces DISCOVERY_NODE_LEFT span
- * with corresponding 'event.node.id' on coordinator.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testClientNodeStopTracing() throws Exception {
- Map clientNodeMeta = new HashMap<>();
-
- performClientBasedOperation(
- () -> {
- try {
- startClientGrid(GRID_CNT);
-
- clientNodeMeta.put("event.node.id", grid(GRID_CNT).localNode().id().toString());
- }
- catch (Exception e) {
- fail("Unable to either start client grid or create cache.");
- }
- },
- () -> {
- try {
- stopGrid(GRID_CNT);
- }
- catch (Exception e) {
- fail("Unable to create cache.");
- }
- });
-
- assertTrue(
- checkSpanExistences(
- DISCOVERY_NODE_LEFT,
- ImmutableMap.builder()
- .put("node.id", grid(0).localNode().id().toString())
- .put("node.consistent.id", grid(0).localNode().consistentId().toString())
- .put("node.name", grid(0).name())
- .put("event.node.id", clientNodeMeta.get("event.node.id"))
- .build()
- )
- );
- }
-
- /**
- * Perform preparation operations and operation to trigger span creation.
- *
- * @param preparationOperations Operations to run without tracing.
- * @param operationToCheck Operations to run with tracing.
- * @throws Exception If failed.
- */
- private void performClientBasedOperation(
- @Nullable Runnable preparationOperations,
- @NotNull Runnable operationToCheck
- ) throws Exception {
- if (preparationOperations != null) {
- try {
- preparationOperations.run();
- }
- catch (Exception e) {
- fail("Unable to perform preparation operations. " + e);
- }
- }
-
- // Enable discovery tracing.
- grid(0).tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(Scope.DISCOVERY).build(),
- new TracingConfigurationParameters.Builder().
- withSamplingRate(SAMPLING_RATE_ALWAYS).build());
-
- try {
- operationToCheck.run();
- }
- catch (Exception e) {
- fail("Unable to perform operation that is supposed to be traced." + e);
- }
-
- handler().flush();
-
- // Disable discovery tracing in order not to mess with un-relevant spans.
- grid(0).tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(Scope.DISCOVERY).build(),
- new TracingConfigurationParameters.Builder().
- withSamplingRate(SAMPLING_RATE_NEVER).build());
- }
-
- /**
- * Test Value class to be registered within one of the tests.
- */
- public static class Value {
- /** */
- final int val;
-
- /**
- * Constructor.
- *
- * @param val Value to register.
- */
- public Value(int val) {
- this.val = val;
- }
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlJdbcTracingTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlJdbcTracingTest.java
deleted file mode 100644
index 4f59bb8ea9fdc..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlJdbcTracingTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Objects;
-import java.util.UUID;
-
-import io.opencensus.trace.SpanId;
-import org.apache.ignite.client.Config;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.junit.Test;
-
-import static java.sql.DriverManager.getConnection;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.internal.processors.query.QueryUtils.DFLT_SCHEMA;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_PAGE_ROWS;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_QRY_ID;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_BATCH_PROCESS;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CMD_QRY_EXECUTE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_CLOSE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_OPEN;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_ITER_CLOSE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_ITER_OPEN;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_FETCH;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_EXECUTE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_PARSE;
-import static org.apache.ignite.internal.util.IgniteUtils.resolveIgnitePath;
-import static org.apache.ignite.spi.tracing.Scope.SQL;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER;
-
-/**
- * Tests tracing of SQL queries execution via JDBC.
- */
-public class OpenCensusSqlJdbcTracingTest extends OpenCensusSqlNativeTracingTest {
- /** JDBC URL prefix. */
- private static final String JDBC_URL_PREFIX = "jdbc:ignite:thin://";
-
- /** CSV file for bulk-load testing. */
- private static final String BULKLOAD_FILE = Objects.requireNonNull(resolveIgnitePath(
- "/modules/clients/src/test/resources/bulkload2.csv")).getAbsolutePath();
-
- /** Number of bulk-load entries. */
- private static final int BULKLOAD_ENTRIES = 2;
-
- /**
- * 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 = findChildSpanIds(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(findChildSpanIds(SQL_CURSOR_CLOSE, rootSpan).isEmpty());
- }
-
- /**
- * 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);
- }
-
- /** {@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 rootSpans = findRootSpans(SQL_QRY);
-
- assertEquals(2, rootSpans.size());
-
- for (SpanId rootSpan : rootSpans)
- checkBasicSelectQuerySpanTree(rootSpan, TEST_TABLE_POPULATION);
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("StatementWithEmptyBody")
- @Override protected void executeQuery(
- String sql,
- String schema,
- boolean skipReduceOnUpdate,
- boolean distributedJoins,
- Boolean isQry
- ) {
- String url = JDBC_URL_PREFIX + Config.SERVER + '/' + schema +
- "?skipReducerOnUpdate=" + skipReduceOnUpdate + "&distributedJoins=" + distributedJoins;
-
- try (
- Connection conn = getConnection(url);
-
- PreparedStatement stmt = conn.prepareStatement(sql)
- ) {
- stmt.setFetchSize(PAGE_SIZE);
-
- if (isQry == null)
- stmt.execute();
- else if (!isQry)
- stmt.executeUpdate();
- else {
- stmt.executeQuery();
-
- try (ResultSet resultSet = stmt.getResultSet()) {
- while (resultSet.next()) {
- // No-op.
- }
- }
- }
- }
- catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteEx reducer() {
- return ignite(0);
- }
-
- /** {@inheritDoc} */
- @Override protected int mapNodesCount() {
- return GRID_CNT - 1;
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlNativeTracingTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlNativeTracingTest.java
deleted file mode 100644
index 03527a6ac7a20..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusSqlNativeTracingTest.java
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import com.google.common.collect.ImmutableMap;
-import io.opencensus.trace.SpanId;
-import io.opencensus.trace.Tracing;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.query.FieldsQueryCursor;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.TestRecordingCommunicationSpi;
-import org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx;
-import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.NoopSpan;
-import org.apache.ignite.internal.processors.tracing.SpanType;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.junit.Test;
-
-import static java.lang.Boolean.parseBoolean;
-import static java.lang.Integer.parseInt;
-import static java.util.regex.Pattern.compile;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.internal.TestRecordingCommunicationSpi.spi;
-import static org.apache.ignite.internal.processors.query.QueryUtils.DFLT_SCHEMA;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.CONSISTENT_ID;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.NAME;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.NODE;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.NODE_ID;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_CACHE_UPDATES;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_IDX_RANGE_ROWS;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_PAGE_ROWS;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_PARSER_CACHE_HIT;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_QRY_ID;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_QRY_TEXT;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SQL_SCHEMA;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.tag;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CACHE_UPDATE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CMD_QRY_EXECUTE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_CANCEL;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_CLOSE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_OPEN;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_DML_QRY_EXECUTE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_DML_QRY_EXEC_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_DML_QRY_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_FAIL_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_IDX_RANGE_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_IDX_RANGE_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_ITER_CLOSE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_ITER_OPEN;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_NEXT_PAGE_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_FETCH;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_PREPARE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PAGE_WAIT;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_PARTITIONS_RESERVE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_CANCEL_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_EXECUTE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_EXEC_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_PARSE;
-import static org.apache.ignite.spi.tracing.Scope.SQL;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS;
-import static org.apache.ignite.testframework.GridTestUtils.runAsync;
-
-/**
- * Tests tracing of SQL queries based on {@link OpenCensusTracingSpi}.
- */
-public class OpenCensusSqlNativeTracingTest extends AbstractTracingTest {
- /** Number of entries in test table. */
- protected static final int TEST_TABLE_POPULATION = 100;
-
- /** Page size for queries. */
- protected static final int PAGE_SIZE = 20;
-
- /** Test schema name. */
- protected static final String TEST_SCHEMA = "TEST_SCHEMA";
-
- /** Key counter. */
- private final AtomicInteger keyCntr = new AtomicInteger();
-
- /** {@inheritDoc} */
- @Override protected TracingSpi> getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- return super.getConfiguration(igniteInstanceName)
- .setCommunicationSpi(new TestRecordingCommunicationSpi());
- }
-
- /** {@inheritDoc} */
- @Override public void before() throws Exception {
- super.before();
-
- IgniteEx cli = startClientGrid(GRID_CNT);
-
- cli.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(SQL).build(),
- new TracingConfigurationParameters.Builder()
- .withSamplingRate(SAMPLING_RATE_ALWAYS).build());
- }
-
- /**
- * 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 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 += findChildSpanIds(SQL_PAGE_FETCH, execReqSpan).stream()
- .mapToInt(span -> parseInt(getAttribute(span, SQL_PAGE_ROWS)))
- .sum();
-
- List cacheUpdateSpans = findChildSpanIds(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);
- }
-
- /**
- * Tests tracing of multiple MERGE query.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testMultipleMerge() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
-
- checkDmlQuerySpans("MERGE INTO " + prsnTable + "(_key, prsnVal) SELECT _key, 0 FROM " + prsnTable,
- true, TEST_TABLE_POPULATION);
- }
-
- /**
- * Tests tracing of single MERGE query.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testSingleMerge() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
-
- checkDmlQuerySpans("MERGE INTO " + prsnTable + "(_key, prsnId, prsnVal) VALUES (" + keyCntr.get() + ", 0, 0)",
- false, 1);
- }
-
- /**
- * Tests tracing of UPDATE query.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testUpdate() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
-
- checkDmlQuerySpans("UPDATE " + prsnTable + " SET prsnVal = (prsnVal + 1)",
- true, TEST_TABLE_POPULATION);
- }
-
- /**
- * Tests tracing of DELETE query.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testDelete() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
-
- checkDmlQuerySpans("DELETE FROM " + prsnTable, true, TEST_TABLE_POPULATION);
- }
-
- /**
- * Tests tracing of multiple INSERT query.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testMultipleInsert() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
-
- checkDmlQuerySpans("INSERT INTO " + prsnTable + "(_key, prsnId, prsnVal) VALUES" +
- " (" + keyCntr.incrementAndGet() + ", 0, 0)," +
- " (" + keyCntr.incrementAndGet() + ", 1, 1)", false, 2);
- }
-
- /**
- * Tests tracing of single INSERT query.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testSingleInsert() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
-
- checkDmlQuerySpans("INSERT INTO " + prsnTable + "(_key, prsnId, prsnVal) VALUES" +
- " (" + keyCntr.incrementAndGet() + ", 0, 0)", false, 1);
- }
-
- /**
- * Tests tracing of distributed join query which includes all communications between reducer and mapped nodes and
- * index range requests.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testDistributedJoin() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
-
- String orgTable = createTableAndPopulate(Organization.class, PARTITIONED, 1);
-
- SpanId rootSpan = executeAndCheckRootSpan(
- "SELECT * FROM " + prsnTable + " AS p JOIN " + orgTable + " AS o ON o.orgId = p.prsnId",
- TEST_SCHEMA, false, true, 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);
-
- SpanId iterSpan = checkChildSpan(SQL_ITER_OPEN, rootSpan);
-
- List execReqSpans = checkSpan(SQL_QRY_EXEC_REQ, iterSpan, GRID_CNT, null);
-
- int idxRangeReqRows = 0;
-
- int preparedRows = 0;
-
- int fetchedRows = 0;
-
- for (int i = 0; i < GRID_CNT; i++) {
- SpanId execReqSpan = execReqSpans.get(i);
-
- Ignite ignite = Ignition.ignite(UUID.fromString(getAttribute(execReqSpan, NODE_ID)));
-
- SpanId partsReserveSpan = checkChildSpan(SQL_PARTITIONS_RESERVE, execReqSpan);
-
- List partsReserveLogs = handler().spanById(partsReserveSpan).getAnnotations().getEvents().stream()
- .map(e -> e.getEvent().getDescription())
- .collect(Collectors.toList());
-
- assertEquals(2, partsReserveLogs.size());
-
- Pattern ptrn = compile("Cache partitions were reserved \\[cache=(.+), partitions=\\[(.+)], topology=(.+)]");
-
- partsReserveLogs.forEach(l -> {
- Matcher matcher = ptrn.matcher(l);
-
- assertTrue(matcher.matches());
-
- Set expParts = Arrays.stream(ignite.affinity(matcher.group(1))
- .primaryPartitions(ignite.cluster().localNode())
- ).boxed().collect(Collectors.toSet());
-
- Set parts = Arrays.stream(matcher.group(2).split(","))
- .map(s -> parseInt(s.trim()))
- .collect(Collectors.toSet());
-
- assertEquals(expParts, parts);
- });
-
- SpanId pagePrepareSpan = checkChildSpan(SQL_PAGE_PREPARE, execReqSpan);
-
- preparedRows += parseInt(getAttribute(pagePrepareSpan, SQL_PAGE_ROWS));
-
- List distLookupReqSpans = findChildSpanIds(SQL_IDX_RANGE_REQ, pagePrepareSpan);
-
- for (SpanId span : distLookupReqSpans) {
- String rowsAttr = getAttribute(span, SQL_IDX_RANGE_ROWS);
-
- if (rowsAttr != null)
- idxRangeReqRows += parseInt(rowsAttr);
-
- checkChildSpan(SQL_IDX_RANGE_RESP, span);
- }
-
- checkChildSpan(SQL_QRY_EXECUTE, execReqSpan);
- checkChildSpan(SQL_PAGE_RESP, execReqSpan);
- }
-
- SpanId pageFetchSpan = checkChildSpan(SQL_PAGE_FETCH, iterSpan);
-
- fetchedRows += parseInt(getAttribute(pageFetchSpan, SQL_PAGE_ROWS));
-
- checkChildSpan(SQL_PAGE_WAIT, pageFetchSpan);
-
- SpanId nexPageSpan = checkChildSpan(SQL_NEXT_PAGE_REQ, pageFetchSpan);
-
- preparedRows += parseInt(getAttribute(checkChildSpan(SQL_PAGE_PREPARE, nexPageSpan), SQL_PAGE_ROWS));
-
- checkChildSpan(SQL_PAGE_RESP, nexPageSpan);
-
- List pageFetchSpans = findChildSpanIds(SQL_PAGE_FETCH, rootSpan);
-
- for (SpanId span : pageFetchSpans) {
- fetchedRows += parseInt(getAttribute(span, SQL_PAGE_ROWS));
-
- checkChildSpan(SQL_PAGE_WAIT, span);
-
- List nextPageSpans = findChildSpanIds(SQL_NEXT_PAGE_REQ, span);
-
- if (!nextPageSpans.isEmpty()) {
- assertEquals(1, nextPageSpans.size());
-
- SpanId nextPageSpan = nextPageSpans.get(0);
-
- preparedRows += parseInt(getAttribute(checkChildSpan(SQL_PAGE_PREPARE, nextPageSpan), SQL_PAGE_ROWS));
-
- checkChildSpan(SQL_PAGE_RESP, nextPageSpan);
- }
- }
-
- assertEquals(TEST_TABLE_POPULATION, fetchedRows);
- assertEquals(TEST_TABLE_POPULATION, preparedRows);
- assertEquals(TEST_TABLE_POPULATION, idxRangeReqRows);
-
- waitForSpan(SQL_QRY_CANCEL_REQ, rootSpan, mapNodesCount());
-
- assertFalse(findChildSpanIds(SQL_CURSOR_CLOSE, rootSpan).isEmpty());
- }
-
- /**
- * 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 qryExecSpans = findChildSpanIds(SQL_QRY_EXEC_REQ, iterOpenSpan);
-
- assertEquals(GRID_CNT * qryParallelism, qryExecSpans.size());
- }
-
- /**
- * Tests tracing of the SQL query next page request failure.
- *
- * @throws Exception If failed.
- */
- @Test
- 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);
-
- waitForSpan(SQL_QRY_CANCEL_REQ, iterCloseSpan, mapNodesCount());
-
- List pageFetchSpans = findChildSpanIds(SQL_PAGE_FETCH, rootSpan);
-
- for (SpanId pageFetchSpan : pageFetchSpans) {
- List nextPageReqSpans = findChildSpanIds(SQL_NEXT_PAGE_REQ, pageFetchSpan);
-
- if (!nextPageReqSpans.isEmpty()) {
- assertEquals(1, nextPageReqSpans.size());
-
- waitForSpan(SQL_FAIL_RESP, nextPageReqSpans.get(0), 1);
- }
- }
- }
-
- /**
- * 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);
- }
-
- /** 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)));
- }
-
- /**
- * Tests that tracing of multiple SELECT queries produces separate span tree for each query and does not affect
- * user thread {@link MTC#span()} value during execution and after it.
- */
- @Test
- public void testSelectQueryUserThreadSpanNotAffected() throws Exception {
- String prsnTable = createTableAndPopulate(Person.class, PARTITIONED, 1);
- String orgTable = createTableAndPopulate(Organization.class, PARTITIONED, 1);
-
- try (
- FieldsQueryCursor> prsnQryCursor = reducer().context().query()
- .querySqlFields(new SqlFieldsQuery("SELECT * FROM " + prsnTable), false);
-
- FieldsQueryCursor> orgQryCursor = reducer().context().query()
- .querySqlFields(new SqlFieldsQuery("SELECT * FROM " + orgTable), false)
- ) {
- Iterator> prsnQryIter = prsnQryCursor.iterator();
- Iterator> orgQryIter = orgQryCursor.iterator();
-
- while (prsnQryIter.hasNext() && orgQryIter.hasNext()) {
- assertEquals(NoopSpan.INSTANCE, MTC.span());
-
- prsnQryIter.next();
-
- assertEquals(NoopSpan.INSTANCE, MTC.span());
-
- orgQryIter.next();
-
- assertEquals(NoopSpan.INSTANCE, MTC.span());
- }
- }
-
- assertEquals(NoopSpan.INSTANCE, MTC.span());
-
- handler().flush();
-
- checkDroppedSpans();
-
- List rootSpans = findRootSpans(SQL_QRY);
-
- assertEquals(2, rootSpans.size());
-
- for (SpanId rootSpan : rootSpans)
- checkBasicSelectQuerySpanTree(rootSpan, TEST_TABLE_POPULATION);
- }
-
- /**
- * 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 pageFetchSpans = findChildSpanIds(SQL_PAGE_FETCH, rootSpan);
-
- for (SpanId span : pageFetchSpans)
- fetchedRows += parseInt(getAttribute(span, SQL_PAGE_ROWS));
-
- assertEquals(expRows, fetchedRows);
-
- assertFalse(findChildSpanIds(SQL_CURSOR_CLOSE, rootSpan).isEmpty());
- }
-
- /**
- * 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 = findChildSpanIds(SQL_PAGE_FETCH, null).stream()
- .mapToInt(span -> parseInt(getAttribute(span, SQL_PAGE_ROWS)))
- .sum();
-
- assertEquals(expCacheUpdates, fetchedRows);
- }
-
- int cacheUpdates = findChildSpanIds(SQL_CACHE_UPDATE, dmlExecSpan).stream()
- .mapToInt(span -> parseInt(getAttribute(span, SQL_CACHE_UPDATES)))
- .sum();
-
- assertEquals(expCacheUpdates, cacheUpdates);
- }
-
- /**
- * Checks whether parent span has a single child span with specified type.
- *
- * @param type Span type.
- * @param parentSpan Parent span id.
- * @return Id of the child span.
- */
- protected SpanId checkChildSpan(SpanType type, SpanId parentSpan) {
- return checkSpan(type, parentSpan, 1, null).get(0);
- }
-
- /**
- * Finds root spans with specified type.
- *
- * @param type Span type.
- * @return Ids of the found spans.
- */
- protected List findRootSpans(SpanType type) {
- return handler().allSpans()
- .filter(span -> span.getParentSpanId() == null && type.spanName().equals(span.getName()))
- .map(span -> span.getContext().getSpanId())
- .collect(Collectors.toList());
- }
-
- /**
- * Obtains string representation of the attribtute from span with specified id.
- *
- * @param spanId Id of the target span.
- * @param tag Tag of the attribute.
- * @return Value of the attribute.
- */
- protected String getAttribute(SpanId spanId, String tag) {
- return attributeValueToString(handler()
- .spanById(spanId)
- .getAttributes()
- .getAttributeMap()
- .get(tag));
- }
-
- /**
- * Executes query with specified parameters.
- *
- * @param sql SQL query to execute.
- * @param schema SQL query schema.
- * @param skipReducerOnUpdate Wether reduce phase should be skipped during update query execution.
- * @param distributedJoins Whether distributed joins enabled.
- * @param isQry {@code True} if query is SELECT, {@code False} - DML queries, {@code null} - all remainings.
- */
- protected void executeQuery(
- String sql,
- String schema,
- boolean skipReducerOnUpdate,
- boolean distributedJoins,
- Boolean isQry
- ) {
- SqlFieldsQuery qry = new SqlFieldsQueryEx(sql, isQry)
- .setSkipReducerOnUpdate(skipReducerOnUpdate)
- .setDistributedJoins(distributedJoins)
- .setPageSize(PAGE_SIZE)
- .setSchema(schema);
-
- reducer().context().query().querySqlFields(qry, false).getAll();
- }
-
- /**
- * Executes specified query and checks the root span of query execution.
- *
- * @param sql SQL query to execute.
- * @param schema SQL query schema.
- * @param skipReducerOnUpdate Wether reduce phase should be skipped during update query execution.
- * @param distributedJoins Whether distributed joins enabled.
- * @param isQry {@code True} if query is SELECT, {@code False} - DML queries, {@code null} - all remainings.
- */
- protected SpanId executeAndCheckRootSpan(
- String sql,
- String schema,
- boolean skipReducerOnUpdate,
- boolean distributedJoins,
- Boolean isQry
- ) throws Exception {
- executeQuery(sql, schema, skipReducerOnUpdate, distributedJoins, isQry);
-
- handler().flush();
-
- checkDroppedSpans();
-
- return checkSpan(
- SQL_QRY,
- null,
- 1,
- ImmutableMap.builder()
- .put(NODE_ID, reducer().localNode().id().toString())
- .put(tag(NODE, CONSISTENT_ID), reducer().localNode().consistentId().toString())
- .put(tag(NODE, NAME), reducer().name())
- .put(SQL_QRY_TEXT, sql)
- .put(SQL_SCHEMA, schema)
- .build(),
- CheckAttributes.CONTAINS
- ).get(0);
- }
-
- /**
- * @return Name of the table which was created.
- */
- protected String createTableAndPopulate(Class> cls, CacheMode mode, int qryParallelism) {
- IgniteCache cache = grid(0).createCache(
- new CacheConfiguration(cls.getSimpleName() + "_" + mode)
- .setIndexedTypes(Integer.class, cls)
- .setCacheMode(mode)
- .setQueryParallelism(qryParallelism)
- .setSqlSchema(TEST_SCHEMA)
- );
-
- awaitCacheOnClient(grid(GRID_CNT), cache.getName());
-
- for (int i = 0; i < TEST_TABLE_POPULATION; i++)
- cache.put(keyCntr.getAndIncrement(), cls == Organization.class ? new Organization(i, i) : new Person(i, i));
-
- return TEST_SCHEMA + '.' + cls.getSimpleName();
- }
-
- /**
- * Checks that no spans were dropped by OpencenCensus due to exporter buffer overflow.
- */
- protected void checkDroppedSpans() {
- Object worker = U.field(Tracing.getExportComponent().getSpanExporter(), "worker");
-
- long droppedSpans = U.field(worker, "droppedSpans");
-
- assertEquals("Some spans were dropped by OpencenCensus due to exporter buffer overflow.",
- 0, droppedSpans);
- }
-
- /**
- * @return Reducer node.
- */
- protected IgniteEx reducer() {
- return ignite(GRID_CNT);
- }
-
- /**
- * @return Number of nodes in cluster except reducer.
- */
- protected int mapNodesCount() {
- return GRID_CNT;
- }
-
- /** */
- public static class Person {
- /** */
- @QuerySqlField(index = true)
- private int prsnId;
-
- /** */
- @QuerySqlField
- private int prsnVal;
-
- /** */
- public Person(int prsnId, int prsnVal) {
- this.prsnId = prsnId;
- this.prsnVal = prsnVal;
- }
- }
-
- /** */
- public static class Organization {
- /** */
- @QuerySqlField(index = true)
- private int orgId;
-
- /** */
- @QuerySqlField
- private int orgVal;
-
- /** */
- public Organization(int orgId, int orgVal) {
- this.orgId = orgId;
- this.orgVal = orgVal;
- }
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetAllTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetAllTest.java
deleted file mode 100644
index bad320d250fc6..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetAllTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationManager;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.junit.Test;
-
-import static org.apache.ignite.spi.tracing.Scope.TX;
-
-/**
- * Tests for OpenCensus based {@link TracingConfigurationManager#getAll(Scope)}.
- */
-public class OpenCensusTracingConfigurationGetAllTest extends AbstractTracingTest {
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /**
- * Ensure that getAll() retrieves default transaction configuration.
- */
- @Test
- public void testThatDefaultConfigurationReturnsIfScopeNotSpecifiedAndCustomConfigurationNotSet() {
- assertEquals(
- DFLT_CONFIG_MAP,
- grid(0).tracingConfiguration().getAll(null));
- }
-
- /**
- * Ensure that getAll(Scope) retrieves default scope specific transaction configuration.
- */
- @Test
- public void testThatDefaultScopeSpecificConfigurationReturnsIfScopeIsSpecifiedAndCustomConfigurationNotSet() {
- assertEquals(
- Collections.singletonMap(
- TX_SCOPE_SPECIFIC_COORDINATES,
- TracingConfigurationManager.DEFAULT_TX_CONFIGURATION),
- grid(0).tracingConfiguration().getAll(TX));
- }
-
- /**
- * Update any scope specific configuration and add some label specific one.
- * Ensure that getAll() retrieves tracing configuration including updated one.
- */
- @Test
- public void testThatCustomConfigurationReturnsIfScopeNotSpecifiedAndCustomConfigurationIsSet() {
- grid(0).tracingConfiguration().set(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- Map expTracingCfg =
- new HashMap<>(DFLT_CONFIG_MAP);
-
- expTracingCfg.put(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- expTracingCfg.put(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- assertEquals(
- expTracingCfg,
- grid(0).tracingConfiguration().getAll(null));
- }
-
- /**
- * Update any scope specific configuration and add some label specific one.
- * Ensure that getAll(scope) retrieves updated scope specific configuration.
- */
- @Test
- public void testThatCustomScopeSpecificConfigurationReturnsIfScopeIsSpecifiedAndCustomConfigurationIsSet() {
- grid(0).tracingConfiguration().set(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- Map expTracingCfg = new HashMap<>();
-
- expTracingCfg.put(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- expTracingCfg.put(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- assertEquals(
- expTracingCfg,
- grid(0).tracingConfiguration().getAll(TX));
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetTest.java
deleted file mode 100644
index 88439f8110db9..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationGetTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.Collections;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationManager;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.junit.Test;
-
-import static org.apache.ignite.spi.tracing.Scope.COMMUNICATION;
-import static org.apache.ignite.spi.tracing.Scope.TX;
-
-/**
- * Tests for OpenCensus based {@link TracingConfigurationManager#get(TracingConfigurationCoordinates)}.
- */
-public class OpenCensusTracingConfigurationGetTest extends AbstractTracingTest {
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /**
- * Ensure that label specific configuration get returns default scope specific if there's
- * neither corresponding custom label specific nor corresponding custom scope specific.
- */
- @Test
- public void testThatLabelSpecificConfigurationGetReturnsDefaultIfCustomConfigurationNotSet() {
- assertEquals(
- TracingConfigurationManager.DEFAULT_TX_CONFIGURATION,
- grid(0).tracingConfiguration().get(
- new TracingConfigurationCoordinates.Builder(TX).withLabel("label").build()));
- }
-
- /**
- * Ensure that label specific configuration get returns custom scope specific if there's no
- * corresponding custom label specific one.
- */
- @Test
- public void testThatLabelSpecificConfigurationGetReturnsCustomScopeSpecificIfLabelSpecificIsNotSet() {
- TracingConfigurationCoordinates coords =
- new TracingConfigurationCoordinates.Builder(TX).build();
-
- TracingConfigurationParameters expScopeSpecificParameters =
- new TracingConfigurationParameters.Builder().
- withSamplingRate(0.2).
- withIncludedScopes(Collections.singleton(COMMUNICATION)).build();
-
- grid(0).tracingConfiguration().set(coords, expScopeSpecificParameters);
-
- assertEquals(
- expScopeSpecificParameters,
- grid(0).tracingConfiguration().get(
- new TracingConfigurationCoordinates.Builder(TX).withLabel("label").build()));
- }
-
- /**
- * Ensure that label specific configuration get returns custom label specific is such one is present.
- */
- @Test
- public void testThatLabelSpecificConfigurationGetReturnsLabelSpecificOne() {
- TracingConfigurationCoordinates coords =
- new TracingConfigurationCoordinates.Builder(TX).withLabel("label").build();
-
- TracingConfigurationParameters expScopeSpecificParameters =
- new TracingConfigurationParameters.Builder().
- withSamplingRate(0.35).
- withIncludedScopes(Collections.singleton(COMMUNICATION)).build();
-
- grid(0).tracingConfiguration().set(coords, expScopeSpecificParameters);
-
- assertEquals(
- expScopeSpecificParameters,
- grid(0).tracingConfiguration().get(coords));
- }
-
- /**
- * Ensure that scope specific configuration get returns default scope specific if there's no corresponding
- * custom specific one.
- */
- @Test
- public void testThatScopeSpecificConfigurationGetReturnsDefaultOneIfCustomConfigurationNotSet() {
- assertEquals(
- TracingConfigurationManager.DEFAULT_TX_CONFIGURATION,
- grid(0).tracingConfiguration().get(
- new TracingConfigurationCoordinates.Builder(TX).build()));
- }
-
- /**
- * Ensure that scope specific configuration get returns corresponding custom specific one if it's available.
- */
- @Test
- public void testThatScopeSpecificConfigurationGetReturnsCustomScopeSpecific() {
- TracingConfigurationCoordinates coords =
- new TracingConfigurationCoordinates.Builder(TX).build();
-
- TracingConfigurationParameters expScopeSpecificParameters =
- new TracingConfigurationParameters.Builder().
- withSamplingRate(0.2).
- withIncludedScopes(Collections.singleton(COMMUNICATION)).build();
-
- grid(0).tracingConfiguration().set(coords, expScopeSpecificParameters);
-
- assertEquals(
- expScopeSpecificParameters,
- grid(0).tracingConfiguration().get(coords));
- }
-
- /**
- * Ensure that scope specific configuration get returns corresponding custom specific one if it's available
- * and ignores label specific one.
- */
- @Test
- public void testThatScopeSpecificConfigurationGetReturnsScopeSpecificEventIfLabelSpecificIsSet() {
- TracingConfigurationCoordinates scopeSpecificCoords =
- new TracingConfigurationCoordinates.Builder(TX).build();
-
- TracingConfigurationCoordinates lbSpecificCoords =
- new TracingConfigurationCoordinates.Builder(TX).withLabel("label").build();
-
- TracingConfigurationParameters expScopeSpecificParameters =
- new TracingConfigurationParameters.Builder().
- withSamplingRate(0.35).
- withIncludedScopes(Collections.singleton(COMMUNICATION)).build();
-
- grid(0).tracingConfiguration().set(lbSpecificCoords, expScopeSpecificParameters);
-
- assertEquals(
- TracingConfigurationManager.DEFAULT_TX_CONFIGURATION,
- grid(0).tracingConfiguration().get(scopeSpecificCoords));
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetAllTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetAllTest.java
deleted file mode 100644
index c5ac198aad9dd..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetAllTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationManager;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.junit.Test;
-
-import static org.apache.ignite.spi.tracing.Scope.TX;
-
-/**
- * Tests for OpenCensus based {@link TracingConfigurationManager#resetAll(Scope)}.
- */
-public class OpenCensusTracingConfigurationResetAllTest extends AbstractTracingTest {
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
-
- /**
- * Ensure that resetAll() default tracing configuration doesn't effect it.
- */
- @Test
- public void testThatResetAllDefaultTracingConfigurationDoesNotEffectIt() {
- grid(0).tracingConfiguration().resetAll(TX);
-
- grid(0).tracingConfiguration().resetAll(null);
-
- assertEquals(
- DFLT_CONFIG_MAP,
- grid(0).tracingConfiguration().getAll(null));
- }
-
- /**
- * Ensure that resetAll(scope) resets specified scope and only specified scope.
- */
- @Test
- public void testThatResetAllWithSpecificScopeResetsOnlySpecificScopeBasedConfiguration() {
- grid(0).tracingConfiguration().set(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(EXCHANGE_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- // Reset scope specific configuration.
- grid(0).tracingConfiguration().resetAll(TX);
-
- Map expTracingCfg =
- new HashMap<>(DFLT_CONFIG_MAP);
-
- expTracingCfg.put(EXCHANGE_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- assertEquals(
- expTracingCfg,
- grid(0).tracingConfiguration().getAll(null));
- }
-
- /**
- * Ensure that resetAll(null) resets configuration of all scopes.
- */
- @Test
- public void testThatResetAllResetsAllTracingConfigurations() {
- grid(0).tracingConfiguration().set(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(EXCHANGE_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- // Reset scope specific configuration.
- grid(0).tracingConfiguration().resetAll(null);
-
- assertEquals(
- DFLT_CONFIG_MAP,
- grid(0).tracingConfiguration().getAll(null));
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetTest.java
deleted file mode 100644
index 0a8265ffc5ed2..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingConfigurationResetTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationManager;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.junit.Test;
-
-/**
- * Tests for OpenCensus based {@link TracingConfigurationManager#reset(TracingConfigurationCoordinates)}.
- */
-public class OpenCensusTracingConfigurationResetTest extends AbstractTracingTest {
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /**
- * Ensure that resetting default tracing configuration doesn't effect it.
- */
- @Test
- public void testThatResettingDefaultTracingConfigurationDoesNotEffectIt() {
- grid(0).tracingConfiguration().reset(TX_SCOPE_SPECIFIC_COORDINATES);
-
- assertEquals(
- DFLT_CONFIG_MAP,
- grid(0).tracingConfiguration().getAll(null));
- }
-
- /**
- * Update any scope specific configuration and add some label specific one.
- * Reset scope specific configuration and ensure that it was restored to default,
- * also ensure that label specific configuration wasn't affected.
- */
- @Test
- public void testThatResettingScopeSpecificConfigurationWithScopeAndLabelSpecificItemsRestoresOnlyScopeToDefault() {
- grid(0).tracingConfiguration().set(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(EXCHANGE_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- Map expTracingCfg =
- new HashMap<>(DFLT_CONFIG_MAP);
-
- expTracingCfg.put(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- expTracingCfg.put(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- expTracingCfg.put(EXCHANGE_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- // Check tracing configuration. Just in case.
- assertEquals(
- expTracingCfg,
- grid(0).tracingConfiguration().getAll(null));
-
- // Reset scope specific configuration.
- grid(0).tracingConfiguration().reset(TX_SCOPE_SPECIFIC_COORDINATES);
-
- // Modify expected tracing configuration map to reflect changes after resetting scope specific configuration.
- expTracingCfg.put(TX_SCOPE_SPECIFIC_COORDINATES, TracingConfigurationManager.DEFAULT_TX_CONFIGURATION);
-
- // Check tracing configuration after resetting.
- assertEquals(
- expTracingCfg,
- grid(0).tracingConfiguration().getAll(null));
-
- // Just in case, assert with simple get()
- assertEquals(
- TracingConfigurationManager.DEFAULT_TX_CONFIGURATION,
- grid(0).tracingConfiguration().get(TX_SCOPE_SPECIFIC_COORDINATES));
-
- assertEquals(
- SOME_LABEL_SPECIFIC_PARAMETERS,
- grid(0).tracingConfiguration().get(TX_LABEL_SPECIFIC_COORDINATES));
-
- assertEquals(
- SOME_SCOPE_SPECIFIC_PARAMETERS,
- grid(0).tracingConfiguration().get(EXCHANGE_SCOPE_SPECIFIC_COORDINATES));
- }
-
- /**
- * Update any scope specific configuration and add some label specific one.
- * Reset label specific configuration and ensure that it was restored to default,
- * also ensure that scope specific configuration wasn't affected.
- */
- @Test
- public void testThatResettingLabelSpecificConfigurationWithScopeAndLabelSpecificItemsRestoresOnlyLabelToDefault() {
- grid(0).tracingConfiguration().set(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- grid(0).tracingConfiguration().set(EXCHANGE_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- Map expTracingCfg =
- new HashMap<>(DFLT_CONFIG_MAP);
-
- expTracingCfg.put(TX_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- expTracingCfg.put(TX_LABEL_SPECIFIC_COORDINATES, SOME_LABEL_SPECIFIC_PARAMETERS);
-
- expTracingCfg.put(EXCHANGE_SCOPE_SPECIFIC_COORDINATES, SOME_SCOPE_SPECIFIC_PARAMETERS);
-
- // Check tracing configuration. Just in case.
- assertEquals(
- expTracingCfg,
- grid(0).tracingConfiguration().getAll(null));
-
- // Reset scope specific configuration.
- grid(0).tracingConfiguration().reset(TX_LABEL_SPECIFIC_COORDINATES);
-
- // Modify expected tracing configuration map to reflect changes after resetting scope specific configuration.
- expTracingCfg.remove(TX_LABEL_SPECIFIC_COORDINATES);
-
- // Check tracing configuration after resetting.
- assertEquals(
- expTracingCfg,
- grid(0).tracingConfiguration().getAll(null));
-
- // Just in case, assert with simple get()
- assertEquals(
- SOME_SCOPE_SPECIFIC_PARAMETERS,
- grid(0).tracingConfiguration().get(TX_SCOPE_SPECIFIC_COORDINATES));
-
- // Cause there's no label specific configuration after reset, scope specific should be returned.
- assertEquals(
- SOME_SCOPE_SPECIFIC_PARAMETERS,
- grid(0).tracingConfiguration().get(TX_LABEL_SPECIFIC_COORDINATES));
-
- assertEquals(
- SOME_SCOPE_SPECIFIC_PARAMETERS,
- grid(0).tracingConfiguration().get(EXCHANGE_SCOPE_SPECIFIC_COORDINATES));
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingSpiTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingSpiTest.java
deleted file mode 100644
index 8308e6dc8e040..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTracingSpiTest.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import io.opencensus.trace.AttributeValue;
-import io.opencensus.trace.Status;
-import io.opencensus.trace.export.SpanData;
-import org.apache.ignite.events.EventType;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.processors.tracing.MTC;
-import org.apache.ignite.internal.processors.tracing.SpanTags;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.junit.Assert;
-import org.junit.Test;
-
-import static io.opencensus.trace.AttributeValue.stringAttributeValue;
-import static java.lang.Integer.parseInt;
-import static org.apache.ignite.internal.processors.tracing.SpanTags.SOCKET_WRITE_BYTES;
-import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_JOB_EXECUTE_REQUEST;
-import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_JOB_EXECUTE_RESPONSE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_REGULAR_PROCESS;
-import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_READ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_WRITE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.CUSTOM_JOB_CALL;
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_CUSTOM_EVENT;
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_JOIN_ADD;
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_JOIN_FINISH;
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_JOIN_REQUEST;
-import static org.apache.ignite.internal.processors.tracing.SpanType.DISCOVERY_NODE_LEFT;
-import static org.apache.ignite.internal.processors.tracing.SpanType.EXCHANGE_FUTURE;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS;
-
-/**
- * Tests to check correctness of OpenCensus Tracing SPI implementation.
- */
-public class OpenCensusTracingSpiTest extends AbstractTracingTest {
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /** {@inheritDoc} */
- @Override public void before() throws Exception {
- super.before();
-
- grid(0).tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(Scope.DISCOVERY).build(),
- new TracingConfigurationParameters.Builder().
- withSamplingRate(SAMPLING_RATE_ALWAYS).build());
-
- grid(0).tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(Scope.COMMUNICATION).build(),
- new TracingConfigurationParameters.Builder().
- withSamplingRate(SAMPLING_RATE_ALWAYS).build());
- }
-
- /**
- * Test checks that node join process is traced correctly in positive case.
- */
- @Test
- public void testNodeJoinTracing() throws Exception {
- IgniteEx joinedNode = startGrid(GRID_CNT);
-
- awaitPartitionMapExchange();
-
- // Consistent id is the same with node name.
- List clusterNodeNames = grid(0).cluster().nodes()
- .stream().map(node -> (String)node.consistentId()).collect(Collectors.toList());
-
- handler().flush();
-
- String joinedNodeId = joinedNode.localNode().id().toString();
-
- // Check existence of Traces.Discovery.NODE_JOIN_REQUEST spans with OK status on all nodes:
- Map nodeJoinReqSpans = handler().allSpans()
- .filter(span -> DISCOVERY_NODE_JOIN_REQUEST.spanName().equals(span.getName()))
- .filter(span -> span.getStatus() == Status.OK)
- .filter(span -> stringAttributeValue(joinedNodeId).equals(
- span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))))
- .collect(Collectors.toMap(
- span -> span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.NODE, SpanTags.NAME)),
- span -> span
- ));
-
- // NODE_JOIN_REQUEST must be processed at least on coordinator node.
- // For other nodes there is no such guarantee.
- int CRD_IDX = 0;
- clusterNodeNames.stream().filter(
- node -> node.endsWith(String.valueOf(CRD_IDX))
- ).forEach(nodeName ->
- Assert.assertTrue(
- String.format(
- "%s not found on node with name=%s, nodeJoinReqSpans=%s",
- DISCOVERY_NODE_JOIN_REQUEST, nodeName, nodeJoinReqSpans),
- nodeJoinReqSpans.containsKey(stringAttributeValue(nodeName)))
- );
-
- // Check existence of Traces.Discovery.NODE_JOIN_ADD spans with OK status on all nodes:
- for (int i = 0; i <= GRID_CNT; i++) {
- List nodeJoinAddSpans = handler().spansReportedByNode(getTestIgniteInstanceName(i))
- .filter(span -> DISCOVERY_NODE_JOIN_ADD.spanName().equals(span.getName()))
- .filter(span -> span.getStatus() == Status.OK)
- .filter(span -> stringAttributeValue(joinedNodeId).equals(
- span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))))
- .collect(Collectors.toList());
-
- Assert.assertTrue(
- String.format("%s span not found, nodeId=%d",
- DISCOVERY_NODE_JOIN_ADD, i),
- !nodeJoinReqSpans.isEmpty()
- );
-
- nodeJoinAddSpans.forEach(spanData -> {
- SpanData parentSpan = handler().spanById(spanData.getParentSpanId());
-
- Assert.assertNotNull(
- "Parent span doesn't exist for " + spanData,
- parentSpan
- );
- Assert.assertEquals(
- "Parent span name is invalid, parentSpan=" + parentSpan,
- DISCOVERY_NODE_JOIN_REQUEST.spanName(),
- parentSpan.getName()
- );
- Assert.assertEquals(
- "Parent span is not related to joined node, parentSpan=" + parentSpan,
- stringAttributeValue(joinedNodeId),
- parentSpan.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))
- );
- });
- }
-
- // Check existence of Traces.Discovery.NODE_JOIN_FINISH spans with OK status on all nodes:
- for (int i = 0; i <= GRID_CNT; i++) {
- List nodeJoinAddSpans = handler().spansReportedByNode(getTestIgniteInstanceName(i))
- .filter(span -> DISCOVERY_NODE_JOIN_FINISH.spanName().equals(span.getName()))
- .filter(span -> span.getStatus() == Status.OK)
- .filter(span -> stringAttributeValue(joinedNodeId).equals(
- span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))))
- .collect(Collectors.toList());
-
- Assert.assertTrue(
- String.format("%s span not found, nodeId=%d",
- DISCOVERY_NODE_JOIN_FINISH, i),
- !nodeJoinReqSpans.isEmpty()
- );
-
- nodeJoinAddSpans.forEach(spanData -> {
- SpanData parentSpan = handler().spanById(spanData.getParentSpanId());
-
- Assert.assertNotNull(
- "Parent span doesn't exist for " + spanData,
- parentSpan
- );
- Assert.assertEquals(
- "Parent span name is invalid " + parentSpan,
- DISCOVERY_NODE_JOIN_ADD.spanName(),
- parentSpan.getName()
- );
- Assert.assertEquals(
- "Parent span is not related to joined node " + parentSpan,
- stringAttributeValue(joinedNodeId),
- parentSpan.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))
- );
- });
- }
- }
-
- /**
- * Test checks that node left process is traced correctly in positive case.
- */
- @Test
- public void testNodeLeftTracing() throws Exception {
- // Consistent id is the same with node name.
- List clusterNodeNames = grid(0).cluster().forServers().nodes()
- .stream().map(node -> (String)node.consistentId()).collect(Collectors.toList());
-
- String leftNodeId = grid(GRID_CNT - 1).localNode().id().toString();
-
- stopGrid(GRID_CNT - 1);
-
- awaitPartitionMapExchange();
-
- handler().flush();
-
- // Check existence of DISCOVERY_NODE_LEFT spans with OK status on all nodes:
- Map nodeLeftSpans = handler().allSpans()
- .filter(span -> DISCOVERY_NODE_LEFT.spanName().equals(span.getName()))
- .filter(span -> stringAttributeValue(leftNodeId).equals(
- span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))))
- .filter(span -> span.getStatus() == Status.OK)
- .collect(Collectors.toMap(
- span -> span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.NODE, SpanTags.NAME)),
- span -> span,
- (span1, span2) -> {
- throw new AssertionError(String.format(
- "More than 1 %s span handled on a node (id can be extracted from span), " +
- "existingSpan=%s, extraSpan=%s",
- DISCOVERY_NODE_LEFT, span1, span2
- ));
- }
- ));
-
- clusterNodeNames.forEach(nodeName ->
- Assert.assertTrue(
- "Span " + DISCOVERY_NODE_LEFT + " doesn't exist on node with name=" + nodeName,
- nodeLeftSpans.containsKey(stringAttributeValue(nodeName)))
- );
- }
-
- /**
- * Test checks that PME process in case of node left discovery event is traced correctly in positive case.
- */
- @Test
- public void testPartitionsMapExchangeTracing() throws Exception {
- long curTopVer = grid(0).cluster().topologyVersion();
-
- String leftNodeId = grid(GRID_CNT - 1).localNode().id().toString();
-
- stopGrid(GRID_CNT - 1);
-
- awaitPartitionMapExchange();
-
- handler().flush();
-
- // Check PME for NODE_LEFT event on remaining nodes:
- for (int i = 0; i < GRID_CNT - 1; i++) {
- List exchFutSpans = handler().spansReportedByNode(getTestIgniteInstanceName(i))
- .filter(span -> EXCHANGE_FUTURE.spanName().equals(span.getName()))
- .filter(span -> span.getStatus() == Status.OK)
- .filter(span -> AttributeValue.stringAttributeValue(String.valueOf(EventType.EVT_NODE_LEFT)).equals(
- span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT, SpanTags.TYPE))))
- .filter(span -> stringAttributeValue(leftNodeId).equals(
- span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))))
- .collect(Collectors.toList());
-
- Assert.assertTrue(
- String.format("%s span not found (or more than 1), nodeId=%d, exchFutSpans=%s",
- EXCHANGE_FUTURE, i, exchFutSpans),
- exchFutSpans.size() == 1
- );
-
- exchFutSpans.forEach(span -> {
- SpanData parentSpan = handler().spanById(span.getParentSpanId());
-
- Assert.assertNotNull(
- "Parent span doesn't exist for " + span,
- parentSpan
- );
- Assert.assertEquals(
- "Parent span name is invalid " + parentSpan,
- DISCOVERY_NODE_LEFT.spanName(),
- parentSpan.getName()
- );
- Assert.assertEquals(
- "Parent span is not related to joined node " + parentSpan,
- stringAttributeValue(leftNodeId),
- parentSpan.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID))
- );
- Assert.assertEquals(
- "Exchange future major topology version is invalid " + span,
- AttributeValue.stringAttributeValue(String.valueOf(curTopVer + 1)),
- span.getAttributes().getAttributeMap().get(
- SpanTags.tag(SpanTags.RESULT, SpanTags.TOPOLOGY_VERSION, SpanTags.MAJOR))
- );
- Assert.assertEquals(
- "Exchange future minor version is invalid " + span,
- AttributeValue.stringAttributeValue("0"),
- span.getAttributes().getAttributeMap().get(
- SpanTags.tag(SpanTags.RESULT, SpanTags.TOPOLOGY_VERSION, SpanTags.MINOR))
- );
- });
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- @Test
- public void testCommunicationMessages() throws Exception {
- IgniteEx ignite = grid(0);
- IgniteEx ignite1 = grid(1);
-
- try (MTC.TraceSurroundings ignore = MTC.support(ignite.context().tracing().create(CUSTOM_JOB_CALL))) {
- ignite.compute(ignite.cluster().forNode(ignite1.localNode())).withNoFailover().call(() -> "");
- }
-
- handler().flush();
-
- SpanData jobSpan = handler().spanByName(CUSTOM_JOB_CALL.spanName());
-
- List data = handler().unrollByParent(jobSpan);
-
- List nodejobMsgTags = data.stream()
- .filter(it -> it.getAttributes().getAttributeMap().containsKey(SpanTags.MESSAGE))
- .map(it -> it.getAttributes().getAttributeMap().get(SpanTags.MESSAGE))
- .collect(Collectors.toList());
-
- List nodejobTraces = data.stream()
- .map(SpanData::getName)
- .collect(Collectors.toList());
-
- assertEquals(nodejobTraces.toString(), 7, nodejobTraces.size());
-
- assertEquals(1, nodejobTraces.stream().filter(it -> it.contains(CUSTOM_JOB_CALL.spanName())).count());
-
- List sockWriteTraces = data.stream()
- .filter(span -> span.getName().contains(COMMUNICATION_SOCKET_WRITE.spanName()))
- .collect(Collectors.toList());
-
- //request + response
- assertEquals(2, sockWriteTraces.size());
-
- sockWriteTraces.forEach(span -> assertTrue(
- parseInt(attributeValueToString(span.getAttributes().getAttributeMap().get(SOCKET_WRITE_BYTES))) > 0));
-
- //request + response
- assertEquals(2, nodejobTraces.stream().filter(it -> it.contains(COMMUNICATION_SOCKET_READ.spanName())).count());
- //request + response
- assertEquals(2, nodejobTraces.stream().filter(it -> it.contains(COMMUNICATION_REGULAR_PROCESS.spanName())).count());
-
- assertTrue(nodejobMsgTags.stream().anyMatch(it -> it.equals(stringAttributeValue(COMMUNICATION_JOB_EXECUTE_REQUEST.spanName()))));
- assertTrue(nodejobMsgTags.stream().anyMatch(it -> it.equals(stringAttributeValue(COMMUNICATION_JOB_EXECUTE_RESPONSE.spanName()))));
- }
-
- /**
- * Ensure that root discovery.custom.event have message.class with corresponding value.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testCustomEventContainsMessageClassTag() throws Exception {
- IgniteEx ignite = grid(0);
-
- startGrid(GRID_CNT).createCache("New cache");
-
- handler().flush();
-
- // Only root discovery.custom.event spans have message.class tag.
- List rootCustomEvtSpans = handler().allSpans().
- filter(spanData ->
- DISCOVERY_CUSTOM_EVENT.spanName().equals(spanData.getName()) &&
- spanData.getParentSpanId() == null).
- collect(Collectors.toList());
-
- // Check that there's at least one discovery.custom.event span with tag "message.class"
- // and value "CacheAffinityChangeMessage"
- assertTrue(rootCustomEvtSpans.stream().anyMatch(
- span -> "CacheAffinityChangeMessage".equals(
- attributeValueToString(span.getAttributes().getAttributeMap().get(SpanTags.MESSAGE_CLASS)))));
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingConfigurationTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingConfigurationTest.java
deleted file mode 100644
index 6581c1ee3b86e..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingConfigurationTest.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Set;
-import java.util.stream.Collectors;
-import io.opencensus.trace.SpanId;
-import io.opencensus.trace.export.SpanData;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.processors.tracing.SpanType;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.apache.ignite.transactions.Transaction;
-import org.junit.Test;
-
-import static org.apache.ignite.spi.tracing.Scope.TX;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_NEVER;
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
-
-/**
- * Tests for transaction tracing configuration.
- */
-public class OpenCensusTxTracingConfigurationTest extends AbstractTracingTest {
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /**
- * Ensure that in case of sampling rate equals to 0.0 (Never) no transactions are traced.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testTxConfigurationSamplingRateNeverPreventsTxTracing() throws Exception {
- IgniteEx client = startGrid("client");
-
- client.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(TX).build(),
- new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_NEVER).build());
-
- client.transactions().txStart(PESSIMISTIC, SERIALIZABLE).commit();
-
- handler().flush();
-
- Set unexpectedTxSpanNames = Arrays.stream(SpanType.values()).
- filter(spanType -> spanType.scope() == TX).
- map(SpanType::spanName).
- collect(Collectors.toSet());
-
- java.util.List gotSpans = handler().allSpans()
- .filter(span -> unexpectedTxSpanNames.contains(span.getName()))
- .collect(Collectors.toList());
-
- assertTrue(gotSpans.isEmpty());
- }
-
- /**
- * Ensure that in case of sampling rate equals to 1.0 (Always) transactions are successfully traced.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testTxConfigurationSamplingRateAlwaysEnablesTxTracing() throws Exception {
- IgniteEx client = startGrid("client");
-
- client.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(TX).build(),
- new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).build());
-
- client.transactions().txStart(PESSIMISTIC, SERIALIZABLE).commit();
-
- handler().flush();
-
- java.util.List gotSpans = handler().allSpans()
- .filter(span -> SpanType.TX.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- assertEquals(1, gotSpans.size());
- }
-
- /**
- * Ensure that specifying 0 < sapling rate < 1 within TX scope will trace some but not all transactions.
- * Cause of probability nature of sampling, it's not possible to check that 0.5 sampling rate
- * will result in exactly half of the transactions being traced.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testTxConfigurationSamplingRateHalfSamplesSomethingAboutHalfTransactions() throws Exception {
- IgniteEx client = startGrid("client");
-
- client.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(TX).build(),
- new TracingConfigurationParameters.Builder().withSamplingRate(0.5).build());
-
- final int txAmount = 100;
-
- for (int i = 0; i < txAmount; i++)
- client.transactions().txStart(PESSIMISTIC, SERIALIZABLE).commit();
-
- handler().flush();
-
- java.util.List gotSpans = handler().allSpans()
- .filter(span -> SpanType.TX.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- // Cause of probability nature of sampling, it's not possible to check that 0.5 sampling rate will end with
- // 5 sampling transactions out of {@code txAmount},
- // so we just check that some and not all transactions were traced.
- assertTrue(!gotSpans.isEmpty() && gotSpans.size() < txAmount);
- }
-
-
- /**
- * 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 gotSpans = handler().allSpans()
- .filter(span -> parentSpanId.equals(span.getParentSpanId()) &&
- SpanType.COMMUNICATION_SOCKET_WRITE.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- assertTrue(gotSpans.isEmpty());
- }
-
- /**
- * 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 gotSpans = handler().allSpans()
- .filter(span -> parentSpanId.equals(span.getParentSpanId()) &&
- SpanType.COMMUNICATION_SOCKET_WRITE.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- assertFalse(gotSpans.isEmpty());
- }
-
- /**
- * Ensure that label specific configuration is used instead of scope specific if it's possible.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testThatLabelSpecificConfigurationIsUsedWheneverPossible() throws Exception {
- IgniteEx client = startGrid("client");
-
- final String txLbToBeTraced = "label1";
-
- final String txLbNotToBeTraced = "label2";
-
- client.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(TX).withLabel(txLbToBeTraced).build(),
- new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).build());
-
- client.transactions().withLabel(txLbToBeTraced).txStart(PESSIMISTIC, SERIALIZABLE).commit();
-
- handler().flush();
-
- java.util.List gotSpans = handler().allSpans()
- .filter(span -> SpanType.TX.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- assertEquals(1, gotSpans.size());
-
- // Not to be traced, cause there's neither tracing configuration with given label
- // nor scope specific tx configuration. In that case default tx tracing configuration will be used that
- // actually disables tracing.
- client.transactions().withLabel(txLbNotToBeTraced).txStart(PESSIMISTIC, SERIALIZABLE).commit();
-
- handler().flush();
-
- gotSpans = handler().allSpans()
- .filter(span -> SpanType.TX.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- // Still only one, previously detected, span is expected.
- assertEquals(1, gotSpans.size());
- }
-
- /**
- * Ensure that scope specific configuration is used if corresponding label specific not found.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testThatScopeSpecificConfigurationIsUsedIfLabelSpecificNotFound() throws Exception {
- IgniteEx client = startGrid("client");
-
- client.tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(TX).build(),
- new TracingConfigurationParameters.Builder().withSamplingRate(SAMPLING_RATE_ALWAYS).build());
-
- client.transactions().withLabel("label1").txStart(PESSIMISTIC, SERIALIZABLE).commit();
-
- handler().flush();
-
- java.util.List gotSpans = handler().allSpans()
- .filter(span -> SpanType.TX.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- assertEquals(1, gotSpans.size());
- }
-
- /**
- * Ensure that default scope specific configuration is used if there's no neither label specif not custom scope specific ones.
- * Also ensure that by default TX tracing is disabled.
- *
- * @throws Exception If Failed.
- */
- @Test
- public void testThatDefaultConfigurationIsUsedIfScopeSpecificNotFoundAndThatByDefaultTxTracingIsDisabled()
- throws Exception {
- IgniteEx client = startGrid("client");
-
- client.transactions().withLabel("label1").txStart(PESSIMISTIC, SERIALIZABLE).commit();
-
- handler().flush();
-
- java.util.List gotSpans = handler().allSpans()
- .filter(span -> SpanType.TX.spanName().equals(span.getName()))
- .collect(Collectors.toList());
-
- assertTrue(gotSpans.isEmpty());
- }
-}
diff --git a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingTest.java b/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingTest.java
deleted file mode 100644
index 891ae13732f19..0000000000000
--- a/modules/opencensus/src/test/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusTxTracingTest.java
+++ /dev/null
@@ -1,1084 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.monitoring.opencensus;
-
-import java.util.List;
-import com.google.common.collect.ImmutableMap;
-import io.opencensus.trace.SpanId;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.spi.tracing.Scope;
-import org.apache.ignite.spi.tracing.TracingConfigurationCoordinates;
-import org.apache.ignite.spi.tracing.TracingConfigurationParameters;
-import org.apache.ignite.spi.tracing.TracingSpi;
-import org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi;
-import org.apache.ignite.transactions.Transaction;
-import org.junit.Test;
-
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_CLOSE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_COLOCATED_LOCK_MAP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_COMMIT;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_DHT_FINISH;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_DHT_PREPARE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_ENLIST_WRITE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_FINISH;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_FINISH_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_FINISH_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_PREPARE;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_PREPARE_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_NEAR_PREPARE_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_PROCESS_DHT_FINISH_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_PROCESS_DHT_PREPARE_REQ;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_PROCESS_DHT_PREPARE_RESP;
-import static org.apache.ignite.internal.processors.tracing.SpanType.TX_ROLLBACK;
-import static org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS;
-import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
-import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
-
-/**
- * Tests to check correctness of OpenCensus Transactions Tracing implementation.
- */
-public class OpenCensusTxTracingTest extends AbstractTracingTest {
-
- /** {@inheritDoc} */
- @Override protected TracingSpi getTracingSpi() {
- return new OpenCensusTracingSpi();
- }
-
- /** {@inheritDoc} */
- @Override public void before() throws Exception {
- super.before();
-
- grid(0).tracingConfiguration().set(
- new TracingConfigurationCoordinates.Builder(Scope.TX).build(),
- new TracingConfigurationParameters.Builder().
- withSamplingRate(SAMPLING_RATE_ALWAYS).build());
- }
-
- /**
- *
- *
Run pessimistic serializable transaction with some label.