From 4a4a8fa6c04fe57ef5037fd0d49c1c416a1f3e24 Mon Sep 17 00:00:00 2001 From: Sachin Kale Date: Fri, 15 Sep 2023 22:00:28 +0530 Subject: [PATCH 1/9] Always create empty translog on replica for remote store enabled index (#10012) Signed-off-by: Sachin Kale --- .../opensearch/remotestore/RemoteStoreIT.java | 70 +++++++++++++++++++ .../opensearch/index/shard/IndexShard.java | 44 ++++++++---- .../index/translog/TranslogHeader.java | 6 +- 3 files changed, 107 insertions(+), 13 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java index bd019693f01ff..3ccf563941f9c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java @@ -8,6 +8,7 @@ package org.opensearch.remotestore; +import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; import org.opensearch.action.admin.indices.delete.DeleteIndexRequest; import org.opensearch.action.admin.indices.get.GetIndexRequest; import org.opensearch.action.admin.indices.get.GetIndexResponse; @@ -33,16 +34,20 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; +import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.opensearch.index.shard.RemoteStoreRefreshListener.LAST_N_METADATA_FILES_TO_KEEP; import static org.opensearch.indices.IndicesService.CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.comparesEqualTo; +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.oneOf; @@ -346,4 +351,69 @@ private void clearClusterBufferIntervalSetting(String clusterManagerName) { .setTransientSettings(Settings.builder().putNull(CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING.getKey())) .get(); } + + public void testRestoreSnapshotToIndexWithSameNameDifferentUUID() throws Exception { + internalCluster().startClusterManagerOnlyNode(); + List dataNodes = internalCluster().startDataOnlyNodes(2); + + Path absolutePath = randomRepoPath().toAbsolutePath(); + assertAcked( + clusterAdmin().preparePutRepository("test-repo").setType("fs").setSettings(Settings.builder().put("location", absolutePath)) + ); + + logger.info("--> Create index and ingest 50 docs"); + createIndex(INDEX_NAME, remoteStoreIndexSettings(1)); + indexBulk(INDEX_NAME, 50); + flushAndRefresh(INDEX_NAME); + + String originalIndexUUID = client().admin() + .indices() + .prepareGetSettings(INDEX_NAME) + .get() + .getSetting(INDEX_NAME, IndexMetadata.SETTING_INDEX_UUID); + assertNotNull(originalIndexUUID); + assertNotEquals(IndexMetadata.INDEX_UUID_NA_VALUE, originalIndexUUID); + + ensureGreen(); + + logger.info("--> take a snapshot"); + client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setIndices(INDEX_NAME).setWaitForCompletion(true).get(); + + logger.info("--> wipe all indices"); + cluster().wipeIndices(INDEX_NAME); + + logger.info("--> Create index with the same name, different UUID"); + assertAcked( + prepareCreate(INDEX_NAME).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 1)) + ); + + ensureGreen(TimeValue.timeValueSeconds(30), INDEX_NAME); + + String newIndexUUID = client().admin() + .indices() + .prepareGetSettings(INDEX_NAME) + .get() + .getSetting(INDEX_NAME, IndexMetadata.SETTING_INDEX_UUID); + assertNotNull(newIndexUUID); + assertNotEquals(IndexMetadata.INDEX_UUID_NA_VALUE, newIndexUUID); + assertNotEquals(newIndexUUID, originalIndexUUID); + + logger.info("--> close index"); + client().admin().indices().prepareClose(INDEX_NAME).get(); + + logger.info("--> restore all indices from the snapshot"); + RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot("test-repo", "test-snap") + .setWaitForCompletion(true) + .execute() + .actionGet(); + assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0)); + + flushAndRefresh(INDEX_NAME); + + ensureGreen(INDEX_NAME); + assertBusy(() -> { + assertHitCount(client(dataNodes.get(0)).prepareSearch(INDEX_NAME).setSize(0).get(), 50); + assertHitCount(client(dataNodes.get(1)).prepareSearch(INDEX_NAME).setSize(0).get(), 50); + }); + } } diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 8ed75330f938e..34c5ed2112482 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -196,6 +196,7 @@ import java.io.IOException; import java.io.PrintStream; import java.nio.channels.ClosedByInterruptException; +import java.nio.channels.FileChannel; import java.nio.charset.StandardCharsets; import java.nio.file.NoSuchFileException; import java.util.ArrayList; @@ -2355,19 +2356,38 @@ private void innerOpenEngineAndTranslog(LongSupplier globalCheckpointSupplier, b synchronized (engineMutex) { assert currentEngineReference.get() == null : "engine is running"; verifyNotClosed(); - if (indexSettings.isRemoteStoreEnabled() && syncFromRemote) { - syncSegmentsFromRemoteSegmentStore(false); - } - if (indexSettings.isRemoteTranslogStoreEnabled() && shardRouting.primary()) { + if (indexSettings.isRemoteStoreEnabled()) { + // Download missing segments from remote segment store. if (syncFromRemote) { - syncRemoteTranslogAndUpdateGlobalCheckpoint(); - } else { - // we will enter this block when we do not want to recover from remote translog. - // currently only during snapshot restore, we are coming into this block. - // here, as while initiliazing remote translog we cannot skip downloading translog files, - // so before that step, we are deleting the translog files present in remote store. - deleteTranslogFilesFromRemoteTranslog(); - + syncSegmentsFromRemoteSegmentStore(false); + } + if (shardRouting.primary()) { + if (syncFromRemote) { + syncRemoteTranslogAndUpdateGlobalCheckpoint(); + } else { + // we will enter this block when we do not want to recover from remote translog. + // currently only during snapshot restore, we are coming into this block. + // here, as while initiliazing remote translog we cannot skip downloading translog files, + // so before that step, we are deleting the translog files present in remote store. + deleteTranslogFilesFromRemoteTranslog(); + } + } else if (syncFromRemote) { + // For replicas, when we download segments from remote segment store, we need to make sure that local + // translog is having the same UUID that is referred by the segments. If they are different, engine open + // fails with TranslogCorruptedException. It is safe to create empty translog for remote store enabled + // indices as replica would only need to read translog in failover scenario and we always fetch data + // from remote translog at the time of failover. + final SegmentInfos lastCommittedSegmentInfos = store().readLastCommittedSegmentsInfo(); + final String translogUUID = lastCommittedSegmentInfos.userData.get(TRANSLOG_UUID_KEY); + final long checkpoint = Long.parseLong(lastCommittedSegmentInfos.userData.get(SequenceNumbers.LOCAL_CHECKPOINT_KEY)); + Translog.createEmptyTranslog( + shardPath().resolveTranslog(), + shardId(), + checkpoint, + getPendingPrimaryTerm(), + translogUUID, + FileChannel::open + ); } } // we must create a new engine under mutex (see IndexShard#snapshotStoreMetadata). diff --git a/server/src/main/java/org/opensearch/index/translog/TranslogHeader.java b/server/src/main/java/org/opensearch/index/translog/TranslogHeader.java index 42bda11d75783..7b5be9505f27a 100644 --- a/server/src/main/java/org/opensearch/index/translog/TranslogHeader.java +++ b/server/src/main/java/org/opensearch/index/translog/TranslogHeader.java @@ -147,7 +147,11 @@ static TranslogHeader read(final String translogUUID, final Path path, final Fil if (actualUUID.bytesEquals(expectedUUID) == false) { throw new TranslogCorruptedException( path.toString(), - "expected shard UUID " + expectedUUID + " but got: " + actualUUID + " this translog file belongs to a different translog" + "expected shard UUID " + + translogUUID + + " but got: " + + translogHeader.translogUUID + + " this translog file belongs to a different translog" ); } return translogHeader; From d34b35272fa19bc53cb0f6843a92d2d1ee4e3b47 Mon Sep 17 00:00:00 2001 From: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com> Date: Fri, 15 Sep 2023 22:03:25 +0530 Subject: [PATCH 2/9] Fix broken backward compatibility from 2.7 for IndexSorted field indices (#10045) * Fix broken backward comparibility from 2.7 for IndexSorted field indices Signed-off-by: gashutos * Adding CHANGELOG Signed-off-by: gashutos * Update server/src/main/java/org/opensearch/index/IndexSettings.java Co-authored-by: Andriy Redko Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com> * Removing unwanted logs Signed-off-by: gashutos * Removing unwanted logs Signed-off-by: gashutos * Adding index sort as part of mixed cluster to test this scenario Signed-off-by: gashutos * Removing optimization disable logic Signed-off-by: gashutos * Correcting some comments & version check to before( V_2_7_0) instead onOrBefire(V_2_6_1) since Signed-off-by: gashutos * Resolving spotless check error Signed-off-by: gashutos * Fixing broken UT - last minute checkin without copile Signed-off-by: gashutos * Improving code coverage to make codcov happy Signed-off-by: gashutos * Correcting typos and adding more tests Signed-off-by: gashutos * Removing unwanted imports Signed-off-by: gashutos --------- Signed-off-by: gashutos Signed-off-by: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com> Co-authored-by: Andriy Redko --- CHANGELOG.md | 1 + .../org/opensearch/backwards/IndexingIT.java | 32 ++++++-- .../org/opensearch/index/IndexSettings.java | 17 +++++ .../org/opensearch/index/IndexSortConfig.java | 8 +- .../index/fielddata/IndexFieldData.java | 7 ++ .../fielddata/IndexNumericFieldData.java | 21 +++++- .../opensearch/index/IndexServiceTests.java | 74 +++++++++++++++++++ .../AbstractFieldDataImplTestCase.java | 22 ++++++ 8 files changed, 173 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f3c3abd4162..633f005a0883d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fix ignore_missing parameter has no effect when using template snippet in rename ingest processor ([#9725](https://github.com/opensearch-project/OpenSearch/pull/9725)) +- Fix broken backward compatibility from 2.7 for IndexSorted field indices ([#10045](https://github.com/opensearch-project/OpenSearch/pull/9725)) ### Security diff --git a/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java b/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java index 686fc78dcec8a..13c2daeec37af 100644 --- a/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java @@ -67,13 +67,14 @@ public class IndexingIT extends OpenSearchRestTestCase { protected static final Version UPGRADE_FROM_VERSION = Version.fromString(System.getProperty("tests.upgrade_from_version")); + private static final String TEST_MAPPING = createTestMapping(); private int indexDocs(String index, final int idStart, final int numDocs) throws IOException { for (int i = 0; i < numDocs; i++) { final int id = idStart + i; Request request = new Request("PUT", index + "/_doc/" + id); - request.setJsonEntity("{\"test\": \"test_" + randomAlphaOfLength(2) + "\"}"); + request.setJsonEntity("{\"test\": \"test_" + randomAlphaOfLength(2) + "\", \"sortfield\": \""+ randomIntBetween(0, numDocs) + "\"}"); assertOK(client().performRequest(request)); } return numDocs; @@ -129,9 +130,10 @@ public void testIndexingWithPrimaryOnBwcNodes() throws Exception { .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) + .putList("index.sort.field", "sortfield") .put("index.routing.allocation.include._name", bwcNames); final String index = "test-index"; - createIndex(index, settings.build()); + createIndex(index, settings.build(), TEST_MAPPING); ensureNoInitializingShards(); // wait for all other shard activity to finish int docCount = 200; @@ -178,9 +180,10 @@ public void testIndexingWithReplicaOnBwcNodes() throws Exception { .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) + .putList("index.sort.field", "sortfield") .put("index.routing.allocation.exclude._name", bwcNames); final String index = "test-index"; - createIndex(index, settings.build()); + createIndex(index, settings.build(), TEST_MAPPING); ensureNoInitializingShards(); // wait for all other shard activity to finish printClusterRouting(); @@ -214,11 +217,12 @@ public void testIndexVersionPropagation() throws Exception { Settings.Builder settings = Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 2) + .putList("index.sort.field", "sortfield") .put("index.routing.allocation.include._name", bwcNames); final String index = "indexversionprop"; final int minUpdates = 5; final int maxUpdates = 10; - createIndex(index, settings.build()); + createIndex(index, settings.build(), TEST_MAPPING); try (RestClient newNodeClient = buildClient(restClientSettings(), nodes.getNewNodes().stream().map(Node::getPublishAddress).toArray(HttpHost[]::new))) { @@ -300,10 +304,11 @@ public void testSeqNoCheckpoints() throws Exception { Settings.Builder settings = Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 2) + .putList("index.sort.field", "sortfield") .put("index.routing.allocation.include._name", bwcNames); final String index = "test"; - createIndex(index, settings.build()); + createIndex(index, settings.build(), TEST_MAPPING); try (RestClient newNodeClient = buildClient(restClientSettings(), nodes.getNewNodes().stream().map(Node::getPublishAddress).toArray(HttpHost[]::new))) { int numDocs = 0; @@ -382,10 +387,11 @@ public void testUpdateSnapshotStatus() throws Exception { Settings.Builder settings = Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), between(5, 10)) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1) + .putList("index.sort.field", "sortfield") .put("index.routing.allocation.include._name", bwcNames); final String index = "test-snapshot-index"; - createIndex(index, settings.build()); + createIndex(index, settings.build(), TEST_MAPPING); indexDocs(index, 0, between(50, 100)); ensureGreen(index); assertOK(client().performRequest(new Request("POST", index + "/_refresh"))); @@ -419,7 +425,8 @@ public void testSyncedFlushTransition() throws Exception { createIndex(index, Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), numShards) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) - .put("index.routing.allocation.include._name", newNodes).build()); + .putList("index.sort.field", "sortfield") + .put("index.routing.allocation.include._name", newNodes).build(), TEST_MAPPING); ensureGreen(index); indexDocs(index, randomIntBetween(0, 100), between(1, 100)); try (RestClient oldNodeClient = buildClient(restClientSettings(), @@ -664,4 +671,15 @@ public String toString() { '}'; } } + + private static String createTestMapping() { + return " \"properties\": {\n" + + " \"test\": {\n" + + " \"type\": \"text\"\n" + + " },\n" + + " \"sortfield\": {\n" + + " \"type\": \"integer\"\n" + + " }\n" + + " }"; + } } diff --git a/server/src/main/java/org/opensearch/index/IndexSettings.java b/server/src/main/java/org/opensearch/index/IndexSettings.java index 03c71351294d5..1e4224c314f05 100644 --- a/server/src/main/java/org/opensearch/index/IndexSettings.java +++ b/server/src/main/java/org/opensearch/index/IndexSettings.java @@ -63,6 +63,7 @@ import java.util.function.Function; import java.util.function.UnaryOperator; +import static org.opensearch.Version.V_2_7_0; import static org.opensearch.common.util.FeatureFlags.SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY; import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING; import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING; @@ -660,6 +661,7 @@ public final class IndexSettings { private volatile long retentionLeaseMillis; private volatile String defaultSearchPipeline; + private final boolean widenIndexSortType; /** * The maximum age of a retention lease before it is considered expired. @@ -857,6 +859,13 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti mergeOnFlushEnabled = scopedSettings.get(INDEX_MERGE_ON_FLUSH_ENABLED); setMergeOnFlushPolicy(scopedSettings.get(INDEX_MERGE_ON_FLUSH_POLICY)); defaultSearchPipeline = scopedSettings.get(DEFAULT_SEARCH_PIPELINE); + /* There was unintentional breaking change got introduced with [OpenSearch-6424](https://github.com/opensearch-project/OpenSearch/pull/6424) (version 2.7). + * For indices created prior version (prior to 2.7) which has IndexSort type, they used to type cast the SortField.Type + * to higher bytes size like integer to long. This behavior was changed from OpenSearch 2.7 version not to + * up cast the SortField to gain some sort query optimizations. + * Now this sortField (IndexSort) is stored in SegmentInfo and we need to maintain backward compatibility for them. + */ + widenIndexSortType = IndexMetadata.SETTING_INDEX_VERSION_CREATED.get(settings).before(V_2_7_0); scopedSettings.addSettingsUpdateConsumer(MergePolicyConfig.INDEX_COMPOUND_FORMAT_SETTING, mergePolicyConfig::setNoCFSRatio); scopedSettings.addSettingsUpdateConsumer( @@ -1652,4 +1661,12 @@ public String getDefaultSearchPipeline() { public void setDefaultSearchPipeline(String defaultSearchPipeline) { this.defaultSearchPipeline = defaultSearchPipeline; } + + /** + * Returns true if we need to maintain backward compatibility for index sorted indices created prior to version 2.7 + * @return boolean + */ + public boolean shouldWidenIndexSortType() { + return this.widenIndexSortType; + } } diff --git a/server/src/main/java/org/opensearch/index/IndexSortConfig.java b/server/src/main/java/org/opensearch/index/IndexSortConfig.java index f73f96df4f9ad..83192052564f3 100644 --- a/server/src/main/java/org/opensearch/index/IndexSortConfig.java +++ b/server/src/main/java/org/opensearch/index/IndexSortConfig.java @@ -143,6 +143,7 @@ private static MultiValueMode parseMultiValueMode(String value) { // visible for tests final FieldSortSpec[] sortSpecs; + final boolean shouldWidenIndexSortType; public IndexSortConfig(IndexSettings indexSettings) { final Settings settings = indexSettings.getSettings(); @@ -182,6 +183,7 @@ public IndexSortConfig(IndexSettings indexSettings) { sortSpecs[i].missingValue = missingValues.get(i); } } + this.shouldWidenIndexSortType = indexSettings.shouldWidenIndexSortType(); } /** @@ -230,7 +232,11 @@ public Sort buildIndexSort( if (fieldData == null) { throw new IllegalArgumentException("docvalues not found for index sort field:[" + sortSpec.field + "]"); } - sortFields[i] = fieldData.sortField(sortSpec.missingValue, mode, null, reverse); + if (this.shouldWidenIndexSortType == true) { + sortFields[i] = fieldData.wideSortField(sortSpec.missingValue, mode, null, reverse); + } else { + sortFields[i] = fieldData.sortField(sortSpec.missingValue, mode, null, reverse); + } validateIndexSortField(sortFields[i]); } return new Sort(sortFields); diff --git a/server/src/main/java/org/opensearch/index/fielddata/IndexFieldData.java b/server/src/main/java/org/opensearch/index/fielddata/IndexFieldData.java index f9db28a2c56fe..81d4ce2dd8772 100644 --- a/server/src/main/java/org/opensearch/index/fielddata/IndexFieldData.java +++ b/server/src/main/java/org/opensearch/index/fielddata/IndexFieldData.java @@ -94,6 +94,13 @@ public interface IndexFieldData { */ SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse); + /** + * Returns the {@link SortField} to use for index sorting where we widen the sort field type to higher or equal bytes. + */ + default SortField wideSortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) { + return sortField(missingValue, sortMode, nested, reverse); + } + /** * Build a sort implementation specialized for aggregations. */ diff --git a/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java b/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java index ae8ffd8fe6b97..b4e90b8ab570a 100644 --- a/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java +++ b/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java @@ -151,6 +151,25 @@ public final SortField sortField(Object missingValue, MultiValueMode sortMode, N return sortField(getNumericType(), missingValue, sortMode, nested, reverse); } + @Override + public final SortField wideSortField(Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) { + // This is to support backward compatibility, the minimum number of bytes prior to OpenSearch 2.7 were 16 bytes, + // i.e all sort fields were upcasted to Long/Double with 16 bytes. + // Now from OpenSearch 2.7, the minimum number of bytes for sort field is 8 bytes, so if it comes as SortField INT, + // we need to up cast it to LONG to support backward compatibility info stored in segment info + if (getNumericType().sortFieldType == SortField.Type.INT) { + XFieldComparatorSource source = comparatorSource(NumericType.LONG, missingValue, sortMode, nested); + SortedNumericSelector.Type selectorType = sortMode == MultiValueMode.MAX + ? SortedNumericSelector.Type.MAX + : SortedNumericSelector.Type.MIN; + SortField sortField = new SortedNumericSortField(getFieldName(), SortField.Type.LONG, reverse, selectorType); + sortField.setMissingValue(source.missingObject(missingValue, reverse)); + return sortField; + } + // If already more than INT, up cast not needed. + return sortField(getNumericType(), missingValue, sortMode, nested, reverse); + } + /** * Builds a {@linkplain BucketedSort} for the {@code targetNumericType}, * casting the values if their native type doesn't match. @@ -224,7 +243,7 @@ private XFieldComparatorSource comparatorSource( source = new IntValuesComparatorSource(this, missingValue, sortMode, nested); } if (targetNumericType != getNumericType()) { - source.disableSkipping(); // disable skipping logic for caste of sort field + source.disableSkipping(); // disable skipping logic for cast of sort field } return source; } diff --git a/server/src/test/java/org/opensearch/index/IndexServiceTests.java b/server/src/test/java/org/opensearch/index/IndexServiceTests.java index 1b8e1abb1bf1b..db9f4bd305c79 100644 --- a/server/src/test/java/org/opensearch/index/IndexServiceTests.java +++ b/server/src/test/java/org/opensearch/index/IndexServiceTests.java @@ -33,7 +33,9 @@ package org.opensearch.index; import org.apache.lucene.search.MatchAllDocsQuery; +import org.apache.lucene.search.SortField; import org.apache.lucene.search.TopDocs; +import org.opensearch.Version; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.compress.CompressedXContent; @@ -526,4 +528,76 @@ public void testUpdateRemoteTranslogBufferIntervalDynamically() { indexMetadata = client().admin().cluster().prepareState().execute().actionGet().getState().metadata().index("test"); assertEquals("20s", indexMetadata.getSettings().get(IndexSettings.INDEX_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING.getKey())); } + + public void testIndexSort() { + Settings settings = Settings.builder() + .put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), "0ms") // disable + .putList("index.sort.field", "sortfield") + .build(); + try { + // Integer index sort should be remained to int sort type + IndexService index = createIndex("test", settings, createTestMapping("integer")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.INT); + + // Long index sort should be remained to long sort type + index = createIndex("test", settings, createTestMapping("long")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.LONG); + + // Float index sort should be remained to float sort type + index = createIndex("test", settings, createTestMapping("float")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.FLOAT); + + // Double index sort should be remained to double sort type + index = createIndex("test", settings, createTestMapping("double")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.DOUBLE); + + // String index sort should be remained to string sort type + index = createIndex("test", settings, createTestMapping("string")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.STRING); + } catch (IllegalArgumentException ex) { + assertEquals("failed to parse value [0ms] for setting [index.translog.sync_interval], must be >= [100ms]", ex.getMessage()); + } + } + + public void testIndexSortBackwardCompatible() { + Settings settings = Settings.builder() + .put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), "0ms") // disable + .put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), Version.V_2_6_1) + .putList("index.sort.field", "sortfield") + .build(); + try { + // Integer index sort should be converted to long sort type + IndexService index = createIndex("test", settings, createTestMapping("integer")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.LONG); + + // Long index sort should be remained to long sort type + index = createIndex("test", settings, createTestMapping("long")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.LONG); + + // Float index sort should be remained to float sort type + index = createIndex("test", settings, createTestMapping("float")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.FLOAT); + + // Double index sort should be remained to double sort type + index = createIndex("test", settings, createTestMapping("double")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.DOUBLE); + + // String index sort should be remained to string sort type + index = createIndex("test", settings, createTestMapping("string")); + assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.STRING); + } catch (IllegalArgumentException ex) { + assertEquals("failed to parse value [0ms] for setting [index.translog.sync_interval], must be >= [100ms]", ex.getMessage()); + } + } + + private static String createTestMapping(String type) { + return " \"properties\": {\n" + + " \"test\": {\n" + + " \"type\": \"text\"\n" + + " },\n" + + " \"sortfield\": {\n" + + " \"type\": \" + type + \"\n" + + " }\n" + + " }"; + } } diff --git a/server/src/test/java/org/opensearch/index/fielddata/AbstractFieldDataImplTestCase.java b/server/src/test/java/org/opensearch/index/fielddata/AbstractFieldDataImplTestCase.java index 1ffacf98a6836..2b44e759f4ff9 100644 --- a/server/src/test/java/org/opensearch/index/fielddata/AbstractFieldDataImplTestCase.java +++ b/server/src/test/java/org/opensearch/index/fielddata/AbstractFieldDataImplTestCase.java @@ -39,6 +39,7 @@ import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; +import org.apache.lucene.search.SortedNumericSortField; import org.apache.lucene.search.TopFieldDocs; import org.apache.lucene.util.BytesRef; import org.opensearch.core.common.Strings; @@ -144,6 +145,27 @@ public void testSingleValueAllSet() throws Exception { } } + public void testWideSortField() throws Exception { + if (this instanceof NoOrdinalsStringFieldDataTests || this instanceof PagedBytesStringFieldDataTests) { + return; // Numeric types are not supported there. + } + // integer to long widening should happen + IndexFieldData indexFieldData = getForField("int", "value"); + SortField sortField = indexFieldData.wideSortField(null, MultiValueMode.MIN, null, false); + assertTrue(((SortedNumericSortField) sortField).getNumericType() == SortField.Type.LONG); + + // long to long no widening should happen + indexFieldData = getForField("long", "value"); + sortField = indexFieldData.wideSortField(null, MultiValueMode.MIN, null, false); + assertTrue(((SortedNumericSortField) sortField).getNumericType() == SortField.Type.LONG); + + // float to float no widening should happen + indexFieldData = getForField("float", "value"); + sortField = indexFieldData.wideSortField(null, MultiValueMode.MIN, null, false); + assertTrue(((SortedNumericSortField) sortField).getNumericType() == SortField.Type.FLOAT); + + } + protected abstract void fillSingleValueWithMissing() throws Exception; public void assertValues(SortedBinaryDocValues values, int docId, BytesRef... actualValues) throws IOException { From 70a582fcbe82e9b4250e29cbf7d6db470370906a Mon Sep 17 00:00:00 2001 From: Kunal Kotwani Date: Fri, 15 Sep 2023 15:38:42 -0700 Subject: [PATCH 3/9] Add async read support for S3 plugin (#9694) * Add async read support for S3 plugin Signed-off-by: Kunal Kotwani (cherry picked from commit 03ddc8a6b07221b1ed60ad5627939d1f957b1c49) Signed-off-by: Kunal Kotwani * Move functionality to S3BlobContainer Signed-off-by: Kunal Kotwani --------- Signed-off-by: Kunal Kotwani --- CHANGELOG.md | 1 + .../repositories/s3/S3BlobContainer.java | 109 +++++- .../repositories/s3/utils/HttpRangeUtils.java | 22 ++ .../s3/S3BlobStoreContainerTests.java | 310 +++++++++++++++++- .../s3/utils/HttpRangeUtilsTests.java | 29 ++ 5 files changed, 458 insertions(+), 13 deletions(-) create mode 100644 plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/utils/HttpRangeUtilsTests.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 633f005a0883d..337573480adfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased 2.x] ### Added - Add metrics for thread_pool task wait time ([#9681](https://github.com/opensearch-project/OpenSearch/pull/9681)) +- Async blob read support for S3 plugin ([#9694](https://github.com/opensearch-project/OpenSearch/pull/9694)) ### Dependencies - Bump `peter-evans/create-or-update-comment` from 2 to 3 ([#9575](https://github.com/opensearch-project/OpenSearch/pull/9575)) diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java index bb1643faecc95..2911a018df337 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java @@ -32,6 +32,8 @@ package org.opensearch.repositories.s3; +import software.amazon.awssdk.core.ResponseInputStream; +import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.exception.SdkException; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.services.s3.S3AsyncClient; @@ -44,10 +46,15 @@ import software.amazon.awssdk.services.s3.model.Delete; import software.amazon.awssdk.services.s3.model.DeleteObjectsRequest; import software.amazon.awssdk.services.s3.model.DeleteObjectsResponse; +import software.amazon.awssdk.services.s3.model.GetObjectAttributesRequest; +import software.amazon.awssdk.services.s3.model.GetObjectAttributesResponse; +import software.amazon.awssdk.services.s3.model.GetObjectRequest; +import software.amazon.awssdk.services.s3.model.GetObjectResponse; import software.amazon.awssdk.services.s3.model.HeadObjectRequest; import software.amazon.awssdk.services.s3.model.ListObjectsV2Request; import software.amazon.awssdk.services.s3.model.ListObjectsV2Response; import software.amazon.awssdk.services.s3.model.NoSuchKeyException; +import software.amazon.awssdk.services.s3.model.ObjectAttributes; import software.amazon.awssdk.services.s3.model.ObjectIdentifier; import software.amazon.awssdk.services.s3.model.PutObjectRequest; import software.amazon.awssdk.services.s3.model.S3Error; @@ -63,6 +70,7 @@ import org.opensearch.common.Nullable; import org.opensearch.common.SetOnce; import org.opensearch.common.StreamContext; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.blobstore.AsyncMultiStreamBlobContainer; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; @@ -75,11 +83,13 @@ import org.opensearch.common.blobstore.support.AbstractBlobContainer; import org.opensearch.common.blobstore.support.PlainBlobMetadata; import org.opensearch.common.collect.Tuple; +import org.opensearch.common.io.InputStreamContainer; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.Strings; import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.repositories.s3.async.UploadRequest; +import org.opensearch.repositories.s3.utils.HttpRangeUtils; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -212,9 +222,45 @@ public void asyncBlobUpload(WriteContext writeContext, ActionListener comp } } + @ExperimentalApi @Override public void readBlobAsync(String blobName, ActionListener listener) { - throw new UnsupportedOperationException(); + try (AmazonAsyncS3Reference amazonS3Reference = SocketAccess.doPrivileged(blobStore::asyncClientReference)) { + final S3AsyncClient s3AsyncClient = amazonS3Reference.get().client(); + final String bucketName = blobStore.bucket(); + + final GetObjectAttributesResponse blobMetadata = getBlobMetadata(s3AsyncClient, bucketName, blobName).get(); + + final long blobSize = blobMetadata.objectSize(); + final int numberOfParts = blobMetadata.objectParts().totalPartsCount(); + final String blobChecksum = blobMetadata.checksum().checksumCRC32(); + + final List blobPartStreams = new ArrayList<>(); + final List> blobPartInputStreamFutures = new ArrayList<>(); + // S3 multipart files use 1 to n indexing + for (int partNumber = 1; partNumber <= numberOfParts; partNumber++) { + blobPartInputStreamFutures.add(getBlobPartInputStreamContainer(s3AsyncClient, bucketName, blobName, partNumber)); + } + + CompletableFuture.allOf(blobPartInputStreamFutures.toArray(CompletableFuture[]::new)).whenComplete((unused, throwable) -> { + if (throwable == null) { + listener.onResponse( + new ReadContext( + blobSize, + blobPartInputStreamFutures.stream().map(CompletableFuture::join).collect(Collectors.toList()), + blobChecksum + ) + ); + } else { + Exception ex = throwable.getCause() instanceof Exception + ? (Exception) throwable.getCause() + : new Exception(throwable.getCause()); + listener.onFailure(ex); + } + }); + } catch (Exception ex) { + listener.onFailure(SdkException.create("Error occurred while fetching blob parts from the repository", ex)); + } } public boolean remoteIntegrityCheckSupported() { @@ -633,4 +679,65 @@ static Tuple numberOfMultiparts(final long totalSize, final long par return Tuple.tuple(parts + 1, remaining); } } + + /** + * Fetches a part of the blob from the S3 bucket and transforms it to an {@link InputStreamContainer}, which holds + * the stream and its related metadata. + * @param s3AsyncClient Async client to be utilized to fetch the object part + * @param bucketName Name of the S3 bucket + * @param blobName Identifier of the blob for which the parts will be fetched + * @param partNumber Part number for the blob to be retrieved + * @return A future of {@link InputStreamContainer} containing the stream and stream metadata. + */ + CompletableFuture getBlobPartInputStreamContainer( + S3AsyncClient s3AsyncClient, + String bucketName, + String blobName, + int partNumber + ) { + final GetObjectRequest.Builder getObjectRequestBuilder = GetObjectRequest.builder() + .bucket(bucketName) + .key(blobName) + .partNumber(partNumber); + + return SocketAccess.doPrivileged( + () -> s3AsyncClient.getObject(getObjectRequestBuilder.build(), AsyncResponseTransformer.toBlockingInputStream()) + .thenApply(S3BlobContainer::transformResponseToInputStreamContainer) + ); + } + + /** + * Transforms the stream response object from S3 into an {@link InputStreamContainer} + * @param streamResponse Response stream object from S3 + * @return {@link InputStreamContainer} containing the stream and stream metadata + */ + // Package-Private for testing. + static InputStreamContainer transformResponseToInputStreamContainer(ResponseInputStream streamResponse) { + final GetObjectResponse getObjectResponse = streamResponse.response(); + final String contentRange = getObjectResponse.contentRange(); + final Long contentLength = getObjectResponse.contentLength(); + if (contentRange == null || contentLength == null) { + throw SdkException.builder().message("Failed to fetch required metadata for blob part").build(); + } + final Long offset = HttpRangeUtils.getStartOffsetFromRangeHeader(getObjectResponse.contentRange()); + return new InputStreamContainer(streamResponse, getObjectResponse.contentLength(), offset); + } + + /** + * Retrieves the metadata like checksum, object size and parts for the provided blob within the S3 bucket. + * @param s3AsyncClient Async client to be utilized to fetch the metadata + * @param bucketName Name of the S3 bucket + * @param blobName Identifier of the blob for which the metadata will be fetched + * @return A future containing the metadata within {@link GetObjectAttributesResponse} + */ + CompletableFuture getBlobMetadata(S3AsyncClient s3AsyncClient, String bucketName, String blobName) { + // Fetch blob metadata - part info, size, checksum + final GetObjectAttributesRequest getObjectAttributesRequest = GetObjectAttributesRequest.builder() + .bucket(bucketName) + .key(blobName) + .objectAttributes(ObjectAttributes.CHECKSUM, ObjectAttributes.OBJECT_SIZE, ObjectAttributes.OBJECT_PARTS) + .build(); + + return SocketAccess.doPrivileged(() -> s3AsyncClient.getObjectAttributes(getObjectAttributesRequest)); + } } diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/utils/HttpRangeUtils.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/utils/HttpRangeUtils.java index 40aec7d52847b..2e2fc9b86a45b 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/utils/HttpRangeUtils.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/utils/HttpRangeUtils.java @@ -8,7 +8,29 @@ package org.opensearch.repositories.s3.utils; +import software.amazon.awssdk.core.exception.SdkException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public final class HttpRangeUtils { + private static final Pattern RANGE_PATTERN = Pattern.compile("^bytes\\s+(\\d+)-\\d+[/\\d*]+$"); + + /** + * Parses the content range header string value to calculate the start (offset) of the HTTP response. + * Tests against the RFC9110 specification of content range string. + * Sample values: "bytes 0-10/200", "bytes 0-10/*" + * Details here + * @param headerValue Header content range string value from the HTTP response + * @return Start (Offset) value of the HTTP response + */ + public static Long getStartOffsetFromRangeHeader(String headerValue) { + Matcher matcher = RANGE_PATTERN.matcher(headerValue); + if (!matcher.find()) { + throw SdkException.create("Regex match for Content-Range header {" + headerValue + "} failed", new RuntimeException()); + } + return Long.parseLong(matcher.group(1)); + } /** * Provides a byte range string per RFC 9110 diff --git a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java index 1c4936cae7eba..a87c060dcc60a 100644 --- a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java +++ b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java @@ -32,11 +32,15 @@ package org.opensearch.repositories.s3; +import software.amazon.awssdk.core.ResponseInputStream; +import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.exception.SdkException; import software.amazon.awssdk.core.sync.RequestBody; +import software.amazon.awssdk.services.s3.S3AsyncClient; import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest; import software.amazon.awssdk.services.s3.model.AbortMultipartUploadResponse; +import software.amazon.awssdk.services.s3.model.Checksum; import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest; import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadResponse; import software.amazon.awssdk.services.s3.model.CompletedPart; @@ -44,6 +48,11 @@ import software.amazon.awssdk.services.s3.model.CreateMultipartUploadResponse; import software.amazon.awssdk.services.s3.model.DeleteObjectsRequest; import software.amazon.awssdk.services.s3.model.DeleteObjectsResponse; +import software.amazon.awssdk.services.s3.model.GetObjectAttributesParts; +import software.amazon.awssdk.services.s3.model.GetObjectAttributesRequest; +import software.amazon.awssdk.services.s3.model.GetObjectAttributesResponse; +import software.amazon.awssdk.services.s3.model.GetObjectRequest; +import software.amazon.awssdk.services.s3.model.GetObjectResponse; import software.amazon.awssdk.services.s3.model.HeadObjectRequest; import software.amazon.awssdk.services.s3.model.HeadObjectResponse; import software.amazon.awssdk.services.s3.model.ListObjectsV2Request; @@ -61,15 +70,18 @@ import software.amazon.awssdk.services.s3.model.UploadPartResponse; import software.amazon.awssdk.services.s3.paginators.ListObjectsV2Iterable; -import org.opensearch.action.support.PlainActionFuture; +import org.opensearch.action.LatchedActionListener; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.common.blobstore.BlobPath; import org.opensearch.common.blobstore.BlobStoreException; import org.opensearch.common.blobstore.DeleteResult; +import org.opensearch.common.blobstore.stream.read.ReadContext; import org.opensearch.common.collect.Tuple; +import org.opensearch.common.io.InputStreamContainer; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.unit.ByteSizeUnit; +import org.opensearch.repositories.s3.async.AsyncTransferManager; import org.opensearch.test.OpenSearchTestCase; import java.io.ByteArrayInputStream; @@ -86,14 +98,19 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.IntStream; import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -882,17 +899,6 @@ public void onFailure(Exception e) {} } } - public void testAsyncBlobDownload() { - final S3BlobStore blobStore = mock(S3BlobStore.class); - final BlobPath blobPath = mock(BlobPath.class); - final String blobName = "test-blob"; - - final UnsupportedOperationException e = expectThrows(UnsupportedOperationException.class, () -> { - final S3BlobContainer blobContainer = new S3BlobContainer(blobPath, blobStore); - blobContainer.readBlobAsync(blobName, new PlainActionFuture<>()); - }); - } - public void testListBlobsByPrefixInLexicographicOrderWithNegativeLimit() throws IOException { testListBlobsByPrefixInLexicographicOrder(-5, 0, BlobContainer.BlobNameSortOrder.LEXICOGRAPHIC); } @@ -912,4 +918,284 @@ public void testListBlobsByPrefixInLexicographicOrderWithLimitGreaterThanPageSiz public void testListBlobsByPrefixInLexicographicOrderWithLimitGreaterThanNumberOfRecords() throws IOException { testListBlobsByPrefixInLexicographicOrder(12, 2, BlobContainer.BlobNameSortOrder.LEXICOGRAPHIC); } + + public void testReadBlobAsync() throws Exception { + final String bucketName = randomAlphaOfLengthBetween(1, 10); + final String blobName = randomAlphaOfLengthBetween(1, 10); + final String checksum = randomAlphaOfLength(10); + + final long objectSize = 100L; + final int objectPartCount = 10; + final int partSize = 10; + + final S3AsyncClient s3AsyncClient = mock(S3AsyncClient.class); + final AmazonAsyncS3Reference amazonAsyncS3Reference = new AmazonAsyncS3Reference( + AmazonAsyncS3WithCredentials.create(s3AsyncClient, s3AsyncClient, null) + ); + final AsyncTransferManager asyncTransferManager = new AsyncTransferManager( + 10000L, + mock(ExecutorService.class), + mock(ExecutorService.class) + ); + final S3BlobStore blobStore = mock(S3BlobStore.class); + final BlobPath blobPath = new BlobPath(); + + when(blobStore.bucket()).thenReturn(bucketName); + when(blobStore.getStatsMetricPublisher()).thenReturn(new StatsMetricPublisher()); + when(blobStore.serverSideEncryption()).thenReturn(false); + when(blobStore.asyncClientReference()).thenReturn(amazonAsyncS3Reference); + when(blobStore.getAsyncTransferManager()).thenReturn(asyncTransferManager); + + CompletableFuture getObjectAttributesResponseCompletableFuture = new CompletableFuture<>(); + getObjectAttributesResponseCompletableFuture.complete( + GetObjectAttributesResponse.builder() + .checksum(Checksum.builder().checksumCRC32(checksum).build()) + .objectSize(objectSize) + .objectParts(GetObjectAttributesParts.builder().totalPartsCount(objectPartCount).build()) + .build() + ); + when(s3AsyncClient.getObjectAttributes(any(GetObjectAttributesRequest.class))).thenReturn( + getObjectAttributesResponseCompletableFuture + ); + + mockObjectPartResponse(s3AsyncClient, bucketName, blobName, objectPartCount, partSize, objectSize); + + CountDownLatch countDownLatch = new CountDownLatch(1); + CountingCompletionListener readContextActionListener = new CountingCompletionListener<>(); + LatchedActionListener listener = new LatchedActionListener<>(readContextActionListener, countDownLatch); + + final S3BlobContainer blobContainer = new S3BlobContainer(blobPath, blobStore); + blobContainer.readBlobAsync(blobName, listener); + countDownLatch.await(); + + assertEquals(1, readContextActionListener.getResponseCount()); + assertEquals(0, readContextActionListener.getFailureCount()); + ReadContext readContext = readContextActionListener.getResponse(); + assertEquals(objectPartCount, readContext.getNumberOfParts()); + assertEquals(checksum, readContext.getBlobChecksum()); + assertEquals(objectSize, readContext.getBlobSize()); + + for (int partNumber = 1; partNumber < objectPartCount; partNumber++) { + InputStreamContainer inputStreamContainer = readContext.getPartStreams().get(partNumber); + final int offset = partNumber * partSize; + assertEquals(partSize, inputStreamContainer.getContentLength()); + assertEquals(offset, inputStreamContainer.getOffset()); + assertEquals(partSize, inputStreamContainer.getInputStream().readAllBytes().length); + } + } + + public void testReadBlobAsyncFailure() throws Exception { + final String bucketName = randomAlphaOfLengthBetween(1, 10); + final String blobName = randomAlphaOfLengthBetween(1, 10); + final String checksum = randomAlphaOfLength(10); + + final long objectSize = 100L; + final int objectPartCount = 10; + + final S3AsyncClient s3AsyncClient = mock(S3AsyncClient.class); + final AmazonAsyncS3Reference amazonAsyncS3Reference = new AmazonAsyncS3Reference( + AmazonAsyncS3WithCredentials.create(s3AsyncClient, s3AsyncClient, null) + ); + final AsyncTransferManager asyncTransferManager = new AsyncTransferManager( + 10000L, + mock(ExecutorService.class), + mock(ExecutorService.class) + ); + final S3BlobStore blobStore = mock(S3BlobStore.class); + final BlobPath blobPath = new BlobPath(); + + when(blobStore.bucket()).thenReturn(bucketName); + when(blobStore.getStatsMetricPublisher()).thenReturn(new StatsMetricPublisher()); + when(blobStore.serverSideEncryption()).thenReturn(false); + when(blobStore.asyncClientReference()).thenReturn(amazonAsyncS3Reference); + when(blobStore.getAsyncTransferManager()).thenReturn(asyncTransferManager); + + CompletableFuture getObjectAttributesResponseCompletableFuture = new CompletableFuture<>(); + getObjectAttributesResponseCompletableFuture.complete( + GetObjectAttributesResponse.builder() + .checksum(Checksum.builder().checksumCRC32(checksum).build()) + .objectSize(objectSize) + .objectParts(GetObjectAttributesParts.builder().totalPartsCount(objectPartCount).build()) + .build() + ); + when(s3AsyncClient.getObjectAttributes(any(GetObjectAttributesRequest.class))).thenThrow(new RuntimeException()); + + CountDownLatch countDownLatch = new CountDownLatch(1); + CountingCompletionListener readContextActionListener = new CountingCompletionListener<>(); + LatchedActionListener listener = new LatchedActionListener<>(readContextActionListener, countDownLatch); + + final S3BlobContainer blobContainer = new S3BlobContainer(blobPath, blobStore); + blobContainer.readBlobAsync(blobName, listener); + countDownLatch.await(); + + assertEquals(0, readContextActionListener.getResponseCount()); + assertEquals(1, readContextActionListener.getFailureCount()); + } + + public void testGetBlobMetadata() throws Exception { + final String checksum = randomAlphaOfLengthBetween(1, 10); + final long objectSize = 100L; + final int objectPartCount = 10; + final String blobName = randomAlphaOfLengthBetween(1, 10); + final String bucketName = randomAlphaOfLengthBetween(1, 10); + + final S3AsyncClient s3AsyncClient = mock(S3AsyncClient.class); + final S3BlobStore blobStore = mock(S3BlobStore.class); + final BlobPath blobPath = new BlobPath(); + when(blobStore.bucket()).thenReturn(bucketName); + when(blobStore.getStatsMetricPublisher()).thenReturn(new StatsMetricPublisher()); + when(blobStore.serverSideEncryption()).thenReturn(false); + final S3BlobContainer blobContainer = new S3BlobContainer(blobPath, blobStore); + + CompletableFuture getObjectAttributesResponseCompletableFuture = new CompletableFuture<>(); + getObjectAttributesResponseCompletableFuture.complete( + GetObjectAttributesResponse.builder() + .checksum(Checksum.builder().checksumCRC32(checksum).build()) + .objectSize(objectSize) + .objectParts(GetObjectAttributesParts.builder().totalPartsCount(objectPartCount).build()) + .build() + ); + when(s3AsyncClient.getObjectAttributes(any(GetObjectAttributesRequest.class))).thenReturn( + getObjectAttributesResponseCompletableFuture + ); + + CompletableFuture responseFuture = blobContainer.getBlobMetadata(s3AsyncClient, bucketName, blobName); + GetObjectAttributesResponse objectAttributesResponse = responseFuture.get(); + + assertEquals(checksum, objectAttributesResponse.checksum().checksumCRC32()); + assertEquals(Long.valueOf(objectSize), objectAttributesResponse.objectSize()); + assertEquals(Integer.valueOf(objectPartCount), objectAttributesResponse.objectParts().totalPartsCount()); + } + + public void testGetBlobPartInputStream() throws Exception { + final String blobName = randomAlphaOfLengthBetween(1, 10); + final String bucketName = randomAlphaOfLengthBetween(1, 10); + final long contentLength = 10L; + final String contentRange = "bytes 0-10/100"; + final InputStream inputStream = ResponseInputStream.nullInputStream(); + + final S3AsyncClient s3AsyncClient = mock(S3AsyncClient.class); + final S3BlobStore blobStore = mock(S3BlobStore.class); + final BlobPath blobPath = new BlobPath(); + when(blobStore.bucket()).thenReturn(bucketName); + when(blobStore.getStatsMetricPublisher()).thenReturn(new StatsMetricPublisher()); + when(blobStore.serverSideEncryption()).thenReturn(false); + final S3BlobContainer blobContainer = new S3BlobContainer(blobPath, blobStore); + + GetObjectResponse getObjectResponse = GetObjectResponse.builder().contentLength(contentLength).contentRange(contentRange).build(); + + CompletableFuture> getObjectPartResponse = new CompletableFuture<>(); + ResponseInputStream responseInputStream = new ResponseInputStream<>(getObjectResponse, inputStream); + getObjectPartResponse.complete(responseInputStream); + + when( + s3AsyncClient.getObject( + any(GetObjectRequest.class), + ArgumentMatchers.>>any() + ) + ).thenReturn(getObjectPartResponse); + + InputStreamContainer inputStreamContainer = blobContainer.getBlobPartInputStreamContainer(s3AsyncClient, bucketName, blobName, 0) + .get(); + + assertEquals(0, inputStreamContainer.getOffset()); + assertEquals(contentLength, inputStreamContainer.getContentLength()); + assertEquals(inputStream.available(), inputStreamContainer.getInputStream().available()); + } + + public void testTransformResponseToInputStreamContainer() throws Exception { + final String contentRange = "bytes 0-10/100"; + final long contentLength = 10L; + final InputStream inputStream = ResponseInputStream.nullInputStream(); + + final S3AsyncClient s3AsyncClient = mock(S3AsyncClient.class); + + GetObjectResponse getObjectResponse = GetObjectResponse.builder().contentLength(contentLength).build(); + + ResponseInputStream responseInputStreamNoRange = new ResponseInputStream<>(getObjectResponse, inputStream); + assertThrows(SdkException.class, () -> S3BlobContainer.transformResponseToInputStreamContainer(responseInputStreamNoRange)); + + getObjectResponse = GetObjectResponse.builder().contentRange(contentRange).build(); + ResponseInputStream responseInputStreamNoContentLength = new ResponseInputStream<>( + getObjectResponse, + inputStream + ); + assertThrows(SdkException.class, () -> S3BlobContainer.transformResponseToInputStreamContainer(responseInputStreamNoContentLength)); + + getObjectResponse = GetObjectResponse.builder().contentRange(contentRange).contentLength(contentLength).build(); + ResponseInputStream responseInputStream = new ResponseInputStream<>(getObjectResponse, inputStream); + InputStreamContainer inputStreamContainer = S3BlobContainer.transformResponseToInputStreamContainer(responseInputStream); + assertEquals(contentLength, inputStreamContainer.getContentLength()); + assertEquals(0, inputStreamContainer.getOffset()); + assertEquals(inputStream.available(), inputStreamContainer.getInputStream().available()); + } + + private void mockObjectPartResponse( + S3AsyncClient s3AsyncClient, + String bucketName, + String blobName, + int totalNumberOfParts, + int partSize, + long objectSize + ) { + for (int partNumber = 1; partNumber <= totalNumberOfParts; partNumber++) { + final int start = (partNumber - 1) * partSize; + final int end = partNumber * partSize; + final String contentRange = "bytes " + start + "-" + end + "/" + objectSize; + final InputStream inputStream = new ByteArrayInputStream(randomByteArrayOfLength(partSize)); + + GetObjectResponse getObjectResponse = GetObjectResponse.builder() + .contentLength((long) partSize) + .contentRange(contentRange) + .build(); + + CompletableFuture> getObjectPartResponse = new CompletableFuture<>(); + ResponseInputStream responseInputStream = new ResponseInputStream<>(getObjectResponse, inputStream); + getObjectPartResponse.complete(responseInputStream); + + GetObjectRequest getObjectRequest = GetObjectRequest.builder().bucket(bucketName).key(blobName).partNumber(partNumber).build(); + + when( + s3AsyncClient.getObject( + eq(getObjectRequest), + ArgumentMatchers.>>any() + ) + ).thenReturn(getObjectPartResponse); + } + } + + private static class CountingCompletionListener implements ActionListener { + private int responseCount; + private int failureCount; + private T response; + private Exception exception; + + @Override + public void onResponse(T response) { + this.response = response; + responseCount++; + } + + @Override + public void onFailure(Exception e) { + exception = e; + failureCount++; + } + + public int getResponseCount() { + return responseCount; + } + + public int getFailureCount() { + return failureCount; + } + + public T getResponse() { + return response; + } + + public Exception getException() { + return exception; + } + } } diff --git a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/utils/HttpRangeUtilsTests.java b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/utils/HttpRangeUtilsTests.java new file mode 100644 index 0000000000000..9a4267c5266e5 --- /dev/null +++ b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/utils/HttpRangeUtilsTests.java @@ -0,0 +1,29 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.repositories.s3.utils; + +import software.amazon.awssdk.core.exception.SdkException; + +import org.opensearch.test.OpenSearchTestCase; + +public final class HttpRangeUtilsTests extends OpenSearchTestCase { + + public void testFromHttpRangeHeader() { + String headerValue = "bytes 0-10/200"; + Long offset = HttpRangeUtils.getStartOffsetFromRangeHeader(headerValue); + assertEquals(0L, offset.longValue()); + + headerValue = "bytes 0-10/*"; + offset = HttpRangeUtils.getStartOffsetFromRangeHeader(headerValue); + assertEquals(0L, offset.longValue()); + + final String invalidHeaderValue = "bytes */*"; + assertThrows(SdkException.class, () -> HttpRangeUtils.getStartOffsetFromRangeHeader(invalidHeaderValue)); + } +} From 5fdd418be5717cc91023b071075fb1ab525ba8e4 Mon Sep 17 00:00:00 2001 From: Varun Bansal Date: Sat, 16 Sep 2023 12:59:56 +0530 Subject: [PATCH 4/9] skip overriding routing table when it already contains entries with remote recovery source (#9962) * skip overriding routing table when it already contains entries with remote recovery source Signed-off-by: bansvaru --- .../gateway/ClusterStateUpdaters.java | 17 +- .../recovery/RemoteStoreRestoreService.java | 2 +- .../gateway/ClusterStateUpdatersTests.java | 320 ++++++++++++++++++ 3 files changed, 337 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/gateway/ClusterStateUpdaters.java b/server/src/main/java/org/opensearch/gateway/ClusterStateUpdaters.java index 1563ac84bdd1c..4c562b348f141 100644 --- a/server/src/main/java/org/opensearch/gateway/ClusterStateUpdaters.java +++ b/server/src/main/java/org/opensearch/gateway/ClusterStateUpdaters.java @@ -41,6 +41,7 @@ import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; +import org.opensearch.cluster.routing.RecoverySource; import org.opensearch.cluster.routing.RoutingTable; import org.opensearch.common.settings.ClusterSettings; @@ -120,7 +121,21 @@ static ClusterState updateRoutingTable(final ClusterState state) { // initialize all index routing tables as empty final RoutingTable.Builder routingTableBuilder = RoutingTable.builder(state.routingTable()); for (final IndexMetadata cursor : state.metadata().indices().values()) { - routingTableBuilder.addAsRecovery(cursor); + // Whether IndexMetadata is recovered from local disk or remote it doesn't matter to us at this point. + // We are only concerned about index data recovery here. Which is why we only check for remote store enabled and not for remote + // cluster state enabled. + if (cursor.getSettings().getAsBoolean(IndexMetadata.SETTING_REMOTE_STORE_ENABLED, false) == false + || state.routingTable().hasIndex(cursor.getIndex()) == false + || state.routingTable() + .index(cursor.getIndex()) + .shardsMatchingPredicateCount( + shardRouting -> shardRouting.primary() + // We need to ensure atleast one of the primaries is being recovered from remote. + // This ensures we have gone through the RemoteStoreRestoreService and routing table is updated + && shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) == 0) { + routingTableBuilder.addAsRecovery(cursor); + } } // start with 0 based versions for routing table routingTableBuilder.version(0); diff --git a/server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java b/server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java index d05242a3aeaf7..94fd08b99ac58 100644 --- a/server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java +++ b/server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java @@ -187,7 +187,7 @@ private RemoteRestoreResult executeRestore( IndexMetadata indexMetadata = indexMetadataEntry.getValue().v2(); boolean metadataFromRemoteStore = indexMetadataEntry.getValue().v1(); IndexMetadata updatedIndexMetadata = indexMetadata; - if (restoreAllShards || metadataFromRemoteStore) { + if (metadataFromRemoteStore == false && restoreAllShards) { updatedIndexMetadata = IndexMetadata.builder(indexMetadata) .state(IndexMetadata.State.OPEN) .version(1 + indexMetadata.getVersion()) diff --git a/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java b/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java index c83da46b23fb1..9b3fd45245ef7 100644 --- a/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java +++ b/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java @@ -40,6 +40,10 @@ import org.opensearch.cluster.metadata.MetadataIndexStateService; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodeRole; +import org.opensearch.cluster.routing.IndexRoutingTable; +import org.opensearch.cluster.routing.RecoverySource; +import org.opensearch.cluster.routing.RoutingTable; +import org.opensearch.cluster.routing.UnassignedInfo; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.UUIDs; import org.opensearch.common.settings.ClusterSettings; @@ -48,10 +52,12 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.set.Sets; import org.opensearch.core.index.Index; +import org.opensearch.repositories.IndexId; import org.opensearch.test.OpenSearchTestCase; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Function; @@ -269,6 +275,320 @@ public void testUpdateRoutingTable() { } } + public void testSkipRoutingTableUpdateWhenRemoteRecovery() { + final int numOfShards = randomIntBetween(1, 10); + + final IndexMetadata remoteMetadata = createIndexMetadata( + "test-remote", + Settings.builder() + .put(IndexMetadata.SETTING_REMOTE_STORE_ENABLED, true) + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numOfShards) + .build() + ); + + // Test remote index routing table is generated with ExistingStoreRecoverySource if no routing table is present + { + final Index index = remoteMetadata.getIndex(); + final ClusterState initialState = ClusterState.builder(ClusterState.EMPTY_STATE) + .metadata(Metadata.builder().put(remoteMetadata, false).build()) + .build(); + final ClusterState newState = updateRoutingTable(initialState); + IndexRoutingTable newRemoteIndexRoutingTable = newState.routingTable().index(remoteMetadata.getIndex()); + assertTrue(newState.routingTable().hasIndex(index)); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.INDEX_CREATED) + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.CLUSTER_RECOVERED) + ) + ); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.EmptyStoreRecoverySource + ) + ); + + } + + // Test remote index routing table is overridden if recovery source is not RemoteStoreRecoverySource + { + IndexRoutingTable.Builder remoteBuilderWithoutRemoteRecovery = new IndexRoutingTable.Builder(remoteMetadata.getIndex()) + .initializeAsNew(remoteMetadata); + final Index index = remoteMetadata.getIndex(); + final ClusterState initialState = ClusterState.builder(ClusterState.EMPTY_STATE) + .metadata(Metadata.builder().put(remoteMetadata, false).build()) + .routingTable(new RoutingTable.Builder().add(remoteBuilderWithoutRemoteRecovery.build()).build()) + .build(); + assertTrue(initialState.routingTable().hasIndex(index)); + final ClusterState newState = updateRoutingTable(initialState); + IndexRoutingTable newRemoteIndexRoutingTable = newState.routingTable().index(remoteMetadata.getIndex()); + assertTrue(newState.routingTable().hasIndex(index)); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.INDEX_CREATED) + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.CLUSTER_RECOVERED) + ) + ); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.EmptyStoreRecoverySource + ) + ); + + } + + // Test routing table update is skipped for a remote index + { + IndexRoutingTable.Builder remoteBuilderWithRemoteRecovery = new IndexRoutingTable.Builder(remoteMetadata.getIndex()) + .initializeAsRemoteStoreRestore( + remoteMetadata, + new RecoverySource.RemoteStoreRecoverySource( + UUIDs.randomBase64UUID(), + remoteMetadata.getCreationVersion(), + new IndexId(remoteMetadata.getIndex().getName(), remoteMetadata.getIndexUUID()) + ), + new HashMap<>(), + true + ); + final Index index = remoteMetadata.getIndex(); + final ClusterState initialState = ClusterState.builder(ClusterState.EMPTY_STATE) + .metadata(Metadata.builder().put(remoteMetadata, false).build()) + .routingTable(new RoutingTable.Builder().add(remoteBuilderWithRemoteRecovery.build()).build()) + .build(); + assertTrue(initialState.routingTable().hasIndex(index)); + final ClusterState newState = updateRoutingTable(initialState); + IndexRoutingTable newRemoteIndexRoutingTable = newState.routingTable().index(remoteMetadata.getIndex()); + assertTrue(newState.routingTable().hasIndex(index)); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.CLUSTER_RECOVERED) + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.EXISTING_INDEX_RESTORED) + ) + ); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.EmptyStoreRecoverySource + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) + ); + + } + + // Test reset routing table for 2 indices - one remote and one non remote. + // Routing table for non remote index should be updated and remote index routing table should remain intact + { + final IndexMetadata nonRemoteMetadata = createIndexMetadata( + "test-nonremote", + Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numOfShards).build() + ); + IndexRoutingTable.Builder remoteBuilderWithRemoteRecovery = new IndexRoutingTable.Builder(remoteMetadata.getIndex()) + .initializeAsRemoteStoreRestore( + remoteMetadata, + new RecoverySource.RemoteStoreRecoverySource( + UUIDs.randomBase64UUID(), + remoteMetadata.getCreationVersion(), + new IndexId(remoteMetadata.getIndex().getName(), remoteMetadata.getIndexUUID()) + ), + new HashMap<>(), + true + ); + IndexRoutingTable.Builder nonRemoteBuilderWithoutRemoteRecovery = new IndexRoutingTable.Builder(nonRemoteMetadata.getIndex()) + .initializeAsNew(nonRemoteMetadata); + final ClusterState initialState = ClusterState.builder(ClusterState.EMPTY_STATE) + .metadata(Metadata.builder().put(remoteMetadata, false).build()) + .metadata(Metadata.builder().put(nonRemoteMetadata, false).build()) + .routingTable( + new RoutingTable.Builder().add(remoteBuilderWithRemoteRecovery.build()) + .add(nonRemoteBuilderWithoutRemoteRecovery.build()) + .build() + ) + .build(); + assertTrue(initialState.routingTable().hasIndex(remoteMetadata.getIndex())); + assertTrue(initialState.routingTable().hasIndex(nonRemoteMetadata.getIndex())); + final ClusterState newState = updateRoutingTable(initialState); + assertTrue(newState.routingTable().hasIndex(remoteMetadata.getIndex())); + assertTrue(newState.routingTable().hasIndex(nonRemoteMetadata.getIndex())); + IndexRoutingTable newRemoteIndexRoutingTable = newState.routingTable().index(remoteMetadata.getIndex()); + IndexRoutingTable newNonRemoteIndexRoutingTable = newState.routingTable().index(nonRemoteMetadata.getIndex()); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.CLUSTER_RECOVERED) + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.EXISTING_INDEX_RESTORED) + ) + ); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.EmptyStoreRecoverySource + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) + ); + assertEquals( + 0, + newNonRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.INDEX_CREATED) + ) + ); + assertEquals( + numOfShards, + newNonRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.CLUSTER_RECOVERED) + ) + ); + assertEquals( + 0, + newNonRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) + ); + assertEquals( + numOfShards, + newNonRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.EmptyStoreRecoverySource + ) + ); + } + + // Test reset routing table for 2 indices, both remote backed but only once index has RemoteStoreRecoverySource. + // Routing table for only remote index without RemoteStoreRecoverySource should be updated + { + final IndexMetadata remoteWithoutRemoteRecoveryMetadata = createIndexMetadata( + "test-remote-without-recovery", + Settings.builder() + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numOfShards) + .put(IndexMetadata.SETTING_REMOTE_STORE_ENABLED, true) + .build() + ); + IndexRoutingTable.Builder remoteBuilderWithRemoteRecovery = new IndexRoutingTable.Builder(remoteMetadata.getIndex()) + .initializeAsRemoteStoreRestore( + remoteMetadata, + new RecoverySource.RemoteStoreRecoverySource( + UUIDs.randomBase64UUID(), + remoteMetadata.getCreationVersion(), + new IndexId(remoteMetadata.getIndex().getName(), remoteMetadata.getIndexUUID()) + ), + new HashMap<>(), + true + ); + IndexRoutingTable.Builder remoteBuilderWithoutRemoteRecovery = new IndexRoutingTable.Builder( + remoteWithoutRemoteRecoveryMetadata.getIndex() + ).initializeAsNew(remoteWithoutRemoteRecoveryMetadata); + final ClusterState initialState = ClusterState.builder(ClusterState.EMPTY_STATE) + .metadata(Metadata.builder().put(remoteMetadata, false).build()) + .metadata(Metadata.builder().put(remoteWithoutRemoteRecoveryMetadata, false).build()) + .routingTable( + new RoutingTable.Builder().add(remoteBuilderWithRemoteRecovery.build()) + .add(remoteBuilderWithoutRemoteRecovery.build()) + .build() + ) + .build(); + assertTrue(initialState.routingTable().hasIndex(remoteMetadata.getIndex())); + assertTrue(initialState.routingTable().hasIndex(remoteWithoutRemoteRecoveryMetadata.getIndex())); + final ClusterState newState = updateRoutingTable(initialState); + assertTrue(newState.routingTable().hasIndex(remoteMetadata.getIndex())); + assertTrue(newState.routingTable().hasIndex(remoteWithoutRemoteRecoveryMetadata.getIndex())); + IndexRoutingTable newRemoteIndexRoutingTable = newState.routingTable().index(remoteMetadata.getIndex()); + IndexRoutingTable newRemoteWithoutRemoteRecoveryIndexRoutingTable = newState.routingTable() + .index(remoteWithoutRemoteRecoveryMetadata.getIndex()); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.CLUSTER_RECOVERED) + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.EXISTING_INDEX_RESTORED) + ) + ); + assertEquals( + 0, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.EmptyStoreRecoverySource + ) + ); + assertEquals( + numOfShards, + newRemoteIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) + ); + assertEquals( + 0, + newRemoteWithoutRemoteRecoveryIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.INDEX_CREATED) + ) + ); + assertEquals( + numOfShards, + newRemoteWithoutRemoteRecoveryIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.CLUSTER_RECOVERED) + ) + ); + assertEquals( + 0, + newRemoteWithoutRemoteRecoveryIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.RemoteStoreRecoverySource + ) + ); + assertEquals( + numOfShards, + newRemoteWithoutRemoteRecoveryIndexRoutingTable.shardsMatchingPredicateCount( + shardRouting -> shardRouting.recoverySource() instanceof RecoverySource.EmptyStoreRecoverySource + ) + ); + } + } + public void testMixCurrentAndRecoveredState() { final ClusterState currentState = ClusterState.builder(ClusterState.EMPTY_STATE) .blocks(ClusterBlocks.builder().addGlobalBlock(STATE_NOT_RECOVERED_BLOCK).build()) From d7aa6dd9c7759bbfedd7263d453d3ac6c92fab7d Mon Sep 17 00:00:00 2001 From: Chaitanya Gohel <104654647+gashutos@users.noreply.github.com> Date: Sat, 16 Sep 2023 20:49:23 +0530 Subject: [PATCH 5/9] Finxing broken UT (#10087) Signed-off-by: Gohel Co-authored-by: Gohel --- server/src/main/java/org/opensearch/index/IndexService.java | 2 ++ .../src/main/java/org/opensearch/index/IndexSortConfig.java | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/IndexService.java b/server/src/main/java/org/opensearch/index/IndexService.java index 80ead0a333ba3..38456ad3e43a5 100644 --- a/server/src/main/java/org/opensearch/index/IndexService.java +++ b/server/src/main/java/org/opensearch/index/IndexService.java @@ -240,8 +240,10 @@ public IndexService( if (indexSettings.getIndexSortConfig().hasIndexSort()) { // we delay the actual creation of the sort order for this index because the mapping has not been merged yet. // The sort order is validated right after the merge of the mapping later in the process. + boolean shouldWidenIndexSortType = this.indexSettings.shouldWidenIndexSortType(); this.indexSortSupplier = () -> indexSettings.getIndexSortConfig() .buildIndexSort( + shouldWidenIndexSortType, mapperService::fieldType, (fieldType, searchLookup) -> indexFieldData.getForField(fieldType, indexFieldData.index().getName(), searchLookup) ); diff --git a/server/src/main/java/org/opensearch/index/IndexSortConfig.java b/server/src/main/java/org/opensearch/index/IndexSortConfig.java index 83192052564f3..763ed34a1e6a6 100644 --- a/server/src/main/java/org/opensearch/index/IndexSortConfig.java +++ b/server/src/main/java/org/opensearch/index/IndexSortConfig.java @@ -143,7 +143,6 @@ private static MultiValueMode parseMultiValueMode(String value) { // visible for tests final FieldSortSpec[] sortSpecs; - final boolean shouldWidenIndexSortType; public IndexSortConfig(IndexSettings indexSettings) { final Settings settings = indexSettings.getSettings(); @@ -183,7 +182,6 @@ public IndexSortConfig(IndexSettings indexSettings) { sortSpecs[i].missingValue = missingValues.get(i); } } - this.shouldWidenIndexSortType = indexSettings.shouldWidenIndexSortType(); } /** @@ -202,6 +200,7 @@ public boolean hasPrimarySortOnField(String field) { * or returns null if this index has no sort. */ public Sort buildIndexSort( + boolean shouldWidenIndexSortType, Function fieldTypeLookup, BiFunction, IndexFieldData> fieldDataLookup ) { @@ -232,7 +231,7 @@ public Sort buildIndexSort( if (fieldData == null) { throw new IllegalArgumentException("docvalues not found for index sort field:[" + sortSpec.field + "]"); } - if (this.shouldWidenIndexSortType == true) { + if (shouldWidenIndexSortType == true) { sortFields[i] = fieldData.wideSortField(sortSpec.missingValue, mode, null, reverse); } else { sortFields[i] = fieldData.sortField(sortSpec.missingValue, mode, null, reverse); From 9fa8b951bd563a4364bc47757ceaebdafd8e03cc Mon Sep 17 00:00:00 2001 From: Gagan Juneja Date: Mon, 18 Sep 2023 17:30:32 +0530 Subject: [PATCH 6/9] Add instrumentation in transport action Signed-off-by: Gagan Juneja --- .../action/bulk/TransportNoopBulkAction.java | 5 +- .../search/TransportNoopSearchAction.java | 5 +- .../ingest/common/GrokProcessorGetAction.java | 9 +-- .../common/GrokProcessorGetActionTests.java | 4 +- .../TransportMultiSearchTemplateAction.java | 6 +- .../TransportSearchTemplateAction.java | 6 +- .../action/PainlessContextAction.java | 10 +++- .../action/PainlessExecuteAction.java | 7 ++- .../rankeval/TransportRankEvalAction.java | 6 +- .../TransportRankEvalActionTests.java | 4 +- .../reindex/TransportDeleteByQueryAction.java | 7 ++- .../index/reindex/TransportReindexAction.java | 6 +- .../reindex/TransportRethrottleAction.java | 7 ++- .../reindex/TransportUpdateByQueryAction.java | 7 ++- .../reindex/AsyncBulkByScrollActionTests.java | 10 +++- .../reindex/UpdateByQueryWithScriptTests.java | 4 +- .../TransportIndexCorrelationRuleAction.java | 6 +- .../TelemetryTracerEnabledSanityIT.java | 2 +- .../node/tasks/CancellableTasksIT.java | 5 +- ...tReplicationActionRetryOnClosedNodeIT.java | 7 ++- .../opensearch/cluster/ClusterHealthIT.java | 4 ++ .../BlobStoreRepositoryCleanupIT.java | 4 ++ .../backpressure/SearchBackpressureIT.java | 5 +- .../snapshots/ConcurrentSnapshotsIT.java | 16 +++++ .../DedicatedClusterSnapshotRestoreIT.java | 4 ++ ...ansportClusterAllocationExplainAction.java | 7 ++- ...nsportAddVotingConfigExclusionsAction.java | 7 ++- ...portClearVotingConfigExclusionsAction.java | 7 ++- ...ransportDeleteDecommissionStateAction.java | 7 ++- .../TransportGetDecommissionStateAction.java | 7 ++- .../put/TransportDecommissionAction.java | 7 ++- .../health/TransportClusterHealthAction.java | 7 ++- .../TransportNodesHotThreadsAction.java | 7 ++- .../node/info/TransportNodesInfoAction.java | 7 ++- ...nsportNodesReloadSecureSettingsAction.java | 7 ++- .../node/stats/TransportNodesStatsAction.java | 7 ++- .../cancel/TransportCancelTasksAction.java | 11 +++- .../tasks/get/TransportGetTaskAction.java | 6 +- .../tasks/list/TransportListTasksAction.java | 7 ++- .../node/usage/TransportNodesUsageAction.java | 7 ++- .../remote/TransportRemoteInfoAction.java | 6 +- .../TransportRestoreRemoteStoreAction.java | 7 ++- .../TransportRemoteStoreStatsAction.java | 7 ++- .../TransportCleanupRepositoryAction.java | 7 ++- .../TransportDeleteRepositoryAction.java | 7 ++- .../get/TransportGetRepositoriesAction.java | 7 ++- .../put/TransportPutRepositoryAction.java | 7 ++- .../TransportVerifyRepositoryAction.java | 7 ++- .../TransportClusterRerouteAction.java | 7 ++- .../TransportClusterUpdateSettingsAction.java | 7 ++- .../TransportClusterSearchShardsAction.java | 7 ++- .../TransportDeleteWeightedRoutingAction.java | 7 ++- .../TransportGetWeightedRoutingAction.java | 7 ++- .../TransportAddWeightedRoutingAction.java | 7 ++- .../clone/TransportCloneSnapshotAction.java | 7 ++- .../create/TransportCreateSnapshotAction.java | 7 ++- .../delete/TransportDeleteSnapshotAction.java | 7 ++- .../get/TransportGetSnapshotsAction.java | 7 ++- .../TransportRestoreSnapshotAction.java | 7 ++- .../status/TransportNodesSnapshotsStatus.java | 7 ++- .../TransportSnapshotsStatusAction.java | 7 ++- .../state/TransportClusterStateAction.java | 7 ++- .../stats/TransportClusterStatsAction.java | 7 ++- .../TransportDeleteStoredScriptAction.java | 7 ++- .../TransportGetScriptContextAction.java | 10 +++- .../TransportGetScriptLanguageAction.java | 10 +++- .../TransportGetStoredScriptAction.java | 7 ++- .../TransportPutStoredScriptAction.java | 7 ++- .../TransportPendingClusterTasksAction.java | 7 ++- .../alias/TransportIndicesAliasesAction.java | 7 ++- .../alias/get/TransportGetAliasesAction.java | 7 ++- .../analyze/TransportAnalyzeAction.java | 7 ++- .../TransportClearIndicesCacheAction.java | 7 ++- .../close/TransportCloseIndexAction.java | 7 ++- ...TransportVerifyShardBeforeCloseAction.java | 7 ++- .../indices/create/AutoCreateAction.java | 15 ++++- .../create/TransportCreateIndexAction.java | 7 ++- .../TransportDeleteDanglingIndexAction.java | 7 ++- .../TransportFindDanglingIndexAction.java | 7 ++- .../TransportImportDanglingIndexAction.java | 6 +- .../TransportListDanglingIndicesAction.java | 7 ++- .../datastream/CreateDataStreamAction.java | 6 +- .../datastream/DataStreamsStatsAction.java | 7 ++- .../datastream/DeleteDataStreamAction.java | 6 +- .../datastream/GetDataStreamAction.java | 6 +- .../delete/TransportDeleteIndexAction.java | 7 ++- .../indices/TransportIndicesExistsAction.java | 7 ++- .../indices/flush/TransportFlushAction.java | 7 ++- .../flush/TransportShardFlushAction.java | 7 ++- .../forcemerge/TransportForceMergeAction.java | 7 ++- .../indices/get/TransportGetIndexAction.java | 7 ++- .../get/TransportGetFieldMappingsAction.java | 6 +- .../TransportGetFieldMappingsIndexAction.java | 7 ++- .../get/TransportGetMappingsAction.java | 7 ++- .../put/TransportAutoPutMappingAction.java | 7 ++- .../put/TransportPutMappingAction.java | 7 ++- .../open/TransportOpenIndexAction.java | 7 ++- .../TransportAddIndexBlockAction.java | 7 ++- .../TransportVerifyShardIndexBlockAction.java | 7 ++- .../recovery/TransportRecoveryAction.java | 7 ++- .../refresh/TransportRefreshAction.java | 7 ++- .../refresh/TransportShardRefreshAction.java | 7 ++- ...ransportSegmentReplicationStatsAction.java | 7 ++- .../indices/resolve/ResolveIndexAction.java | 6 +- .../rollover/TransportRolloverAction.java | 7 ++- .../TransportIndicesSegmentsAction.java | 7 ++- .../segments/TransportPitSegmentsAction.java | 7 ++- .../get/TransportGetSettingsAction.java | 7 ++- .../put/TransportUpdateSettingsAction.java | 7 ++- .../TransportIndicesShardStoresAction.java | 7 ++- .../indices/shrink/TransportResizeAction.java | 21 +++++-- .../stats/TransportIndicesStatsAction.java | 7 ++- ...ransportDeleteComponentTemplateAction.java | 7 ++- ...rtDeleteComposableIndexTemplateAction.java | 7 ++- .../TransportDeleteIndexTemplateAction.java | 7 ++- .../TransportGetComponentTemplateAction.java | 7 ++- ...sportGetComposableIndexTemplateAction.java | 7 ++- .../get/TransportGetIndexTemplatesAction.java | 7 ++- .../TransportSimulateIndexTemplateAction.java | 7 ++- .../post/TransportSimulateTemplateAction.java | 7 ++- .../TransportPutComponentTemplateAction.java | 7 ++- ...sportPutComposableIndexTemplateAction.java | 7 ++- .../put/TransportPutIndexTemplateAction.java | 7 ++- .../get/TransportUpgradeStatusAction.java | 7 ++- .../upgrade/post/TransportUpgradeAction.java | 7 ++- .../post/TransportUpgradeSettingsAction.java | 7 ++- .../query/TransportValidateQueryAction.java | 7 ++- .../action/bulk/TransportBulkAction.java | 12 ++-- .../action/bulk/TransportShardBulkAction.java | 7 ++- .../TransportSingleItemBulkWriteAction.java | 6 +- .../action/delete/TransportDeleteAction.java | 10 +++- .../explain/TransportExplainAction.java | 7 ++- .../TransportFieldCapabilitiesAction.java | 6 +- ...TransportFieldCapabilitiesIndexAction.java | 6 +- .../action/get/TransportGetAction.java | 7 ++- .../action/get/TransportMultiGetAction.java | 6 +- .../get/TransportShardMultiGetAction.java | 7 ++- .../action/index/TransportIndexAction.java | 10 +++- .../ingest/DeletePipelineTransportAction.java | 7 ++- .../ingest/GetPipelineTransportAction.java | 7 ++- .../ingest/PutPipelineTransportAction.java | 7 ++- .../SimulatePipelineTransportAction.java | 7 ++- .../action/main/TransportMainAction.java | 6 +- .../TransportResyncReplicationAction.java | 7 ++- .../DeleteSearchPipelineTransportAction.java | 7 ++- .../GetSearchPipelineTransportAction.java | 7 ++- .../PutSearchPipelineTransportAction.java | 7 ++- .../search/TransportClearScrollAction.java | 6 +- .../search/TransportCreatePitAction.java | 6 +- .../search/TransportDeletePitAction.java | 6 +- .../search/TransportGetAllPitsAction.java | 7 ++- .../search/TransportMultiSearchAction.java | 23 +++++-- .../action/search/TransportSearchAction.java | 6 +- .../search/TransportSearchScrollAction.java | 12 +++- .../support/HandledTransportAction.java | 21 ++++--- .../action/support/TransportAction.java | 38 ++++++++---- .../broadcast/TransportBroadcastAction.java | 6 +- .../node/TransportBroadcastByNodeAction.java | 11 ++-- .../TransportClusterManagerNodeAction.java | 11 ++-- ...TransportClusterManagerNodeReadAction.java | 12 ++-- .../info/TransportClusterInfoAction.java | 6 +- .../master/TransportMasterNodeAction.java | 12 ++-- .../master/TransportMasterNodeReadAction.java | 12 ++-- .../info/TransportClusterInfoAction.java | 6 +- .../support/nodes/TransportNodesAction.java | 14 +++-- .../TransportBroadcastReplicationAction.java | 6 +- .../TransportReplicationAction.java | 12 ++-- .../replication/TransportWriteAction.java | 7 ++- ...ransportInstanceSingleOperationAction.java | 6 +- .../shard/TransportSingleShardAction.java | 6 +- .../support/tasks/TransportTasksAction.java | 6 +- .../TransportMultiTermVectorsAction.java | 6 +- .../TransportShardMultiTermsVectorAction.java | 7 ++- .../TransportTermVectorsAction.java | 7 ++- .../action/update/TransportUpdateAction.java | 7 ++- .../extensions/ExtensionsManager.java | 7 ++- .../extensions/NoopExtensionsManager.java | 4 +- .../action/ExtensionProxyTransportAction.java | 6 +- .../action/ExtensionTransportAction.java | 6 +- .../ExtensionTransportActionsHandler.java | 8 ++- .../TransportNodesListGatewayMetaState.java | 7 ++- ...ransportNodesListGatewayStartedShards.java | 7 ++- .../seqno/GlobalCheckpointSyncAction.java | 7 ++- .../index/seqno/RetentionLeaseActions.java | 25 +++++--- .../RetentionLeaseBackgroundSyncAction.java | 7 ++- .../index/seqno/RetentionLeaseSyncAction.java | 7 ++- .../checkpoint/PublishCheckpointAction.java | 7 ++- .../TransportNodesListShardStoreMetadata.java | 7 ++- .../main/java/org/opensearch/node/Node.java | 10 +++- .../CompletionPersistentTaskAction.java | 7 ++- .../RemovePersistentTaskAction.java | 7 ++- .../persistent/StartPersistentTaskAction.java | 7 ++- .../UpdatePersistentTaskStatusAction.java | 7 ++- .../snapshots/SnapshotsService.java | 13 ++-- .../telemetry/tracing/AttributeNames.java | 10 ++++ .../telemetry/tracing/SpanBuilder.java | 25 ++++++++ .../opensearch/action/ActionModuleTests.java | 5 +- .../action/DynamicActionRegistryTests.java | 11 +++- ...tAddVotingConfigExclusionsActionTests.java | 3 +- ...learVotingConfigExclusionsActionTests.java | 3 +- .../node/tasks/TaskManagerTestCase.java | 13 +++- .../cluster/node/tasks/TestTaskPlugin.java | 16 +++-- .../node/tasks/TransportTasksActionTests.java | 4 +- .../TransportRemoteStoreStatsActionTests.java | 3 +- ...TransportClearIndicesCacheActionTests.java | 4 +- ...portVerifyShardBeforeCloseActionTests.java | 6 +- .../flush/TransportShardFlushActionTests.java | 4 +- .../indices/get/GetIndexActionTests.java | 3 +- ...sportVerifyShardIndexBlockActionTests.java | 4 +- .../TransportShardRefreshActionTests.java | 4 +- .../TransportRolloverActionTests.java | 4 +- .../settings/get/GetSettingsActionTests.java | 3 +- ...ActionIndicesThatCannotBeCreatedTests.java | 4 +- .../bulk/TransportBulkActionIngestTests.java | 7 ++- .../action/bulk/TransportBulkActionTests.java | 3 +- .../bulk/TransportBulkActionTookTests.java | 3 +- .../bulk/TransportShardBulkActionTests.java | 13 ++-- .../get/TransportMultiGetActionTests.java | 9 ++- .../action/main/MainActionTests.java | 8 ++- ...TransportResyncReplicationActionTests.java | 6 +- .../search/MultiSearchActionTookTests.java | 6 +- .../search/TransportDeletePitActionTests.java | 24 +++++--- .../TransportMultiSearchActionTests.java | 6 +- .../TransportActionFilterChainTests.java | 7 ++- .../TransportBroadcastByNodeActionTests.java | 3 +- ...ransportClusterManagerNodeActionTests.java | 52 +++++++++++----- .../nodes/TransportNodesActionTests.java | 3 +- .../BroadcastReplicationTests.java | 10 +++- .../TransportReplicationActionTests.java | 21 +++++-- ...ReplicationAllPermitsAcquisitionTests.java | 13 ++-- ...rtWriteActionForIndexingPressureTests.java | 53 +++++++++++++--- .../TransportWriteActionTests.java | 6 +- ...ortInstanceSingleOperationActionTests.java | 3 +- .../TransportMultiTermVectorsActionTests.java | 9 ++- .../client/node/NodeClientHeadersTests.java | 3 +- ...ransportGetWeightedRoutingActionTests.java | 3 +- .../DecommissionControllerTests.java | 6 +- .../health/ClusterStateHealthTests.java | 3 +- .../extensions/ExtensionsManagerTests.java | 6 +- ...ExtensionTransportActionsHandlerTests.java | 3 +- .../rest/RestSendToExtensionActionTests.java | 8 ++- .../GlobalCheckpointSyncActionTests.java | 6 +- ...tentionLeaseBackgroundSyncActionTests.java | 12 ++-- .../seqno/RetentionLeaseSyncActionTests.java | 12 ++-- .../indices/cluster/ClusterStateChanges.java | 25 +++++--- .../PublishCheckpointActionTests.java | 9 ++- .../InternalOrPrivateSettingsPlugin.java | 7 ++- .../persistent/TestPersistentTasksPlugin.java | 11 +++- .../indices/RestValidateQueryActionTests.java | 4 +- .../snapshots/SnapshotResiliencyTests.java | 60 ++++++++++++------- .../opensearch/test/OpenSearchTestCase.java | 4 ++ .../SkipTracingStrictValidation.java | 29 +++++++++ .../SkipTracingStrictValidationRule.java | 36 +++++++++++ .../tracing/StrictCheckSpanProcessor.java | 24 +++++++- 254 files changed, 1572 insertions(+), 574 deletions(-) create mode 100644 test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java create mode 100644 test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidationRule.java diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java index 77d4d3d095b29..9d27863982b49 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java @@ -43,6 +43,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.index.shard.ShardId; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; public class TransportNoopBulkAction extends HandledTransportAction { @@ -53,8 +54,8 @@ public class TransportNoopBulkAction extends HandledTransportAction { @Inject - public TransportNoopSearchAction(TransportService transportService, ActionFilters actionFilters) { - super(NoopSearchAction.NAME, transportService, actionFilters, (Writeable.Reader) SearchRequest::new); + public TransportNoopSearchAction(TransportService transportService, ActionFilters actionFilters, Tracer tracer) { + super(NoopSearchAction.NAME, transportService, actionFilters, (Writeable.Reader) SearchRequest::new, tracer); } @Override diff --git a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java index 9c79a06a45f58..f8c44ee2329fc 100644 --- a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java +++ b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java @@ -49,6 +49,7 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.io.IOException; @@ -134,13 +135,13 @@ public static class TransportAction extends HandledTransportAction sortedGrokPatterns; @Inject - public TransportAction(TransportService transportService, ActionFilters actionFilters) { - this(transportService, actionFilters, Grok.BUILTIN_PATTERNS); + public TransportAction(TransportService transportService, ActionFilters actionFilters, Tracer tracer) { + this(transportService, actionFilters, Grok.BUILTIN_PATTERNS, tracer); } // visible for testing - TransportAction(TransportService transportService, ActionFilters actionFilters, Map grokPatterns) { - super(NAME, transportService, actionFilters, Request::new); + TransportAction(TransportService transportService, ActionFilters actionFilters, Map grokPatterns, Tracer tracer) { + super(NAME, transportService, actionFilters, Request::new, tracer); this.grokPatterns = grokPatterns; this.sortedGrokPatterns = new TreeMap<>(this.grokPatterns); } diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java index f8c760d48920f..3467c4257e25b 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java @@ -41,6 +41,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.TransportService; @@ -84,7 +85,8 @@ public void testResponseSorting() { GrokProcessorGetAction.TransportAction transportAction = new GrokProcessorGetAction.TransportAction( mock(TransportService.class), mock(ActionFilters.class), - TEST_PATTERNS + TEST_PATTERNS, + NoopTracer.INSTANCE ); GrokProcessorGetAction.Response[] receivedResponse = new GrokProcessorGetAction.Response[1]; transportAction.doExecute(null, new GrokProcessorGetAction.Request(true), new ActionListener() { diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java index b17b48ec1cbf8..e97b21c66a4f1 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java @@ -43,6 +43,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.script.ScriptService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.ArrayList; @@ -62,9 +63,10 @@ public TransportMultiSearchTemplateAction( ActionFilters actionFilters, ScriptService scriptService, NamedXContentRegistry xContentRegistry, - NodeClient client + NodeClient client, + Tracer tracer ) { - super(MultiSearchTemplateAction.NAME, transportService, actionFilters, MultiSearchTemplateRequest::new); + super(MultiSearchTemplateAction.NAME, transportService, actionFilters, MultiSearchTemplateRequest::new, tracer); this.scriptService = scriptService; this.xContentRegistry = xContentRegistry; this.client = client; diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java index 6e8b9d059b583..adf1d32119ed6 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java @@ -52,6 +52,7 @@ import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.search.internal.SearchContext; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.io.IOException; @@ -71,9 +72,10 @@ public TransportSearchTemplateAction( ActionFilters actionFilters, ScriptService scriptService, NamedXContentRegistry xContentRegistry, - NodeClient client + NodeClient client, + Tracer tracer ) { - super(SearchTemplateAction.NAME, transportService, actionFilters, SearchTemplateRequest::new); + super(SearchTemplateAction.NAME, transportService, actionFilters, SearchTemplateRequest::new, tracer); this.scriptService = scriptService; this.xContentRegistry = xContentRegistry; this.client = client; diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java index a26cb79a9717d..3098902d60c97 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java @@ -54,6 +54,7 @@ import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.script.ScriptContext; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.io.IOException; @@ -166,8 +167,13 @@ public static class TransportAction extends HandledTransportAction) Request::new); + public TransportAction( + TransportService transportService, + ActionFilters actionFilters, + PainlessScriptEngine painlessScriptEngine, + Tracer tracer + ) { + super(NAME, transportService, actionFilters, (Writeable.Reader) Request::new, tracer); this.painlessScriptEngine = painlessScriptEngine; } diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java index 67b298eee7973..f7fcb3fe4add6 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java @@ -90,6 +90,7 @@ import org.opensearch.script.ScriptContext; import org.opensearch.script.ScriptService; import org.opensearch.script.ScriptType; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -475,7 +476,8 @@ public TransportAction( IndexNameExpressionResolver indexNameExpressionResolver, ScriptService scriptService, ClusterService clusterService, - IndicesService indicesServices + IndicesService indicesServices, + Tracer tracer ) { super( NAME, @@ -488,7 +490,8 @@ public TransportAction( // Creating a in-memory index is not light weight // TODO: is MANAGEMENT TP the right TP? Right now this is an admin api (see action name). Request::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.scriptService = scriptService; this.indicesServices = indicesServices; diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java index ffdea14e0873d..923ba571850f1 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java @@ -53,6 +53,7 @@ import org.opensearch.search.SearchHit; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.io.IOException; @@ -90,9 +91,10 @@ public TransportRankEvalAction( Client client, TransportService transportService, ScriptService scriptService, - NamedXContentRegistry namedXContentRegistry + NamedXContentRegistry namedXContentRegistry, + Tracer tracer ) { - super(RankEvalAction.NAME, transportService, actionFilters, (Writeable.Reader) RankEvalRequest::new); + super(RankEvalAction.NAME, transportService, actionFilters, (Writeable.Reader) RankEvalRequest::new, tracer); this.scriptService = scriptService; this.namedXContentRegistry = namedXContentRegistry; this.client = client; diff --git a/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java b/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java index bd42289015bf4..650d49f0059fa 100644 --- a/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java +++ b/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java @@ -44,6 +44,7 @@ import org.opensearch.env.Environment; import org.opensearch.script.ScriptService; import org.opensearch.search.builder.SearchSourceBuilder; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.TransportService; @@ -103,7 +104,8 @@ public void multiSearch(MultiSearchRequest request, ActionListener) DeleteByQueryRequest::new + (Writeable.Reader) DeleteByQueryRequest::new, + tracer ); this.threadPool = threadPool; this.client = client; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java index e624b0619a26e..d9da6aaee3081 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java @@ -46,6 +46,7 @@ import org.opensearch.index.reindex.spi.RemoteReindexExtension; import org.opensearch.script.ScriptService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -87,9 +88,10 @@ public TransportReindexAction( AutoCreateIndex autoCreateIndex, Client client, TransportService transportService, - ReindexSslConfig sslConfig + ReindexSslConfig sslConfig, + Tracer tracer ) { - super(ReindexAction.NAME, transportService, actionFilters, ReindexRequest::new); + super(ReindexAction.NAME, transportService, actionFilters, ReindexRequest::new, tracer); this.reindexValidator = new ReindexValidator(settings, clusterService, indexNameExpressionResolver, autoCreateIndex); this.reindexer = new Reindexer(clusterService, client, threadPool, scriptService, sslConfig, remoteExtension); } diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java index 21ae8fd722629..b4755e9570541 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java @@ -44,6 +44,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -57,7 +58,8 @@ public TransportRethrottleAction( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - Client client + Client client, + Tracer tracer ) { super( RethrottleAction.NAME, @@ -67,7 +69,8 @@ public TransportRethrottleAction( RethrottleRequest::new, ListTasksResponse::new, TaskInfo::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.client = client; } diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java index 1af9b62d72fd4..97c7c1dbbdaa8 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java @@ -49,6 +49,7 @@ import org.opensearch.script.Script; import org.opensearch.script.ScriptService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -69,13 +70,15 @@ public TransportUpdateByQueryAction( Client client, TransportService transportService, ScriptService scriptService, - ClusterService clusterService + ClusterService clusterService, + Tracer tracer ) { super( UpdateByQueryAction.NAME, transportService, actionFilters, - (Writeable.Reader) UpdateByQueryRequest::new + (Writeable.Reader) UpdateByQueryRequest::new, + tracer ); this.threadPool = threadPool; this.client = client; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java index 8ddc1ff778982..87e06a7582e53 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java @@ -89,6 +89,7 @@ import org.opensearch.search.internal.InternalSearchResponse; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.client.NoOpClient; import org.opensearch.threadpool.TestThreadPool; @@ -818,8 +819,13 @@ private static class DummyTransportAsyncBulkByScrollAction extends TransportActi DummyAbstractBulkByScrollRequest, BulkByScrollResponse> { - protected DummyTransportAsyncBulkByScrollAction(String actionName, ActionFilters actionFilters, TaskManager taskManager) { - super(actionName, actionFilters, taskManager); + protected DummyTransportAsyncBulkByScrollAction( + String actionName, + ActionFilters actionFilters, + TaskManager taskManager, + Tracer tracer + ) { + super(actionName, actionFilters, taskManager, tracer); } @Override diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWithScriptTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWithScriptTests.java index ce982dcb6bd34..d5b8a548d24f6 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWithScriptTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWithScriptTests.java @@ -35,6 +35,7 @@ import org.opensearch.action.support.ActionFilters; import org.opensearch.cluster.ClusterState; import org.opensearch.script.ScriptService; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.transport.TransportService; import java.util.Collections; @@ -79,7 +80,8 @@ protected TransportUpdateByQueryAction.AsyncIndexBySearchAction action(ScriptSer null, transportService, scriptService, - null + null, + NoopTracer.INSTANCE ); return new TransportUpdateByQueryAction.AsyncIndexBySearchAction( task, diff --git a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java index 7b4fb670c4aee..3761faa1a7468 100644 --- a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java +++ b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java @@ -34,6 +34,7 @@ import org.opensearch.plugin.correlation.utils.IndexUtils; import org.opensearch.rest.RestRequest; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.io.IOException; @@ -68,9 +69,10 @@ public TransportIndexCorrelationRuleAction( Client client, ActionFilters actionFilters, ClusterService clusterService, - CorrelationRuleIndices correlationRuleIndices + CorrelationRuleIndices correlationRuleIndices, + Tracer tracer ) { - super(IndexCorrelationRuleAction.NAME, transportService, actionFilters, IndexCorrelationRuleRequest::new); + super(IndexCorrelationRuleAction.NAME, transportService, actionFilters, IndexCorrelationRuleRequest::new, tracer); this.client = client; this.clusterService = clusterService; this.correlationRuleIndices = correlationRuleIndices; diff --git a/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java b/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java index 8a49a0abf5512..14a5f8f142a59 100644 --- a/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java +++ b/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java @@ -82,7 +82,7 @@ public void testSanityChecksWhenTracingEnabled() throws Exception { Arrays.asList( new AllSpansAreEndedProperly(), new AllSpansHaveUniqueId(), - new NumberOfTraceIDsEqualToRequests(Attributes.create().addAttribute("action", "indices:data/read/search[phase/query]")), + new NumberOfTraceIDsEqualToRequests(Attributes.create().addAttribute("action", "indices:data/read/search")), new TotalRootSpansEqualToRequests() ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java index c4dcedcc722cf..7e39554c2453b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java @@ -68,6 +68,7 @@ import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.test.InternalTestCluster; import org.opensearch.test.ParameterizedOpenSearchIntegTestCase; import org.opensearch.threadpool.ThreadPool; @@ -495,8 +496,8 @@ public static class TransportTestAction extends HandledTransportAction starting three cluster-manager nodes and two data nodes"); internalCluster().startClusterManagerOnlyNodes(3); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java index d59c7e50c55cc..f5e9e4eaa31ba 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java @@ -55,6 +55,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.snapshots.SnapshotsInfoService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -88,7 +89,8 @@ public TransportClusterAllocationExplainAction( ClusterInfoService clusterInfoService, SnapshotsInfoService snapshotsInfoService, AllocationDeciders allocationDeciders, - AllocationService allocationService + AllocationService allocationService, + Tracer tracer ) { super( ClusterAllocationExplainAction.NAME, @@ -97,7 +99,8 @@ public TransportClusterAllocationExplainAction( threadPool, actionFilters, ClusterAllocationExplainRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.clusterInfoService = clusterInfoService; this.snapshotsInfoService = snapshotsInfoService; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java index f578925e54ce7..1978c80bbeddb 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java @@ -55,6 +55,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.TransportService; @@ -96,7 +97,8 @@ public TransportAddVotingConfigExclusionsAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( AddVotingConfigExclusionsAction.NAME, @@ -105,7 +107,8 @@ public TransportAddVotingConfigExclusionsAction( threadPool, actionFilters, AddVotingConfigExclusionsRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); maxVotingConfigExclusions = MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING.get(settings); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java index c3c08b9636518..fcd5c99a35a48 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java @@ -51,6 +51,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.TransportService; @@ -77,7 +78,8 @@ public TransportClearVotingConfigExclusionsAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ClearVotingConfigExclusionsAction.NAME, @@ -86,7 +88,8 @@ public TransportClearVotingConfigExclusionsAction( threadPool, actionFilters, ClearVotingConfigExclusionsRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java index 8901375a4095a..212a77d0def07 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java @@ -21,6 +21,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -45,7 +46,8 @@ public TransportDeleteDecommissionStateAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - DecommissionService decommissionService + DecommissionService decommissionService, + Tracer tracer ) { super( DeleteDecommissionStateAction.NAME, @@ -54,7 +56,8 @@ public TransportDeleteDecommissionStateAction( threadPool, actionFilters, DeleteDecommissionStateRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.decommissionService = decommissionService; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java index 22feb4d99297a..1ead4daef5a29 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java @@ -19,6 +19,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -39,7 +40,8 @@ public TransportGetDecommissionStateAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( GetDecommissionStateAction.NAME, @@ -48,7 +50,8 @@ public TransportGetDecommissionStateAction( threadPool, actionFilters, GetDecommissionStateRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java index 0b1fd380ffdda..4a18427680704 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java @@ -21,6 +21,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -43,7 +44,8 @@ public TransportDecommissionAction( DecommissionService decommissionService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( DecommissionAction.NAME, @@ -52,7 +54,8 @@ public TransportDecommissionAction( threadPool, actionFilters, DecommissionRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.decommissionService = decommissionService; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java index 1cc357a4c20f4..806578391ddf5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java @@ -67,6 +67,7 @@ import org.opensearch.index.IndexNotFoundException; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -94,7 +95,8 @@ public TransportClusterHealthAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, AllocationService allocationService, - Discovery discovery + Discovery discovery, + Tracer tracer ) { super( ClusterHealthAction.NAME, @@ -104,7 +106,8 @@ public TransportClusterHealthAction( threadPool, actionFilters, ClusterHealthRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.allocationService = allocationService; this.discovery = discovery; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java index 482d9526fa53c..6949f6409866a 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java @@ -41,6 +41,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.monitor.jvm.HotThreads; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -64,7 +65,8 @@ public TransportNodesHotThreadsAction( ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { super( NodesHotThreadsAction.NAME, @@ -75,7 +77,8 @@ public TransportNodesHotThreadsAction( NodesHotThreadsRequest::new, NodeRequest::new, ThreadPool.Names.GENERIC, - NodeHotThreads.class + NodeHotThreads.class, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/TransportNodesInfoAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/TransportNodesInfoAction.java index 2c4f8522a5a5c..a5f6b0853a449 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/TransportNodesInfoAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/TransportNodesInfoAction.java @@ -40,6 +40,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.node.NodeService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -67,7 +68,8 @@ public TransportNodesInfoAction( ClusterService clusterService, TransportService transportService, NodeService nodeService, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { super( NodesInfoAction.NAME, @@ -78,7 +80,8 @@ public TransportNodesInfoAction( NodesInfoRequest::new, NodeInfoRequest::new, ThreadPool.Names.MANAGEMENT, - NodeInfo.class + NodeInfo.class, + tracer ); this.nodeService = nodeService; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java index 92b8af0b8aa84..8fb4f0fdd2392 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java @@ -52,6 +52,7 @@ import org.opensearch.plugins.PluginsService; import org.opensearch.plugins.ReloadablePlugin; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -81,7 +82,8 @@ public TransportNodesReloadSecureSettingsAction( TransportService transportService, ActionFilters actionFilters, Environment environment, - PluginsService pluginService + PluginsService pluginService, + Tracer tracer ) { super( NodesReloadSecureSettingsAction.NAME, @@ -92,7 +94,8 @@ public TransportNodesReloadSecureSettingsAction( NodesReloadSecureSettingsRequest::new, NodeRequest::new, ThreadPool.Names.GENERIC, - NodesReloadSecureSettingsResponse.NodeResponse.class + NodesReloadSecureSettingsResponse.NodeResponse.class, + tracer ); this.environment = environment; this.pluginsService = pluginService; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java index 615abbaef845d..b317ddccadfb5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java @@ -40,6 +40,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.node.NodeService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -67,7 +68,8 @@ public TransportNodesStatsAction( ClusterService clusterService, TransportService transportService, NodeService nodeService, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { super( NodesStatsAction.NAME, @@ -78,7 +80,8 @@ public TransportNodesStatsAction( NodesStatsRequest::new, NodeStatsRequest::new, ThreadPool.Names.MANAGEMENT, - NodeStats.class + NodeStats.class, + tracer ); this.nodeService = nodeService; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java index 634ce1e2d4095..5291e9130bd16 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java @@ -42,6 +42,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.TaskInfo; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -60,7 +61,12 @@ public class TransportCancelTasksAction extends TransportTasksAction { @Inject - public TransportCancelTasksAction(ClusterService clusterService, TransportService transportService, ActionFilters actionFilters) { + public TransportCancelTasksAction( + ClusterService clusterService, + TransportService transportService, + ActionFilters actionFilters, + Tracer tracer + ) { super( CancelTasksAction.NAME, clusterService, @@ -69,7 +75,8 @@ public TransportCancelTasksAction(ClusterService clusterService, TransportServic CancelTasksRequest::new, CancelTasksResponse::new, TaskInfo::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java index 8d82827f4ee50..a2274b7ec1b00 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java @@ -57,6 +57,7 @@ import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskResult; import org.opensearch.tasks.TaskResultsService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequestOptions; import org.opensearch.transport.TransportService; @@ -91,9 +92,10 @@ public TransportGetTaskAction( ActionFilters actionFilters, ClusterService clusterService, Client client, - NamedXContentRegistry xContentRegistry + NamedXContentRegistry xContentRegistry, + Tracer tracer ) { - super(GetTaskAction.NAME, transportService, actionFilters, GetTaskRequest::new); + super(GetTaskAction.NAME, transportService, actionFilters, GetTaskRequest::new, tracer); this.threadPool = threadPool; this.clusterService = clusterService; this.transportService = transportService; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java index 1c543e60c46e0..26d3d21b4f1a3 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java @@ -43,6 +43,7 @@ import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskResourceTrackingService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -73,7 +74,8 @@ public TransportListTasksAction( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - TaskResourceTrackingService taskResourceTrackingService + TaskResourceTrackingService taskResourceTrackingService, + Tracer tracer ) { super( ListTasksAction.NAME, @@ -83,7 +85,8 @@ public TransportListTasksAction( ListTasksRequest::new, ListTasksResponse::new, TaskInfo::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.taskResourceTrackingService = taskResourceTrackingService; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java index 7a4aeff50c6e7..d13e2a9838cb2 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java @@ -40,6 +40,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.aggregations.support.AggregationUsageService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -71,7 +72,8 @@ public TransportNodesUsageAction( TransportService transportService, ActionFilters actionFilters, UsageService restUsageService, - AggregationUsageService aggregationUsageService + AggregationUsageService aggregationUsageService, + Tracer tracer ) { super( NodesUsageAction.NAME, @@ -82,7 +84,8 @@ public TransportNodesUsageAction( NodesUsageRequest::new, NodeUsageRequest::new, ThreadPool.Names.MANAGEMENT, - NodeUsage.class + NodeUsage.class, + tracer ); this.restUsageService = restUsageService; this.aggregationUsageService = aggregationUsageService; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java index cb7c965069987..6974e24bc34c5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java @@ -38,6 +38,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.RemoteClusterService; import org.opensearch.transport.TransportService; @@ -56,9 +57,10 @@ public final class TransportRemoteInfoAction extends HandledTransportAction requestValidators + final RequestValidators requestValidators, + final Tracer tracer ) { super( IndicesAliasesAction.NAME, @@ -98,7 +100,8 @@ public TransportIndicesAliasesAction( threadPool, actionFilters, IndicesAliasesRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexAliasesService = indexAliasesService; this.requestValidators = Objects.requireNonNull(requestValidators); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java index 3aca9c1976f16..3e48e3b2234b7 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java @@ -46,6 +46,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.indices.SystemIndices; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -77,7 +78,8 @@ public TransportGetAliasesAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - SystemIndices systemIndices + SystemIndices systemIndices, + Tracer tracer ) { super( GetAliasesAction.NAME, @@ -86,7 +88,8 @@ public TransportGetAliasesAction( threadPool, actionFilters, GetAliasesRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.systemIndices = systemIndices; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/analyze/TransportAnalyzeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/analyze/TransportAnalyzeAction.java index 8dc55e580b9ec..0bfeabe2f4a03 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/analyze/TransportAnalyzeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/analyze/TransportAnalyzeAction.java @@ -66,6 +66,7 @@ import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.index.mapper.StringFieldType; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -98,7 +99,8 @@ public TransportAnalyzeAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( AnalyzeAction.NAME, @@ -108,7 +110,8 @@ public TransportAnalyzeAction( actionFilters, indexNameExpressionResolver, AnalyzeAction.Request::new, - ThreadPool.Names.ANALYZE + ThreadPool.Names.ANALYZE, + tracer ); this.settings = settings; this.indicesService = indicesService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java b/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java index acc6a6c14c5fd..ed813602a3e4e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java @@ -47,6 +47,7 @@ import org.opensearch.index.shard.ShardPath; import org.opensearch.indices.IndicesService; import org.opensearch.node.Node; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -76,7 +77,8 @@ public TransportClearIndicesCacheAction( IndicesService indicesService, Node node, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ClearIndicesCacheAction.NAME, @@ -86,7 +88,8 @@ public TransportClearIndicesCacheAction( indexNameExpressionResolver, ClearIndicesCacheRequest::new, ThreadPool.Names.MANAGEMENT, - false + false, + tracer ); this.indicesService = indicesService; this.node = node; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java index cde2ef63df02d..b3d2d11d1aae4 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java @@ -53,6 +53,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -88,7 +89,8 @@ public TransportCloseIndexAction( ClusterSettings clusterSettings, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - DestructiveOperations destructiveOperations + DestructiveOperations destructiveOperations, + Tracer tracer ) { super( CloseIndexAction.NAME, @@ -97,7 +99,8 @@ public TransportCloseIndexAction( threadPool, actionFilters, CloseIndexRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexStateService = indexStateService; this.destructiveOperations = destructiveOperations; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java index a8a512a5ad05a..62064dfec68b6 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java @@ -53,6 +53,7 @@ import org.opensearch.core.tasks.TaskId; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -80,7 +81,8 @@ public TransportVerifyShardBeforeCloseAction( final IndicesService indicesService, final ThreadPool threadPool, final ShardStateAction stateAction, - final ActionFilters actionFilters + final ActionFilters actionFilters, + final Tracer tracer ) { super( settings, @@ -93,7 +95,8 @@ public TransportVerifyShardBeforeCloseAction( actionFilters, ShardRequest::new, ShardRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java index 02dd2de803f58..aa64aaf6459ce 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java @@ -56,6 +56,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -96,9 +97,19 @@ public TransportAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, MetadataCreateIndexService createIndexService, - MetadataCreateDataStreamService metadataCreateDataStreamService + MetadataCreateDataStreamService metadataCreateDataStreamService, + Tracer tracer ) { - super(NAME, transportService, clusterService, threadPool, actionFilters, CreateIndexRequest::new, indexNameExpressionResolver); + super( + NAME, + transportService, + clusterService, + threadPool, + actionFilters, + CreateIndexRequest::new, + indexNameExpressionResolver, + tracer + ); this.activeShardsObserver = new ActiveShardsObserver(clusterService, threadPool); this.createIndexService = createIndexService; this.metadataCreateDataStreamService = metadataCreateDataStreamService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java index b5f822bd45b7e..8c48429cc4631 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java @@ -43,6 +43,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -64,7 +65,8 @@ public TransportCreateIndexAction( ThreadPool threadPool, MetadataCreateIndexService createIndexService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( CreateIndexAction.NAME, @@ -73,7 +75,8 @@ public TransportCreateIndexAction( threadPool, actionFilters, CreateIndexRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.createIndexService = createIndexService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java index 751a872ee7dcd..467796bbc1632 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java @@ -60,6 +60,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -91,7 +92,8 @@ public TransportDeleteDanglingIndexAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, Settings settings, - NodeClient nodeClient + NodeClient nodeClient, + Tracer tracer ) { super( DeleteDanglingIndexAction.NAME, @@ -100,7 +102,8 @@ public TransportDeleteDanglingIndexAction( threadPool, actionFilters, DeleteDanglingIndexRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.settings = settings; this.nodeClient = nodeClient; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/dangling/find/TransportFindDanglingIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/dangling/find/TransportFindDanglingIndexAction.java index 13da03a04acbd..e772647cdb2fc 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/dangling/find/TransportFindDanglingIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/dangling/find/TransportFindDanglingIndexAction.java @@ -41,6 +41,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.gateway.DanglingIndicesState; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -68,7 +69,8 @@ public TransportFindDanglingIndexAction( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - DanglingIndicesState danglingIndicesState + DanglingIndicesState danglingIndicesState, + Tracer tracer ) { super( FindDanglingIndexAction.NAME, @@ -79,7 +81,8 @@ public TransportFindDanglingIndexAction( FindDanglingIndexRequest::new, NodeFindDanglingIndexRequest::new, ThreadPool.Names.MANAGEMENT, - NodeFindDanglingIndexResponse.class + NodeFindDanglingIndexResponse.class, + tracer ); this.transportService = transportService; this.danglingIndicesState = danglingIndicesState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java index 3f47d1bf083f4..62ea06a7e16a2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java @@ -49,6 +49,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.gateway.LocalAllocateDangledIndices; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.ArrayList; @@ -76,9 +77,10 @@ public TransportImportDanglingIndexAction( ActionFilters actionFilters, TransportService transportService, LocalAllocateDangledIndices danglingIndexAllocator, - NodeClient nodeClient + NodeClient nodeClient, + Tracer tracer ) { - super(ImportDanglingIndexAction.NAME, transportService, actionFilters, ImportDanglingIndexRequest::new); + super(ImportDanglingIndexAction.NAME, transportService, actionFilters, ImportDanglingIndexRequest::new, tracer); this.danglingIndexAllocator = danglingIndexAllocator; this.nodeClient = nodeClient; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/dangling/list/TransportListDanglingIndicesAction.java b/server/src/main/java/org/opensearch/action/admin/indices/dangling/list/TransportListDanglingIndicesAction.java index 59076cc6ef8fb..f3b0120889387 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/dangling/list/TransportListDanglingIndicesAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/dangling/list/TransportListDanglingIndicesAction.java @@ -42,6 +42,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.gateway.DanglingIndicesState; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -69,7 +70,8 @@ public TransportListDanglingIndicesAction( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - DanglingIndicesState danglingIndicesState + DanglingIndicesState danglingIndicesState, + Tracer tracer ) { super( ListDanglingIndicesAction.NAME, @@ -80,7 +82,8 @@ public TransportListDanglingIndicesAction( ListDanglingIndicesRequest::new, NodeListDanglingIndicesRequest::new, ThreadPool.Names.MANAGEMENT, - NodeListDanglingIndicesResponse.class + NodeListDanglingIndicesResponse.class, + tracer ); this.transportService = transportService; this.danglingIndicesState = danglingIndicesState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java b/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java index 14b29c4b2bbba..21e974487ddb9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java @@ -52,6 +52,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -145,9 +146,10 @@ public TransportAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - MetadataCreateDataStreamService metadataCreateDataStreamService + MetadataCreateDataStreamService metadataCreateDataStreamService, + Tracer tracer ) { - super(NAME, transportService, clusterService, threadPool, actionFilters, Request::new, indexNameExpressionResolver); + super(NAME, transportService, clusterService, threadPool, actionFilters, Request::new, indexNameExpressionResolver, tracer); this.metadataCreateDataStreamService = metadataCreateDataStreamService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/datastream/DataStreamsStatsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/datastream/DataStreamsStatsAction.java index fcb13f4091638..75594d5e0fbd3 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/datastream/DataStreamsStatsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/datastream/DataStreamsStatsAction.java @@ -64,6 +64,7 @@ import org.opensearch.index.shard.ShardNotFoundException; import org.opensearch.index.store.StoreStats; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -379,7 +380,8 @@ public TransportAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( DataStreamsStatsAction.NAME, @@ -388,7 +390,8 @@ public TransportAction( actionFilters, indexNameExpressionResolver, Request::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.clusterService = clusterService; this.indicesService = indicesService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java b/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java index 190194e071bc4..275af1069c9b3 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java @@ -64,6 +64,7 @@ import org.opensearch.core.index.Index; import org.opensearch.snapshots.SnapshotInProgressException; import org.opensearch.snapshots.SnapshotsService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -178,9 +179,10 @@ public TransportAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - MetadataDeleteIndexService deleteIndexService + MetadataDeleteIndexService deleteIndexService, + Tracer tracer ) { - super(NAME, transportService, clusterService, threadPool, actionFilters, Request::new, indexNameExpressionResolver); + super(NAME, transportService, clusterService, threadPool, actionFilters, Request::new, indexNameExpressionResolver, tracer); this.deleteIndexService = deleteIndexService; // Task is onboarded for throttling, it will get retried from associated TransportClusterManagerNodeAction. removeDataStreamTaskKey = clusterService.registerClusterManagerTask(ClusterManagerTaskKeys.REMOVE_DATA_STREAM_KEY, true); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java b/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java index 6a7967d31653c..6efb992445d23 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java @@ -61,6 +61,7 @@ import org.opensearch.core.index.Index; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -297,9 +298,10 @@ public TransportAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(NAME, transportService, clusterService, threadPool, actionFilters, Request::new, indexNameExpressionResolver); + super(NAME, transportService, clusterService, threadPool, actionFilters, Request::new, indexNameExpressionResolver, tracer); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java index 410a58afc95f1..ffb423a744269 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java @@ -50,6 +50,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -78,7 +79,8 @@ public TransportDeleteIndexAction( MetadataDeleteIndexService deleteIndexService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - DestructiveOperations destructiveOperations + DestructiveOperations destructiveOperations, + Tracer tracer ) { super( DeleteIndexAction.NAME, @@ -87,7 +89,8 @@ public TransportDeleteIndexAction( threadPool, actionFilters, DeleteIndexRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.deleteIndexService = deleteIndexService; this.destructiveOperations = destructiveOperations; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java index 428a0eb35513d..18f004d98335c 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java @@ -44,6 +44,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.index.IndexNotFoundException; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -62,7 +63,8 @@ public TransportIndicesExistsAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( IndicesExistsAction.NAME, @@ -71,7 +73,8 @@ public TransportIndicesExistsAction( threadPool, actionFilters, IndicesExistsRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportFlushAction.java b/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportFlushAction.java index 07434c65862b6..88fb290a4e7d5 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportFlushAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportFlushAction.java @@ -40,6 +40,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.List; @@ -61,7 +62,8 @@ public TransportFlushAction( TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - TransportShardFlushAction replicatedFlushAction + TransportShardFlushAction replicatedFlushAction, + Tracer tracer ) { super( FlushAction.NAME, @@ -70,7 +72,8 @@ public TransportFlushAction( transportService, actionFilters, indexNameExpressionResolver, - replicatedFlushAction + replicatedFlushAction, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java b/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java index 90db53af72257..ccb7144ab8e22 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java @@ -47,6 +47,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportChannel; import org.opensearch.transport.TransportRequest; @@ -72,7 +73,8 @@ public TransportShardFlushAction( IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { super( settings, @@ -85,7 +87,8 @@ public TransportShardFlushAction( actionFilters, ShardFlushRequest::new, ShardFlushRequest::new, - ThreadPool.Names.FLUSH + ThreadPool.Names.FLUSH, + tracer ); transportService.registerRequestHandler( PRE_SYNCED_FLUSH_ACTION_NAME, diff --git a/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/TransportForceMergeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/TransportForceMergeAction.java index fb8eb86c12269..c6e35f18eba1f 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/TransportForceMergeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/TransportForceMergeAction.java @@ -46,6 +46,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -70,7 +71,8 @@ public TransportForceMergeAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ForceMergeAction.NAME, @@ -79,7 +81,8 @@ public TransportForceMergeAction( actionFilters, indexNameExpressionResolver, ForceMergeRequest::new, - ThreadPool.Names.FORCE_MERGE + ThreadPool.Names.FORCE_MERGE, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java index 755119401c6b5..e5d4b764979b7 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java @@ -47,6 +47,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -78,7 +79,8 @@ public TransportGetIndexAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, IndicesService indicesService, - IndexScopedSettings indexScopedSettings + IndexScopedSettings indexScopedSettings, + Tracer tracer ) { super( GetIndexAction.NAME, @@ -87,7 +89,8 @@ public TransportGetIndexAction( threadPool, actionFilters, GetIndexRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indicesService = indicesService; this.settingsFilter = settingsFilter; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java index 53dbb86233803..37d1ae11b2300 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java @@ -40,6 +40,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.HashMap; @@ -67,9 +68,10 @@ public TransportGetFieldMappingsAction( ClusterService clusterService, TransportGetFieldMappingsIndexAction shardAction, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(GetFieldMappingsAction.NAME, transportService, actionFilters, GetFieldMappingsRequest::new); + super(GetFieldMappingsAction.NAME, transportService, actionFilters, GetFieldMappingsRequest::new, tracer); this.clusterService = clusterService; this.shardAction = shardAction; this.indexNameExpressionResolver = indexNameExpressionResolver; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java index 64f39644a4d96..7f494d7841d36 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java @@ -55,6 +55,7 @@ import org.opensearch.index.mapper.Mapper; import org.opensearch.index.mapper.MappingLookup; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -87,7 +88,8 @@ public TransportGetFieldMappingsIndexAction( IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ACTION_NAME, @@ -97,7 +99,8 @@ public TransportGetFieldMappingsIndexAction( actionFilters, indexNameExpressionResolver, GetFieldMappingsIndexRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.clusterService = clusterService; this.indicesService = indicesService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java index 6f07aa4dbf48a..b6a3da6a2afaa 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java @@ -44,6 +44,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -68,7 +69,8 @@ public TransportGetMappingsAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - IndicesService indicesService + IndicesService indicesService, + Tracer tracer ) { super( GetMappingsAction.NAME, @@ -77,7 +79,8 @@ public TransportGetMappingsAction( threadPool, actionFilters, GetMappingsRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java index 4722c1048014f..81fe4beda2aec 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java @@ -45,6 +45,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -66,7 +67,8 @@ public TransportAutoPutMappingAction( final ThreadPool threadPool, final MetadataMappingService metadataMappingService, final ActionFilters actionFilters, - final IndexNameExpressionResolver indexNameExpressionResolver + final IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( AutoPutMappingAction.NAME, @@ -75,7 +77,8 @@ public TransportAutoPutMappingAction( threadPool, actionFilters, PutMappingRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.metadataMappingService = metadataMappingService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java index ac797914aafd8..4cc065752bd5a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java @@ -51,6 +51,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; import org.opensearch.index.IndexNotFoundException; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -81,7 +82,8 @@ public TransportPutMappingAction( final MetadataMappingService metadataMappingService, final ActionFilters actionFilters, final IndexNameExpressionResolver indexNameExpressionResolver, - final RequestValidators requestValidators + final RequestValidators requestValidators, + final Tracer tracer ) { super( PutMappingAction.NAME, @@ -90,7 +92,8 @@ public TransportPutMappingAction( threadPool, actionFilters, PutMappingRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.metadataMappingService = metadataMappingService; this.requestValidators = Objects.requireNonNull(requestValidators); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java index 0243990dce2ff..b224da4b27ac6 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java @@ -50,6 +50,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -75,7 +76,8 @@ public TransportOpenIndexAction( MetadataIndexStateService indexStateService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - DestructiveOperations destructiveOperations + DestructiveOperations destructiveOperations, + Tracer tracer ) { super( OpenIndexAction.NAME, @@ -84,7 +86,8 @@ public TransportOpenIndexAction( threadPool, actionFilters, OpenIndexRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexStateService = indexStateService; this.destructiveOperations = destructiveOperations; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java index eb018d16119e0..b2bc94438ed64 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java @@ -49,6 +49,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -80,7 +81,8 @@ public TransportAddIndexBlockAction( MetadataIndexStateService indexStateService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - DestructiveOperations destructiveOperations + DestructiveOperations destructiveOperations, + Tracer tracer ) { super( AddIndexBlockAction.NAME, @@ -89,7 +91,8 @@ public TransportAddIndexBlockAction( threadPool, actionFilters, AddIndexBlockRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexStateService = indexStateService; this.destructiveOperations = destructiveOperations; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java index a86475a16a779..8625008a241ff 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java @@ -53,6 +53,7 @@ import org.opensearch.core.tasks.TaskId; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -84,7 +85,8 @@ public TransportVerifyShardIndexBlockAction( final IndicesService indicesService, final ThreadPool threadPool, final ShardStateAction stateAction, - final ActionFilters actionFilters + final ActionFilters actionFilters, + final Tracer tracer ) { super( settings, @@ -97,7 +99,8 @@ public TransportVerifyShardIndexBlockAction( actionFilters, ShardRequest::new, ShardRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/recovery/TransportRecoveryAction.java b/server/src/main/java/org/opensearch/action/admin/indices/recovery/TransportRecoveryAction.java index de76ec2d4f5a7..b68259c42f0db 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/recovery/TransportRecoveryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/recovery/TransportRecoveryAction.java @@ -48,6 +48,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; import org.opensearch.indices.recovery.RecoveryState; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -73,7 +74,8 @@ public TransportRecoveryAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( RecoveryAction.NAME, @@ -82,7 +84,8 @@ public TransportRecoveryAction( actionFilters, indexNameExpressionResolver, RecoveryRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportRefreshAction.java b/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportRefreshAction.java index e276cbf900ff0..1c0a597dbd2b7 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportRefreshAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportRefreshAction.java @@ -42,6 +42,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.List; @@ -63,7 +64,8 @@ public TransportRefreshAction( TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - TransportShardRefreshAction shardRefreshAction + TransportShardRefreshAction shardRefreshAction, + Tracer tracer ) { super( RefreshAction.NAME, @@ -72,7 +74,8 @@ public TransportRefreshAction( transportService, actionFilters, indexNameExpressionResolver, - shardRefreshAction + shardRefreshAction, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java b/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java index e17fa35395770..f331df1299188 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java @@ -44,6 +44,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -69,7 +70,8 @@ public TransportShardRefreshAction( IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { super( settings, @@ -82,7 +84,8 @@ public TransportShardRefreshAction( actionFilters, BasicReplicationRequest::new, BasicReplicationRequest::new, - ThreadPool.Names.REFRESH + ThreadPool.Names.REFRESH, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java index 1b912518d7e04..347ce0e10f4f1 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/replication/TransportSegmentReplicationStatsAction.java @@ -29,6 +29,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.indices.replication.SegmentReplicationState; import org.opensearch.indices.replication.SegmentReplicationTargetService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -63,7 +64,8 @@ public TransportSegmentReplicationStatsAction( SegmentReplicationTargetService targetService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - SegmentReplicationPressureService pressureService + SegmentReplicationPressureService pressureService, + Tracer tracer ) { super( SegmentReplicationStatsAction.NAME, @@ -72,7 +74,8 @@ public TransportSegmentReplicationStatsAction( actionFilters, indexNameExpressionResolver, SegmentReplicationStatsRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.indicesService = indicesService; this.targetService = targetService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java index 98c2446e17998..dc81e7608fd6e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java @@ -61,6 +61,7 @@ import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.RemoteClusterAware; import org.opensearch.transport.RemoteClusterService; @@ -504,9 +505,10 @@ public TransportAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(NAME, transportService, actionFilters, Request::new); + super(NAME, transportService, actionFilters, Request::new, tracer); this.threadPool = threadPool; this.clusterService = clusterService; this.remoteClusterService = transportService.getRemoteClusterService(); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java index 3b11a3d82d707..3e3f145e583d4 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java @@ -58,6 +58,7 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.index.shard.DocsStats; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -89,7 +90,8 @@ public TransportRolloverAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, MetadataRolloverService rolloverService, - Client client + Client client, + Tracer tracer ) { super( RolloverAction.NAME, @@ -98,7 +100,8 @@ public TransportRolloverAction( threadPool, actionFilters, RolloverRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.rolloverService = rolloverService; this.client = client; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java index 6dad4b8e3554f..348402fd4bf71 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java @@ -47,6 +47,7 @@ import org.opensearch.index.IndexService; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -71,7 +72,8 @@ public TransportIndicesSegmentsAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( IndicesSegmentsAction.NAME, @@ -80,7 +82,8 @@ public TransportIndicesSegmentsAction( actionFilters, indexNameExpressionResolver, IndicesSegmentsRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java index 393c07ba58c5e..0071e9e2667ef 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java @@ -38,6 +38,7 @@ import org.opensearch.search.SearchService; import org.opensearch.search.internal.PitReaderContext; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -72,7 +73,8 @@ public TransportPitSegmentsAction( IndexNameExpressionResolver indexNameExpressionResolver, SearchService searchService, NamedWriteableRegistry namedWriteableRegistry, - PitService pitService + PitService pitService, + Tracer tracer ) { super( PitSegmentsAction.NAME, @@ -81,7 +83,8 @@ public TransportPitSegmentsAction( actionFilters, indexNameExpressionResolver, PitSegmentsRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.clusterService = clusterService; this.indicesService = indicesService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java index d8f2180208b18..3335a0af008be 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java @@ -49,6 +49,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.core.index.Index; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -74,7 +75,8 @@ public TransportGetSettingsAction( SettingsFilter settingsFilter, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - IndexScopedSettings indexedScopedSettings + IndexScopedSettings indexedScopedSettings, + Tracer tracer ) { super( GetSettingsAction.NAME, @@ -83,7 +85,8 @@ public TransportGetSettingsAction( threadPool, actionFilters, GetSettingsRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.settingsFilter = settingsFilter; this.indexScopedSettings = indexedScopedSettings; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java index 1c57dc27df8c6..d660a9ffaf882 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java @@ -51,6 +51,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.Index; import org.opensearch.index.IndexModule; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -91,7 +92,8 @@ public TransportUpdateSettingsAction( ThreadPool threadPool, MetadataUpdateSettingsService updateSettingsService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( UpdateSettingsAction.NAME, @@ -100,7 +102,8 @@ public TransportUpdateSettingsAction( threadPool, actionFilters, UpdateSettingsRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.updateSettingsService = updateSettingsService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java index 41225bc362235..a41ea4ae3c41d 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java @@ -61,6 +61,7 @@ import org.opensearch.gateway.AsyncShardFetch; import org.opensearch.gateway.TransportNodesListGatewayStartedShards; import org.opensearch.gateway.TransportNodesListGatewayStartedShards.NodeGatewayStartedShards; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -96,7 +97,8 @@ public TransportIndicesShardStoresAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - TransportNodesListGatewayStartedShards listShardStoresInfo + TransportNodesListGatewayStartedShards listShardStoresInfo, + Tracer tracer ) { super( IndicesShardStoresAction.NAME, @@ -105,7 +107,8 @@ public TransportIndicesShardStoresAction( threadPool, actionFilters, IndicesShardStoresRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.listShardStoresInfo = listShardStoresInfo; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java index 23cd8efdcaf59..74d5777aac760 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java @@ -57,6 +57,7 @@ import org.opensearch.index.IndexSettings; import org.opensearch.index.shard.DocsStats; import org.opensearch.index.store.StoreStats; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -85,7 +86,8 @@ public TransportResizeAction( MetadataCreateIndexService createIndexService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Client client + Client client, + Tracer tracer ) { this( ResizeAction.NAME, @@ -95,7 +97,8 @@ public TransportResizeAction( createIndexService, actionFilters, indexNameExpressionResolver, - client + client, + tracer ); } @@ -107,9 +110,19 @@ protected TransportResizeAction( MetadataCreateIndexService createIndexService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Client client + Client client, + Tracer tracer ) { - super(actionName, transportService, clusterService, threadPool, actionFilters, ResizeRequest::new, indexNameExpressionResolver); + super( + actionName, + transportService, + clusterService, + threadPool, + actionFilters, + ResizeRequest::new, + indexNameExpressionResolver, + tracer + ); this.createIndexService = createIndexService; this.client = client; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/stats/TransportIndicesStatsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/stats/TransportIndicesStatsAction.java index 2b85b6d5d6b5b..4af1731c9eaf1 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/stats/TransportIndicesStatsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/stats/TransportIndicesStatsAction.java @@ -52,6 +52,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.ShardNotFoundException; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -73,7 +74,8 @@ public TransportIndicesStatsAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( IndicesStatsAction.NAME, @@ -82,7 +84,8 @@ public TransportIndicesStatsAction( actionFilters, indexNameExpressionResolver, IndicesStatsRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java index 30cb0cb3e5d00..5f00559cc35e8 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java @@ -46,6 +46,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -71,7 +72,8 @@ public TransportDeleteComponentTemplateAction( ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( DeleteComponentTemplateAction.NAME, @@ -80,7 +82,8 @@ public TransportDeleteComponentTemplateAction( threadPool, actionFilters, DeleteComponentTemplateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java index 27ea64809e3a7..11c45f4efa6fc 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java @@ -46,6 +46,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -71,7 +72,8 @@ public TransportDeleteComposableIndexTemplateAction( ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( DeleteComposableIndexTemplateAction.NAME, @@ -80,7 +82,8 @@ public TransportDeleteComposableIndexTemplateAction( threadPool, actionFilters, DeleteComposableIndexTemplateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java index c9542c7a58810..83352002ab274 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java @@ -46,6 +46,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -71,7 +72,8 @@ public TransportDeleteIndexTemplateAction( ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( DeleteIndexTemplateAction.NAME, @@ -80,7 +82,8 @@ public TransportDeleteIndexTemplateAction( threadPool, actionFilters, DeleteIndexTemplateRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java index e2594cd792cd3..9c3528f601868 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java @@ -45,6 +45,7 @@ import org.opensearch.common.regex.Regex; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -67,7 +68,8 @@ public TransportGetComponentTemplateAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( GetComponentTemplateAction.NAME, @@ -76,7 +78,8 @@ public TransportGetComponentTemplateAction( threadPool, actionFilters, GetComponentTemplateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java index b1ef32db7274f..4c28ee87b5431 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java @@ -45,6 +45,7 @@ import org.opensearch.common.regex.Regex; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -67,7 +68,8 @@ public TransportGetComposableIndexTemplateAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( GetComposableIndexTemplateAction.NAME, @@ -76,7 +78,8 @@ public TransportGetComposableIndexTemplateAction( threadPool, actionFilters, GetComposableIndexTemplateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java index 10b4975f7b9d0..c970c79e3bb25 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java @@ -43,6 +43,7 @@ import org.opensearch.common.regex.Regex; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -67,7 +68,8 @@ public TransportGetIndexTemplatesAction( ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( GetIndexTemplatesAction.NAME, @@ -76,7 +78,8 @@ public TransportGetIndexTemplatesAction( threadPool, actionFilters, GetIndexTemplatesRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java index c1a02d813ffb2..fd960f35ff949 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java @@ -58,6 +58,7 @@ import org.opensearch.index.mapper.DocumentMapper; import org.opensearch.index.mapper.MapperService; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -99,7 +100,8 @@ public TransportSimulateIndexTemplateAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, NamedXContentRegistry xContentRegistry, - IndicesService indicesService + IndicesService indicesService, + Tracer tracer ) { super( SimulateIndexTemplateAction.NAME, @@ -108,7 +110,8 @@ public TransportSimulateIndexTemplateAction( threadPool, actionFilters, SimulateIndexTemplateRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; this.xContentRegistry = xContentRegistry; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java index 6565896fd3db2..079d8fe158bff 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java @@ -49,6 +49,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -85,7 +86,8 @@ public TransportSimulateTemplateAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, NamedXContentRegistry xContentRegistry, - IndicesService indicesService + IndicesService indicesService, + Tracer tracer ) { super( SimulateTemplateAction.NAME, @@ -94,7 +96,8 @@ public TransportSimulateTemplateAction( threadPool, actionFilters, SimulateTemplateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; this.xContentRegistry = xContentRegistry; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java index 6eb87bee9ffa7..f92c278a9b346 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java @@ -49,6 +49,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -74,7 +75,8 @@ public TransportPutComponentTemplateAction( MetadataIndexTemplateService indexTemplateService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - IndexScopedSettings indexScopedSettings + IndexScopedSettings indexScopedSettings, + Tracer tracer ) { super( PutComponentTemplateAction.NAME, @@ -83,7 +85,8 @@ public TransportPutComponentTemplateAction( threadPool, actionFilters, PutComponentTemplateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; this.indexScopedSettings = indexScopedSettings; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java index 8a31c36d723b4..6921bd6fc9fae 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java @@ -45,6 +45,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -68,7 +69,8 @@ public TransportPutComposableIndexTemplateAction( ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( PutComposableIndexTemplateAction.NAME, @@ -77,7 +79,8 @@ public TransportPutComposableIndexTemplateAction( threadPool, actionFilters, PutComposableIndexTemplateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java index 4431949c2e42b..9694a175b84d0 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java @@ -49,6 +49,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -74,7 +75,8 @@ public TransportPutIndexTemplateAction( MetadataIndexTemplateService indexTemplateService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - IndexScopedSettings indexScopedSettings + IndexScopedSettings indexScopedSettings, + Tracer tracer ) { super( PutIndexTemplateAction.NAME, @@ -83,7 +85,8 @@ public TransportPutIndexTemplateAction( threadPool, actionFilters, PutIndexTemplateRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.indexTemplateService = indexTemplateService; this.indexScopedSettings = indexScopedSettings; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java index a171355fb2049..3135f60468aea 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java @@ -49,6 +49,7 @@ import org.opensearch.index.engine.Segment; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -73,7 +74,8 @@ public TransportUpgradeStatusAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( UpgradeStatusAction.NAME, @@ -82,7 +84,8 @@ public TransportUpgradeStatusAction( actionFilters, indexNameExpressionResolver, UpgradeStatusRequest::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java index 2dcd030093a67..af4920e0a7657 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java @@ -55,6 +55,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -82,7 +83,8 @@ public TransportUpgradeAction( IndicesService indicesService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - NodeClient client + NodeClient client, + Tracer tracer ) { super( UpgradeAction.NAME, @@ -91,7 +93,8 @@ public TransportUpgradeAction( actionFilters, indexNameExpressionResolver, UpgradeRequest::new, - ThreadPool.Names.FORCE_MERGE + ThreadPool.Names.FORCE_MERGE, + tracer ); this.indicesService = indicesService; this.client = client; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java index 286724d78bb63..ac424e544c307 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java @@ -48,6 +48,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -71,7 +72,8 @@ public TransportUpgradeSettingsAction( ThreadPool threadPool, MetadataUpdateSettingsService updateSettingsService, IndexNameExpressionResolver indexNameExpressionResolver, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { super( UpgradeSettingsAction.NAME, @@ -80,7 +82,8 @@ public TransportUpgradeSettingsAction( threadPool, actionFilters, UpgradeSettingsRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.updateSettingsService = updateSettingsService; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index 2b46fbcb9d105..7eca43c827e27 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -61,6 +61,7 @@ import org.opensearch.search.internal.SearchContext; import org.opensearch.search.internal.ShardSearchRequest; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -91,7 +92,8 @@ public TransportValidateQueryAction( TransportService transportService, SearchService searchService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ValidateQueryAction.NAME, @@ -101,7 +103,8 @@ public TransportValidateQueryAction( indexNameExpressionResolver, ValidateQueryRequest::new, ShardValidateQueryRequest::new, - ThreadPool.Names.SEARCH + ThreadPool.Names.SEARCH, + tracer ); this.searchService = searchService; } diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java index d8b7facc09df2..4728562b78451 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java @@ -83,6 +83,7 @@ import org.opensearch.ingest.IngestService; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.TransportService; @@ -143,7 +144,8 @@ public TransportBulkAction( IndexNameExpressionResolver indexNameExpressionResolver, AutoCreateIndex autoCreateIndex, IndexingPressureService indexingPressureService, - SystemIndices systemIndices + SystemIndices systemIndices, + Tracer tracer ) { this( threadPool, @@ -157,7 +159,8 @@ public TransportBulkAction( autoCreateIndex, indexingPressureService, systemIndices, - System::nanoTime + System::nanoTime, + tracer ); } @@ -173,9 +176,10 @@ public TransportBulkAction( AutoCreateIndex autoCreateIndex, IndexingPressureService indexingPressureService, SystemIndices systemIndices, - LongSupplier relativeTimeProvider + LongSupplier relativeTimeProvider, + Tracer tracer ) { - super(BulkAction.NAME, transportService, actionFilters, BulkRequest::new, ThreadPool.Names.SAME); + super(BulkAction.NAME, transportService, actionFilters, BulkRequest::new, ThreadPool.Names.SAME, tracer); Objects.requireNonNull(relativeTimeProvider); this.threadPool = threadPool; this.clusterService = clusterService; diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java index fddda0ef1f9a7..268a6ed6f85b8 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java @@ -99,6 +99,7 @@ import org.opensearch.indices.SystemIndices; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.TransportChannel; @@ -161,7 +162,8 @@ public TransportShardBulkAction( IndexingPressureService indexingPressureService, SegmentReplicationPressureService segmentReplicationPressureService, RemoteStorePressureService remoteStorePressureService, - SystemIndices systemIndices + SystemIndices systemIndices, + Tracer tracer ) { super( settings, @@ -177,7 +179,8 @@ public TransportShardBulkAction( EXECUTOR_NAME_FUNCTION, false, indexingPressureService, - systemIndices + systemIndices, + tracer ); this.updateHelper = updateHelper; this.mappingUpdatedAction = mappingUpdatedAction; diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java index 9b901dda24c2b..317ddef0a9236 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java @@ -43,6 +43,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; /** @@ -62,9 +63,10 @@ protected TransportSingleItemBulkWriteAction( TransportService transportService, ActionFilters actionFilters, Writeable.Reader requestReader, - TransportBulkAction bulkAction + TransportBulkAction bulkAction, + Tracer tracer ) { - super(actionName, transportService, actionFilters, requestReader); + super(actionName, transportService, actionFilters, requestReader, tracer); this.bulkAction = bulkAction; } diff --git a/server/src/main/java/org/opensearch/action/delete/TransportDeleteAction.java b/server/src/main/java/org/opensearch/action/delete/TransportDeleteAction.java index 039214459ac21..4ad8953f2778e 100644 --- a/server/src/main/java/org/opensearch/action/delete/TransportDeleteAction.java +++ b/server/src/main/java/org/opensearch/action/delete/TransportDeleteAction.java @@ -36,6 +36,7 @@ import org.opensearch.action.bulk.TransportSingleItemBulkWriteAction; import org.opensearch.action.support.ActionFilters; import org.opensearch.common.inject.Inject; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; /** @@ -49,7 +50,12 @@ public class TransportDeleteAction extends TransportSingleItemBulkWriteAction { @Inject - public TransportDeleteAction(TransportService transportService, ActionFilters actionFilters, TransportBulkAction bulkAction) { - super(DeleteAction.NAME, transportService, actionFilters, DeleteRequest::new, bulkAction); + public TransportDeleteAction( + TransportService transportService, + ActionFilters actionFilters, + TransportBulkAction bulkAction, + Tracer tracer + ) { + super(DeleteAction.NAME, transportService, actionFilters, DeleteRequest::new, bulkAction, tracer); } } diff --git a/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java b/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java index fb2ccc6ebbf12..97e2fe4a545d8 100644 --- a/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java +++ b/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java @@ -60,6 +60,7 @@ import org.opensearch.search.rescore.RescoreContext; import org.opensearch.search.rescore.Rescorer; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -83,7 +84,8 @@ public TransportExplainAction( TransportService transportService, SearchService searchService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ExplainAction.NAME, @@ -93,7 +95,8 @@ public TransportExplainAction( actionFilters, indexNameExpressionResolver, ExplainRequest::new, - ThreadPool.Names.GET + ThreadPool.Names.GET, + tracer ); this.searchService = searchService; } diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java index 4c9e10cba52e7..43ca6564adec1 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java @@ -44,6 +44,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.Strings; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.RemoteClusterAware; import org.opensearch.transport.RemoteClusterService; @@ -77,9 +78,10 @@ public TransportFieldCapabilitiesAction( ThreadPool threadPool, TransportFieldCapabilitiesIndexAction shardAction, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(FieldCapabilitiesAction.NAME, transportService, actionFilters, FieldCapabilitiesRequest::new); + super(FieldCapabilitiesAction.NAME, transportService, actionFilters, FieldCapabilitiesRequest::new, tracer); this.threadPool = threadPool; this.clusterService = clusterService; this.remoteClusterService = transportService.getRemoteClusterService(); diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java index 10bf4975311d6..16b48a722da45 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java @@ -68,6 +68,7 @@ import org.opensearch.search.internal.AliasFilter; import org.opensearch.search.internal.ShardSearchRequest; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportChannel; import org.opensearch.transport.TransportException; @@ -118,9 +119,10 @@ public TransportFieldCapabilitiesIndexAction( SearchService searchService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(ACTION_NAME, transportService, actionFilters, FieldCapabilitiesIndexRequest::new); + super(ACTION_NAME, transportService, actionFilters, FieldCapabilitiesIndexRequest::new, tracer); this.clusterService = clusterService; this.transportService = transportService; this.searchService = searchService; diff --git a/server/src/main/java/org/opensearch/action/get/TransportGetAction.java b/server/src/main/java/org/opensearch/action/get/TransportGetAction.java index 00a795c86356f..7a338e9196bd8 100644 --- a/server/src/main/java/org/opensearch/action/get/TransportGetAction.java +++ b/server/src/main/java/org/opensearch/action/get/TransportGetAction.java @@ -49,6 +49,7 @@ import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -70,7 +71,8 @@ public TransportGetAction( IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( GetAction.NAME, @@ -80,7 +82,8 @@ public TransportGetAction( actionFilters, indexNameExpressionResolver, GetRequest::new, - ThreadPool.Names.GET + ThreadPool.Names.GET, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java b/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java index 8bbfef381aea8..204e1b2326114 100644 --- a/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java +++ b/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java @@ -46,6 +46,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.index.shard.ShardId; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.HashMap; @@ -69,9 +70,10 @@ public TransportMultiGetAction( ClusterService clusterService, TransportShardMultiGetAction shardAction, ActionFilters actionFilters, - IndexNameExpressionResolver resolver + IndexNameExpressionResolver resolver, + Tracer tracer ) { - super(MultiGetAction.NAME, transportService, actionFilters, MultiGetRequest::new); + super(MultiGetAction.NAME, transportService, actionFilters, MultiGetRequest::new, tracer); this.clusterService = clusterService; this.shardAction = shardAction; this.indexNameExpressionResolver = resolver; diff --git a/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java b/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java index 27955098d96cd..5b6c12a44a705 100644 --- a/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java +++ b/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java @@ -48,6 +48,7 @@ import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -71,7 +72,8 @@ public TransportShardMultiGetAction( IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ACTION_NAME, @@ -81,7 +83,8 @@ public TransportShardMultiGetAction( actionFilters, indexNameExpressionResolver, MultiGetShardRequest::new, - ThreadPool.Names.GET + ThreadPool.Names.GET, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/index/TransportIndexAction.java b/server/src/main/java/org/opensearch/action/index/TransportIndexAction.java index fe4f80bf0c065..a53934ffd9766 100644 --- a/server/src/main/java/org/opensearch/action/index/TransportIndexAction.java +++ b/server/src/main/java/org/opensearch/action/index/TransportIndexAction.java @@ -36,6 +36,7 @@ import org.opensearch.action.bulk.TransportSingleItemBulkWriteAction; import org.opensearch.action.support.ActionFilters; import org.opensearch.common.inject.Inject; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; /** @@ -56,7 +57,12 @@ public class TransportIndexAction extends TransportSingleItemBulkWriteAction { @Inject - public TransportIndexAction(ActionFilters actionFilters, TransportService transportService, TransportBulkAction bulkAction) { - super(IndexAction.NAME, transportService, actionFilters, IndexRequest::new, bulkAction); + public TransportIndexAction( + ActionFilters actionFilters, + TransportService transportService, + TransportBulkAction bulkAction, + Tracer tracer + ) { + super(IndexAction.NAME, transportService, actionFilters, IndexRequest::new, bulkAction, tracer); } } diff --git a/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java index fe68f06d0d32e..145bd7bd73dff 100644 --- a/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java @@ -43,6 +43,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.ingest.IngestService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -63,7 +64,8 @@ public DeletePipelineTransportAction( IngestService ingestService, TransportService transportService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( DeletePipelineAction.NAME, @@ -72,7 +74,8 @@ public DeletePipelineTransportAction( threadPool, actionFilters, DeletePipelineRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.ingestService = ingestService; } diff --git a/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java index 80333c7346f92..28f59b23e18c4 100644 --- a/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java @@ -43,6 +43,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.ingest.IngestService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -61,7 +62,8 @@ public GetPipelineTransportAction( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( GetPipelineAction.NAME, @@ -70,7 +72,8 @@ public GetPipelineTransportAction( threadPool, actionFilters, GetPipelineRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java index e2d206e8c4f6d..4e96382e34d90 100644 --- a/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java @@ -49,6 +49,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.ingest.IngestInfo; import org.opensearch.ingest.IngestService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -75,7 +76,8 @@ public PutPipelineTransportAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, IngestService ingestService, - NodeClient client + NodeClient client, + Tracer tracer ) { super( PutPipelineAction.NAME, @@ -84,7 +86,8 @@ public PutPipelineTransportAction( threadPool, actionFilters, PutPipelineRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); // This client is only used to perform an internal implementation detail, // so uses an internal origin context rather than the user context diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java index 4753679d370af..6715e7aabbc05 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java @@ -40,6 +40,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.ingest.IngestService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -60,13 +61,15 @@ public SimulatePipelineTransportAction( ThreadPool threadPool, TransportService transportService, ActionFilters actionFilters, - IngestService ingestService + IngestService ingestService, + Tracer tracer ) { super( SimulatePipelineAction.NAME, transportService, actionFilters, - (Writeable.Reader) SimulatePipelineRequest::new + (Writeable.Reader) SimulatePipelineRequest::new, + tracer ); this.ingestService = ingestService; this.executionService = new SimulateExecutionService(threadPool); diff --git a/server/src/main/java/org/opensearch/action/main/TransportMainAction.java b/server/src/main/java/org/opensearch/action/main/TransportMainAction.java index b3a075233e754..23d07a56a889e 100644 --- a/server/src/main/java/org/opensearch/action/main/TransportMainAction.java +++ b/server/src/main/java/org/opensearch/action/main/TransportMainAction.java @@ -43,6 +43,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.node.Node; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; /** @@ -60,9 +61,10 @@ public TransportMainAction( Settings settings, TransportService transportService, ActionFilters actionFilters, - ClusterService clusterService + ClusterService clusterService, + Tracer tracer ) { - super(MainAction.NAME, transportService, actionFilters, MainRequest::new); + super(MainAction.NAME, transportService, actionFilters, MainRequest::new, tracer); this.nodeName = Node.NODE_NAME_SETTING.get(settings); this.clusterService = clusterService; } diff --git a/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java b/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java index 032fe83e2220b..9d60706d1f100 100644 --- a/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java +++ b/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java @@ -54,6 +54,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.indices.SystemIndices; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.TransportException; @@ -93,7 +94,8 @@ public TransportResyncReplicationAction( ShardStateAction shardStateAction, ActionFilters actionFilters, IndexingPressureService indexingPressureService, - SystemIndices systemIndices + SystemIndices systemIndices, + Tracer tracer ) { super( settings, @@ -109,7 +111,8 @@ public TransportResyncReplicationAction( EXECUTOR_NAME_FUNCTION, true, /* we should never reject resync because of thread pool capacity on primary */ indexingPressureService, - systemIndices + systemIndices, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java index ac83a6bb6b765..439b49fda808d 100644 --- a/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java @@ -19,6 +19,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.search.pipeline.SearchPipelineService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -40,7 +41,8 @@ public DeleteSearchPipelineTransportAction( SearchPipelineService searchPipelineService, TransportService transportService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( DeleteSearchPipelineAction.NAME, @@ -49,7 +51,8 @@ public DeleteSearchPipelineTransportAction( threadPool, actionFilters, DeleteSearchPipelineRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.searchPipelineService = searchPipelineService; } diff --git a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java index a7fcb8f1cfbae..30de832db4355 100644 --- a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java @@ -19,6 +19,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.search.pipeline.SearchPipelineService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -39,7 +40,8 @@ public GetSearchPipelineTransportAction( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( GetSearchPipelineAction.NAME, @@ -48,7 +50,8 @@ public GetSearchPipelineTransportAction( threadPool, actionFilters, GetSearchPipelineRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java index a92961cdc3fd9..999e60af857fd 100644 --- a/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java @@ -25,6 +25,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.search.pipeline.SearchPipelineInfo; import org.opensearch.search.pipeline.SearchPipelineService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -51,7 +52,8 @@ public PutSearchPipelineTransportAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, SearchPipelineService searchPipelineService, - NodeClient client + NodeClient client, + Tracer tracer ) { super( PutSearchPipelineAction.NAME, @@ -60,7 +62,8 @@ public PutSearchPipelineTransportAction( threadPool, actionFilters, PutSearchPipelineRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.client = new OriginSettingClient(client, SEARCH_PIPELINE_ORIGIN); this.searchPipelineService = searchPipelineService; diff --git a/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java b/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java index e67005eb1fb87..ae763531777e8 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java @@ -39,6 +39,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; /** @@ -58,9 +59,10 @@ public TransportClearScrollAction( ClusterService clusterService, ActionFilters actionFilters, SearchTransportService searchTransportService, - NamedWriteableRegistry namedWriteableRegistry + NamedWriteableRegistry namedWriteableRegistry, + Tracer tracer ) { - super(ClearScrollAction.NAME, transportService, actionFilters, ClearScrollRequest::new); + super(ClearScrollAction.NAME, transportService, actionFilters, ClearScrollRequest::new, tracer); this.clusterService = clusterService; this.searchTransportService = searchTransportService; this.namedWriteableRegistry = namedWriteableRegistry; diff --git a/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java b/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java index baa113997f243..99dcfee0f7abe 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java @@ -23,6 +23,7 @@ import org.opensearch.search.SearchPhaseResult; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -50,9 +51,10 @@ public TransportCreatePitAction( ClusterService clusterService, TransportSearchAction transportSearchAction, NamedWriteableRegistry namedWriteableRegistry, - CreatePitController createPitController + CreatePitController createPitController, + Tracer tracer ) { - super(CreatePitAction.NAME, transportService, actionFilters, in -> new CreatePitRequest(in)); + super(CreatePitAction.NAME, transportService, actionFilters, in -> new CreatePitRequest(in), tracer); this.transportService = transportService; this.searchTransportService = searchTransportService; this.clusterService = clusterService; diff --git a/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java b/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java index 614d576324026..4cc5513d5253b 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java @@ -14,6 +14,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.ArrayList; @@ -36,9 +37,10 @@ public TransportDeletePitAction( TransportService transportService, ActionFilters actionFilters, NamedWriteableRegistry namedWriteableRegistry, - PitService pitService + PitService pitService, + Tracer tracer ) { - super(DeletePitAction.NAME, transportService, actionFilters, DeletePitRequest::new); + super(DeletePitAction.NAME, transportService, actionFilters, DeletePitRequest::new, tracer); this.namedWriteableRegistry = namedWriteableRegistry; this.pitService = pitService; } diff --git a/server/src/main/java/org/opensearch/action/search/TransportGetAllPitsAction.java b/server/src/main/java/org/opensearch/action/search/TransportGetAllPitsAction.java index 561ca034da469..07c2d7cde9e64 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportGetAllPitsAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportGetAllPitsAction.java @@ -15,6 +15,7 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.search.SearchService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -37,7 +38,8 @@ public TransportGetAllPitsAction( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - SearchService searchService + SearchService searchService, + Tracer tracer ) { super( GetAllPitsAction.NAME, @@ -48,7 +50,8 @@ public TransportGetAllPitsAction( GetAllPitNodesRequest::new, GetAllPitNodeRequest::new, ThreadPool.Names.SAME, - GetAllPitNodeResponse.class + GetAllPitNodeResponse.class, + tracer ); this.searchService = searchService; } diff --git a/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java b/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java index 146b4010af4b3..9f6942f276ad7 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java @@ -45,6 +45,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -74,9 +75,16 @@ public TransportMultiSearchAction( TransportService transportService, ClusterService clusterService, ActionFilters actionFilters, - NodeClient client + NodeClient client, + Tracer tracer ) { - super(MultiSearchAction.NAME, transportService, actionFilters, (Writeable.Reader) MultiSearchRequest::new); + super( + MultiSearchAction.NAME, + transportService, + actionFilters, + (Writeable.Reader) MultiSearchRequest::new, + tracer + ); this.threadPool = threadPool; this.clusterService = clusterService; this.allocatedProcessors = OpenSearchExecutors.allocatedProcessors(settings); @@ -91,9 +99,16 @@ public TransportMultiSearchAction( ClusterService clusterService, int allocatedProcessors, LongSupplier relativeTimeProvider, - NodeClient client + NodeClient client, + Tracer tracer ) { - super(MultiSearchAction.NAME, transportService, actionFilters, (Writeable.Reader) MultiSearchRequest::new); + super( + MultiSearchAction.NAME, + transportService, + actionFilters, + (Writeable.Reader) MultiSearchRequest::new, + tracer + ); this.threadPool = threadPool; this.clusterService = clusterService; this.allocatedProcessors = allocatedProcessors; diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java index 25ec0fc57d19f..bdf303e762b0b 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java @@ -87,6 +87,7 @@ import org.opensearch.search.profile.SearchProfileShardResults; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.RemoteClusterAware; import org.opensearch.transport.RemoteClusterService; @@ -170,9 +171,10 @@ public TransportSearchAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, NamedWriteableRegistry namedWriteableRegistry, - SearchPipelineService searchPipelineService + SearchPipelineService searchPipelineService, + Tracer tracer ) { - super(SearchAction.NAME, transportService, actionFilters, (Writeable.Reader) SearchRequest::new); + super(SearchAction.NAME, transportService, actionFilters, (Writeable.Reader) SearchRequest::new, tracer); this.client = client; this.threadPool = threadPool; this.circuitBreaker = circuitBreakerService.getBreaker(CircuitBreaker.REQUEST); diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java b/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java index 4713d03c93bac..84b6fa18d6414 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java @@ -39,6 +39,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; /** @@ -58,9 +59,16 @@ public TransportSearchScrollAction( ClusterService clusterService, ActionFilters actionFilters, SearchTransportService searchTransportService, - SearchPhaseController searchPhaseController + SearchPhaseController searchPhaseController, + Tracer tracer ) { - super(SearchScrollAction.NAME, transportService, actionFilters, (Writeable.Reader) SearchScrollRequest::new); + super( + SearchScrollAction.NAME, + transportService, + actionFilters, + (Writeable.Reader) SearchScrollRequest::new, + tracer + ); this.clusterService = clusterService; this.searchTransportService = searchTransportService; this.searchPhaseController = searchPhaseController; diff --git a/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java b/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java index 786d8cfb6fa1d..3768711a49f74 100644 --- a/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java +++ b/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java @@ -35,6 +35,7 @@ import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportChannel; import org.opensearch.transport.TransportRequestHandler; @@ -53,9 +54,10 @@ protected HandledTransportAction( String actionName, TransportService transportService, ActionFilters actionFilters, - Writeable.Reader requestReader + Writeable.Reader requestReader, + Tracer tracer ) { - this(actionName, true, transportService, actionFilters, requestReader); + this(actionName, true, transportService, actionFilters, requestReader, tracer); } protected HandledTransportAction( @@ -63,9 +65,10 @@ protected HandledTransportAction( TransportService transportService, ActionFilters actionFilters, Writeable.Reader requestReader, - String executor + String executor, + Tracer tracer ) { - this(actionName, true, transportService, actionFilters, requestReader, executor); + this(actionName, true, transportService, actionFilters, requestReader, executor, tracer); } protected HandledTransportAction( @@ -73,9 +76,10 @@ protected HandledTransportAction( boolean canTripCircuitBreaker, TransportService transportService, ActionFilters actionFilters, - Writeable.Reader requestReader + Writeable.Reader requestReader, + Tracer tracer ) { - this(actionName, canTripCircuitBreaker, transportService, actionFilters, requestReader, ThreadPool.Names.SAME); + this(actionName, canTripCircuitBreaker, transportService, actionFilters, requestReader, ThreadPool.Names.SAME, tracer); } protected HandledTransportAction( @@ -84,9 +88,10 @@ protected HandledTransportAction( TransportService transportService, ActionFilters actionFilters, Writeable.Reader requestReader, - String executor + String executor, + Tracer tracer ) { - super(actionName, actionFilters, transportService.getTaskManager()); + super(actionName, actionFilters, transportService.getTaskManager(), tracer); transportService.registerRequestHandler(actionName, executor, false, canTripCircuitBreaker, requestReader, new TransportHandler()); } diff --git a/server/src/main/java/org/opensearch/action/support/TransportAction.java b/server/src/main/java/org/opensearch/action/support/TransportAction.java index daa11c2d7d80f..3e3dd61acc125 100644 --- a/server/src/main/java/org/opensearch/action/support/TransportAction.java +++ b/server/src/main/java/org/opensearch/action/support/TransportAction.java @@ -46,6 +46,11 @@ import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskListener; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.Span; +import org.opensearch.telemetry.tracing.SpanBuilder; +import org.opensearch.telemetry.tracing.SpanScope; +import org.opensearch.telemetry.tracing.Tracer; +import org.opensearch.telemetry.tracing.listener.TraceableActionListener; import java.util.concurrent.atomic.AtomicInteger; @@ -59,16 +64,18 @@ public abstract class TransportAction listener) { - ActionRequestValidationException validationException = request.validate(); - if (validationException != null) { - listener.onFailure(validationException); - return; - } + final Span span = tracer.startSpan(SpanBuilder.from(task, actionName)); + try (final SpanScope spanScope = tracer.withSpanInScope(span)) { + listener = TraceableActionListener.create(listener, span, tracer); + ActionRequestValidationException validationException = request.validate(); + if (validationException != null) { + listener.onFailure(validationException); + return; + } - if (task != null && request.getShouldStoreResult()) { - listener = new TaskResultStoringActionListener<>(taskManager, task, listener); - } + if (task != null && request.getShouldStoreResult()) { + listener = new TaskResultStoringActionListener<>(taskManager, task, listener); + } - RequestFilterChain requestFilterChain = new RequestFilterChain<>(this, logger); - requestFilterChain.proceed(task, actionName, request, listener); + RequestFilterChain requestFilterChain = new RequestFilterChain<>(this, logger); + requestFilterChain.proceed(task, actionName, request, listener); + } catch (Exception e) { + // Some validation scenarios throws the RuntimeException other than validationException. + span.setError(e); + span.endSpan(); + throw e; + } } protected abstract void doExecute(Task task, Request request, ActionListener listener); diff --git a/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java b/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java index 8bf8555194976..0e1f3a4db3bf3 100644 --- a/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java +++ b/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java @@ -53,6 +53,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportChannel; import org.opensearch.transport.TransportException; @@ -90,9 +91,10 @@ protected TransportBroadcastAction( IndexNameExpressionResolver indexNameExpressionResolver, Writeable.Reader request, Writeable.Reader shardRequest, - String shardExecutor + String shardExecutor, + Tracer tracer ) { - super(actionName, transportService, actionFilters, request); + super(actionName, transportService, actionFilters, request, tracer); this.clusterService = clusterService; this.transportService = transportService; this.indexNameExpressionResolver = indexNameExpressionResolver; diff --git a/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java b/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java index c08cfb7af0e3d..ce8248c183a2b 100644 --- a/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java @@ -58,6 +58,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.transport.TransportResponse; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.NodeShouldNotConnectException; import org.opensearch.transport.TransportChannel; @@ -107,9 +108,10 @@ public TransportBroadcastByNodeAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, Writeable.Reader request, - String executor + String executor, + Tracer tracer ) { - this(actionName, clusterService, transportService, actionFilters, indexNameExpressionResolver, request, executor, true); + this(actionName, clusterService, transportService, actionFilters, indexNameExpressionResolver, request, executor, true, tracer); } public TransportBroadcastByNodeAction( @@ -120,9 +122,10 @@ public TransportBroadcastByNodeAction( IndexNameExpressionResolver indexNameExpressionResolver, Writeable.Reader request, String executor, - boolean canTripCircuitBreaker + boolean canTripCircuitBreaker, + Tracer tracer ) { - super(actionName, canTripCircuitBreaker, transportService, actionFilters, request); + super(actionName, canTripCircuitBreaker, transportService, actionFilters, request, tracer); this.clusterService = clusterService; this.transportService = transportService; diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java index 536ddcdd402e2..e80ca7b9a5d32 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java @@ -62,6 +62,7 @@ import org.opensearch.discovery.ClusterManagerNotDiscoveredException; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.ConnectTransportException; import org.opensearch.transport.RemoteTransportException; @@ -95,9 +96,10 @@ protected TransportClusterManagerNodeAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - this(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver); + this(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver, tracer); } protected TransportClusterManagerNodeAction( @@ -108,9 +110,10 @@ protected TransportClusterManagerNodeAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(actionName, canTripCircuitBreaker, transportService, actionFilters, request); + super(actionName, canTripCircuitBreaker, transportService, actionFilters, request, tracer); this.transportService = transportService; this.clusterService = clusterService; this.threadPool = threadPool; diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java index d8cd5af992028..7aff84ce0bff1 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java @@ -37,6 +37,7 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -57,9 +58,10 @@ protected TransportClusterManagerNodeReadAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - this(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver); + this(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver, tracer); } protected TransportClusterManagerNodeReadAction( @@ -70,7 +72,8 @@ protected TransportClusterManagerNodeReadAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( actionName, @@ -80,7 +83,8 @@ protected TransportClusterManagerNodeReadAction( threadPool, actionFilters, request, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java b/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java index 65f00a4731ab5..36ea631a25edb 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java @@ -41,6 +41,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -59,9 +60,10 @@ public TransportClusterInfoAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(actionName, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver); + super(actionName, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver, tracer); } @Override diff --git a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java index eec7965bfed02..16df41fcf6fa8 100644 --- a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java @@ -38,6 +38,7 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -58,9 +59,10 @@ protected TransportMasterNodeAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver); + super(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver, tracer); } protected TransportMasterNodeAction( @@ -71,7 +73,8 @@ protected TransportMasterNodeAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( actionName, @@ -81,7 +84,8 @@ protected TransportMasterNodeAction( threadPool, actionFilters, request, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java index b95459971737f..dd0911622a24f 100644 --- a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java @@ -38,6 +38,7 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -59,9 +60,10 @@ protected TransportMasterNodeReadAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver); + super(actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver, tracer); } protected TransportMasterNodeReadAction( @@ -72,7 +74,8 @@ protected TransportMasterNodeReadAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( actionName, @@ -82,7 +85,8 @@ protected TransportMasterNodeReadAction( threadPool, actionFilters, request, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java b/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java index 2653e3a658674..6c998c9de8a28 100644 --- a/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java @@ -36,6 +36,7 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -54,9 +55,10 @@ public TransportClusterInfoAction( ThreadPool threadPool, ActionFilters actionFilters, Writeable.Reader request, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(actionName, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver); + super(actionName, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver, tracer); } } diff --git a/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java b/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java index 9a1a28dd70636..78e76a409c65a 100644 --- a/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java +++ b/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java @@ -44,6 +44,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.NodeShouldNotConnectException; import org.opensearch.transport.TransportChannel; @@ -103,9 +104,10 @@ protected TransportNodesAction( Writeable.Reader nodeRequest, String nodeExecutor, String finalExecutor, - Class nodeResponseClass + Class nodeResponseClass, + Tracer tracer ) { - super(actionName, transportService, actionFilters, request); + super(actionName, transportService, actionFilters, request, tracer); this.threadPool = threadPool; this.clusterService = Objects.requireNonNull(clusterService); this.transportService = Objects.requireNonNull(transportService); @@ -118,7 +120,7 @@ protected TransportNodesAction( /** * Same as {@link #TransportNodesAction(String, ThreadPool, ClusterService, TransportService, ActionFilters, Writeable.Reader, - * Writeable.Reader, String, String, Class)} but executes final response collection on the transport thread except for when the final + * Writeable.Reader, String, String, Class, Tracer)} but executes final response collection on the transport thread except for when the final * node response is received from the local node, in which case {@code nodeExecutor} is used. * This constructor should only be used for actions for which the creation of the final response is fast enough to be safely executed * on a transport thread. @@ -132,7 +134,8 @@ protected TransportNodesAction( Writeable.Reader request, Writeable.Reader nodeRequest, String nodeExecutor, - Class nodeResponseClass + Class nodeResponseClass, + Tracer tracer ) { this( actionName, @@ -144,7 +147,8 @@ protected TransportNodesAction( nodeRequest, nodeExecutor, ThreadPool.Names.SAME, - nodeResponseClass + nodeResponseClass, + tracer ); } diff --git a/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java b/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java index e235adbc162fc..4c1787ec794e0 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java +++ b/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java @@ -50,6 +50,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.index.shard.ShardId; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.ArrayList; @@ -80,9 +81,10 @@ public TransportBroadcastReplicationAction( TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - TransportReplicationAction replicatedBroadcastShardAction + TransportReplicationAction replicatedBroadcastShardAction, + Tracer tracer ) { - super(name, transportService, actionFilters, requestReader); + super(name, transportService, actionFilters, requestReader, tracer); this.replicatedBroadcastShardAction = replicatedBroadcastShardAction; this.clusterService = clusterService; this.indexNameExpressionResolver = indexNameExpressionResolver; diff --git a/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java b/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java index de5a92fdcc4b1..dae670e40f161 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java +++ b/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java @@ -83,6 +83,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.ConnectTransportException; import org.opensearch.transport.TransportChannel; @@ -162,7 +163,8 @@ protected TransportReplicationAction( ActionFilters actionFilters, Writeable.Reader requestReader, Writeable.Reader replicaRequestReader, - String executor + String executor, + Tracer tracer ) { this( settings, @@ -177,7 +179,8 @@ protected TransportReplicationAction( replicaRequestReader, executor, false, - false + false, + tracer ); } @@ -194,9 +197,10 @@ protected TransportReplicationAction( Writeable.Reader replicaRequestReader, String executor, boolean syncGlobalCheckpointAfterOperation, - boolean forceExecutionOnPrimary + boolean forceExecutionOnPrimary, + Tracer tracer ) { - super(actionName, actionFilters, transportService.getTaskManager()); + super(actionName, actionFilters, transportService.getTaskManager(), tracer); this.threadPool = threadPool; this.transportService = transportService; this.clusterService = clusterService; diff --git a/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java b/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java index 62cbfbde9780a..62aa37c785ef5 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java +++ b/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java @@ -59,6 +59,7 @@ import org.opensearch.index.translog.Translog.Location; import org.opensearch.indices.IndicesService; import org.opensearch.indices.SystemIndices; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -97,7 +98,8 @@ protected TransportWriteAction( Function executorFunction, boolean forceExecutionOnPrimary, IndexingPressureService indexingPressureService, - SystemIndices systemIndices + SystemIndices systemIndices, + Tracer tracer ) { // We pass ThreadPool.Names.SAME to the super class as we control the dispatching to the // ThreadPool.Names.WRITE/ThreadPool.Names.SYSTEM_WRITE thread pools in this class. @@ -114,7 +116,8 @@ protected TransportWriteAction( replicaRequest, ThreadPool.Names.SAME, true, - forceExecutionOnPrimary + forceExecutionOnPrimary, + tracer ); this.executorFunction = executorFunction; this.indexingPressureService = indexingPressureService; diff --git a/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java b/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java index 21d4ba726e86f..d1f04f8e862a2 100644 --- a/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java +++ b/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java @@ -55,6 +55,7 @@ import org.opensearch.index.IndexNotFoundException; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.ConnectTransportException; @@ -92,9 +93,10 @@ protected TransportInstanceSingleOperationAction( TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Writeable.Reader request + Writeable.Reader request, + Tracer tracer ) { - super(actionName, transportService, actionFilters, request); + super(actionName, transportService, actionFilters, request, tracer); this.threadPool = threadPool; this.clusterService = clusterService; this.transportService = transportService; diff --git a/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java b/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java index df91559a2f8cb..d8ed9bd4a05e2 100644 --- a/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java +++ b/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java @@ -57,6 +57,7 @@ import org.opensearch.core.common.logging.LoggerMessageFormat; import org.opensearch.core.index.shard.ShardId; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportChannel; import org.opensearch.transport.TransportException; @@ -94,9 +95,10 @@ protected TransportSingleShardAction( ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, Writeable.Reader request, - String executor + String executor, + Tracer tracer ) { - super(actionName, actionFilters, transportService.getTaskManager()); + super(actionName, actionFilters, transportService.getTaskManager(), tracer); this.threadPool = threadPool; this.clusterService = clusterService; this.transportService = transportService; diff --git a/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java b/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java index f33d7161660a3..541aba6bc16a5 100644 --- a/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java +++ b/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java @@ -51,6 +51,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.transport.TransportResponse; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.NodeShouldNotConnectException; import org.opensearch.transport.TransportChannel; @@ -98,9 +99,10 @@ protected TransportTasksAction( Writeable.Reader requestReader, Writeable.Reader responsesReader, Writeable.Reader responseReader, - String nodeExecutor + String nodeExecutor, + Tracer tracer ) { - super(actionName, transportService, actionFilters, requestReader); + super(actionName, transportService, actionFilters, requestReader, tracer); this.clusterService = clusterService; this.transportService = transportService; this.transportNodeAction = actionName + "[n]"; diff --git a/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java b/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java index 0364f36106cb0..7d68b5c2f0ad8 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java +++ b/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java @@ -45,6 +45,7 @@ import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.IndexNotFoundException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.util.HashMap; @@ -68,9 +69,10 @@ public TransportMultiTermVectorsAction( ClusterService clusterService, TransportShardMultiTermsVectorAction shardAction, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { - super(MultiTermVectorsAction.NAME, transportService, actionFilters, MultiTermVectorsRequest::new); + super(MultiTermVectorsAction.NAME, transportService, actionFilters, MultiTermVectorsRequest::new, tracer); this.clusterService = clusterService; this.shardAction = shardAction; this.indexNameExpressionResolver = indexNameExpressionResolver; diff --git a/server/src/main/java/org/opensearch/action/termvectors/TransportShardMultiTermsVectorAction.java b/server/src/main/java/org/opensearch/action/termvectors/TransportShardMultiTermsVectorAction.java index a298e267cca37..47f1d47fed6d4 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/TransportShardMultiTermsVectorAction.java +++ b/server/src/main/java/org/opensearch/action/termvectors/TransportShardMultiTermsVectorAction.java @@ -47,6 +47,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.index.termvectors.TermVectorsService; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -70,7 +71,8 @@ public TransportShardMultiTermsVectorAction( IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( ACTION_NAME, @@ -80,7 +82,8 @@ public TransportShardMultiTermsVectorAction( actionFilters, indexNameExpressionResolver, MultiTermVectorsShardRequest::new, - ThreadPool.Names.GET + ThreadPool.Names.GET, + tracer ); this.indicesService = indicesService; } diff --git a/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java b/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java index b7e8a29bd4027..c3fb1b2bd26f6 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java +++ b/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java @@ -49,6 +49,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.index.termvectors.TermVectorsService; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -70,7 +71,8 @@ public TransportTermVectorsAction( IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( TermVectorsAction.NAME, @@ -80,7 +82,8 @@ public TransportTermVectorsAction( actionFilters, indexNameExpressionResolver, TermVectorsRequest::new, - ThreadPool.Names.GET + ThreadPool.Names.GET, + tracer ); this.indicesService = indicesService; diff --git a/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java index 95735f71a38e7..1b90bb7061fa9 100644 --- a/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java @@ -69,6 +69,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.TransportService; @@ -104,7 +105,8 @@ public TransportUpdateAction( IndexNameExpressionResolver indexNameExpressionResolver, IndicesService indicesService, AutoCreateIndex autoCreateIndex, - NodeClient client + NodeClient client, + Tracer tracer ) { super( UpdateAction.NAME, @@ -113,7 +115,8 @@ public TransportUpdateAction( transportService, actionFilters, indexNameExpressionResolver, - UpdateRequest::new + UpdateRequest::new, + tracer ); this.updateHelper = updateHelper; this.indicesService = indicesService; diff --git a/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java b/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java index 61a6e2faa09e0..89a851c02a057 100644 --- a/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java +++ b/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java @@ -41,6 +41,7 @@ import org.opensearch.extensions.settings.CustomSettingsRequestHandler; import org.opensearch.extensions.settings.RegisterCustomSettingsRequest; import org.opensearch.identity.IdentityService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.ConnectTransportException; import org.opensearch.transport.TransportException; @@ -143,7 +144,8 @@ public void initializeServicesAndRestHandler( ClusterService clusterService, Settings initialEnvironmentSettings, NodeClient client, - IdentityService identityService + IdentityService identityService, + Tracer tracer ) { this.restActionsRequestHandler = new RestActionsRequestHandler( actionModule.getRestController(), @@ -167,7 +169,8 @@ public void initializeServicesAndRestHandler( transportService, client, actionModule, - this + this, + tracer ); registerRequestHandler(actionModule.getDynamicActionRegistry()); } diff --git a/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java b/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java index 34aa3ec1367a7..6d499d1594a82 100644 --- a/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java +++ b/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java @@ -17,6 +17,7 @@ import org.opensearch.extensions.action.ExtensionActionResponse; import org.opensearch.extensions.action.RemoteExtensionActionResponse; import org.opensearch.identity.IdentityService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; import java.io.IOException; @@ -42,7 +43,8 @@ public void initializeServicesAndRestHandler( ClusterService clusterService, Settings initialEnvironmentSettings, NodeClient client, - IdentityService identityService + IdentityService identityService, + Tracer tracer ) { // no-op } diff --git a/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java b/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java index f5ec472c3edc4..d9a6880763e18 100644 --- a/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java +++ b/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java @@ -16,6 +16,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.extensions.ExtensionsManager; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.transport.TransportService; /** @@ -33,9 +34,10 @@ public ExtensionProxyTransportAction( TransportService transportService, ActionFilters actionFilters, ClusterService clusterService, - ExtensionsManager extensionsManager + ExtensionsManager extensionsManager, + Tracer tracer ) { - super(ExtensionProxyAction.NAME, transportService, actionFilters, ExtensionActionRequest::new); + super(ExtensionProxyAction.NAME, transportService, actionFilters, ExtensionActionRequest::new, tracer); this.extensionsManager = extensionsManager; } diff --git a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java index 50a3e0036cbb1..2be297fc77115 100644 --- a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java +++ b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java @@ -14,6 +14,7 @@ import org.opensearch.extensions.ExtensionsManager; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.Tracer; /** * A proxy transport action used to proxy a transport request from an extension to execute on another extension @@ -28,9 +29,10 @@ public ExtensionTransportAction( String actionName, ActionFilters actionFilters, TaskManager taskManager, - ExtensionsManager extensionsManager + ExtensionsManager extensionsManager, + Tracer tracer ) { - super(actionName, actionFilters, taskManager); + super(actionName, actionFilters, taskManager, tracer); this.extensionsManager = extensionsManager; } diff --git a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java index ac60df1b73764..bc46ea64d31b6 100644 --- a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java +++ b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java @@ -20,6 +20,7 @@ import org.opensearch.extensions.AcknowledgedResponse; import org.opensearch.extensions.DiscoveryExtensionNode; import org.opensearch.extensions.ExtensionsManager; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.ActionNotFoundTransportException; import org.opensearch.transport.TransportException; @@ -50,13 +51,15 @@ public class ExtensionTransportActionsHandler { private final ActionFilters actionFilters; private final DynamicActionRegistry dynamicActionRegistry; private final ExtensionsManager extensionsManager; + private final Tracer tracer; public ExtensionTransportActionsHandler( Map extensionIdMap, TransportService transportService, NodeClient client, ActionModule actionModule, - ExtensionsManager extensionsManager + ExtensionsManager extensionsManager, + Tracer tracer ) { this.extensionIdMap = extensionIdMap; this.transportService = transportService; @@ -64,6 +67,7 @@ public ExtensionTransportActionsHandler( this.actionFilters = actionModule.getActionFilters(); this.dynamicActionRegistry = actionModule.getDynamicActionRegistry(); this.extensionsManager = extensionsManager; + this.tracer = tracer; } /** @@ -81,7 +85,7 @@ void registerAction(String action, String uniqueId) throws IllegalArgumentExcept // Register the action in the action module's dynamic actions map dynamicActionRegistry.registerDynamicAction( new ExtensionAction(uniqueId, action), - new ExtensionTransportAction(action, actionFilters, transportService.getTaskManager(), extensionsManager) + new ExtensionTransportAction(action, actionFilters, transportService.getTaskManager(), extensionsManager, tracer) ); } diff --git a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java index 647e3632ea0ca..53cc885482345 100644 --- a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java +++ b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java @@ -50,6 +50,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -79,7 +80,8 @@ public TransportNodesListGatewayMetaState( ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, - GatewayMetaState metaState + GatewayMetaState metaState, + Tracer tracer ) { super( ACTION_NAME, @@ -90,7 +92,8 @@ public TransportNodesListGatewayMetaState( Request::new, NodeRequest::new, ThreadPool.Names.GENERIC, - NodeGatewayMetaState.class + NodeGatewayMetaState.class, + tracer ); this.metaState = metaState; } diff --git a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java index a47893f37a97c..44018bf79ff14 100644 --- a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java +++ b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java @@ -62,6 +62,7 @@ import org.opensearch.index.store.Store; import org.opensearch.indices.IndicesService; import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -104,7 +105,8 @@ public TransportNodesListGatewayStartedShards( ActionFilters actionFilters, NodeEnvironment env, IndicesService indicesService, - NamedXContentRegistry namedXContentRegistry + NamedXContentRegistry namedXContentRegistry, + Tracer tracer ) { super( ACTION_NAME, @@ -115,7 +117,8 @@ public TransportNodesListGatewayStartedShards( Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STARTED, - NodeGatewayStartedShards.class + NodeGatewayStartedShards.class, + tracer ); this.settings = settings; this.nodeEnv = env; diff --git a/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java b/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java index ca1dfe2d5ad01..e4f0f7edca62d 100644 --- a/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java +++ b/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java @@ -51,6 +51,7 @@ import org.opensearch.index.shard.IndexShardClosedException; import org.opensearch.index.translog.Translog; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -78,7 +79,8 @@ public GlobalCheckpointSyncAction( final IndicesService indicesService, final ThreadPool threadPool, final ShardStateAction shardStateAction, - final ActionFilters actionFilters + final ActionFilters actionFilters, + final Tracer tracer ) { super( settings, @@ -91,7 +93,8 @@ public GlobalCheckpointSyncAction( actionFilters, Request::new, Request::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); } diff --git a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java index db8b06489f2ae..dd851b4f6d9d9 100644 --- a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java +++ b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java @@ -52,6 +52,7 @@ import org.opensearch.index.IndexService; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -89,7 +90,8 @@ abstract static class TransportRetentionLeaseAction> extend final ActionFilters actionFilters, final IndexNameExpressionResolver indexNameExpressionResolver, final IndicesService indicesService, - final Writeable.Reader requestSupplier + final Writeable.Reader requestSupplier, + final Tracer tracer ) { super( name, @@ -99,7 +101,8 @@ abstract static class TransportRetentionLeaseAction> extend actionFilters, indexNameExpressionResolver, requestSupplier, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); this.indicesService = Objects.requireNonNull(indicesService); } @@ -167,7 +170,8 @@ public TransportAction( final TransportService transportService, final ActionFilters actionFilters, final IndexNameExpressionResolver indexNameExpressionResolver, - final IndicesService indicesService + final IndicesService indicesService, + final Tracer tracer ) { super( ACTION_NAME, @@ -177,7 +181,8 @@ public TransportAction( actionFilters, indexNameExpressionResolver, indicesService, - AddRequest::new + AddRequest::new, + tracer ); } @@ -227,7 +232,8 @@ public TransportAction( final TransportService transportService, final ActionFilters actionFilters, final IndexNameExpressionResolver indexNameExpressionResolver, - final IndicesService indicesService + final IndicesService indicesService, + final Tracer tracer ) { super( ACTION_NAME, @@ -237,7 +243,8 @@ public TransportAction( actionFilters, indexNameExpressionResolver, indicesService, - RenewRequest::new + RenewRequest::new, + tracer ); } @@ -278,7 +285,8 @@ public TransportAction( final TransportService transportService, final ActionFilters actionFilters, final IndexNameExpressionResolver indexNameExpressionResolver, - final IndicesService indicesService + final IndicesService indicesService, + final Tracer tracer ) { super( ACTION_NAME, @@ -288,7 +296,8 @@ public TransportAction( actionFilters, indexNameExpressionResolver, indicesService, - RemoveRequest::new + RemoveRequest::new, + tracer ); } diff --git a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java index 5fa0a1a6459e7..3c13ad863b6ef 100644 --- a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java +++ b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java @@ -59,6 +59,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; @@ -96,7 +97,8 @@ public RetentionLeaseBackgroundSyncAction( final IndicesService indicesService, final ThreadPool threadPool, final ShardStateAction shardStateAction, - final ActionFilters actionFilters + final ActionFilters actionFilters, + final Tracer tracer ) { super( settings, @@ -109,7 +111,8 @@ public RetentionLeaseBackgroundSyncAction( actionFilters, Request::new, Request::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); } diff --git a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java index f74fc7eefe65c..ca3c7e1d49700 100644 --- a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java +++ b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java @@ -62,6 +62,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.indices.SystemIndices; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; @@ -99,7 +100,8 @@ public RetentionLeaseSyncAction( final ShardStateAction shardStateAction, final ActionFilters actionFilters, final IndexingPressureService indexingPressureService, - final SystemIndices systemIndices + final SystemIndices systemIndices, + final Tracer tracer ) { super( settings, @@ -115,7 +117,8 @@ public RetentionLeaseSyncAction( ignore -> ThreadPool.Names.MANAGEMENT, false, indexingPressureService, - systemIndices + systemIndices, + tracer ); } diff --git a/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java b/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java index 76f0d333db977..ff236799c73bb 100644 --- a/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java +++ b/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java @@ -34,6 +34,7 @@ import org.opensearch.indices.replication.common.ReplicationTimer; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; @@ -67,7 +68,8 @@ public PublishCheckpointAction( ThreadPool threadPool, ShardStateAction shardStateAction, ActionFilters actionFilters, - SegmentReplicationTargetService targetService + SegmentReplicationTargetService targetService, + Tracer tracer ) { super( settings, @@ -80,7 +82,8 @@ public PublishCheckpointAction( actionFilters, PublishCheckpointRequest::new, PublishCheckpointRequest::new, - ThreadPool.Names.REFRESH + ThreadPool.Names.REFRESH, + tracer ); this.replicationService = targetService; } diff --git a/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java b/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java index 0afeae253ae14..0bb198b3a4f17 100644 --- a/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java +++ b/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java @@ -65,6 +65,7 @@ import org.opensearch.index.store.Store; import org.opensearch.index.store.StoreFileMetadata; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportService; @@ -106,7 +107,8 @@ public TransportNodesListShardStoreMetadata( TransportService transportService, IndicesService indicesService, NodeEnvironment nodeEnv, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { super( ACTION_NAME, @@ -117,7 +119,8 @@ public TransportNodesListShardStoreMetadata( Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STORE, - NodeStoreFilesMetadata.class + NodeStoreFilesMetadata.class, + tracer ); this.settings = settings; this.indicesService = indicesService; diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 1f8f17f8e8d91..7658e05600899 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -874,6 +874,7 @@ protected Node( clusterService.getClusterSettings(), tracer ); + Collection>> indexTemplateMetadataUpgraders = pluginsService.filterPlugins( Plugin.class ).stream().map(Plugin::getIndexTemplateMetadataUpgrader).collect(Collectors.toList()); @@ -914,7 +915,8 @@ protected Node( clusterService, environment.settings(), client, - identityService + identityService, + tracer ); final PersistedStateRegistry persistedStateRegistry = new PersistedStateRegistry(); final GatewayMetaState gatewayMetaState = new GatewayMetaState(); @@ -970,7 +972,8 @@ protected Node( clusterModule.getIndexNameExpressionResolver(), repositoryService, transportService, - actionModule.getActionFilters() + actionModule.getActionFilters(), + tracer ); SnapshotShardsService snapshotShardsService = new SnapshotShardsService( settings, @@ -984,7 +987,8 @@ protected Node( clusterService, transportService, snapshotShardsService, - actionModule.getActionFilters() + actionModule.getActionFilters(), + tracer ); RestoreService restoreService = new RestoreService( clusterService, diff --git a/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java b/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java index e43a67ea82fdd..bf677ccc6dd6b 100644 --- a/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java +++ b/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java @@ -47,6 +47,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -162,7 +163,8 @@ public TransportAction( ThreadPool threadPool, ActionFilters actionFilters, PersistentTasksClusterService persistentTasksClusterService, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( CompletionPersistentTaskAction.NAME, @@ -171,7 +173,8 @@ public TransportAction( threadPool, actionFilters, Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.persistentTasksClusterService = persistentTasksClusterService; } diff --git a/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java b/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java index 45fe8917095c3..ac476f19ae885 100644 --- a/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java +++ b/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java @@ -47,6 +47,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -150,7 +151,8 @@ public TransportAction( ThreadPool threadPool, ActionFilters actionFilters, PersistentTasksClusterService persistentTasksClusterService, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( RemovePersistentTaskAction.NAME, @@ -159,7 +161,8 @@ public TransportAction( threadPool, actionFilters, Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.persistentTasksClusterService = persistentTasksClusterService; } diff --git a/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java b/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java index c839fb72c4d05..fcd0cb17490c9 100644 --- a/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java +++ b/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java @@ -48,6 +48,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -214,7 +215,8 @@ public TransportAction( PersistentTasksClusterService persistentTasksClusterService, PersistentTasksExecutorRegistry persistentTasksExecutorRegistry, PersistentTasksService persistentTasksService, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( StartPersistentTaskAction.NAME, @@ -223,7 +225,8 @@ public TransportAction( threadPool, actionFilters, Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.persistentTasksClusterService = persistentTasksClusterService; NodePersistentTasksExecutor executor = new NodePersistentTasksExecutor(threadPool); diff --git a/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java b/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java index 030b3d231cdd3..698d92b2690a0 100644 --- a/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java +++ b/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java @@ -47,6 +47,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -182,7 +183,8 @@ public TransportAction( ThreadPool threadPool, ActionFilters actionFilters, PersistentTasksClusterService persistentTasksClusterService, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( UpdatePersistentTaskStatusAction.NAME, @@ -191,7 +193,8 @@ public TransportAction( threadPool, actionFilters, Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); this.persistentTasksClusterService = persistentTasksClusterService; } diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java index 1f063bfed8cfe..0a0466cb7985c 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java @@ -100,6 +100,7 @@ import org.opensearch.repositories.RepositoryMissingException; import org.opensearch.repositories.RepositoryShardId; import org.opensearch.repositories.ShardGenerations; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -205,7 +206,8 @@ public SnapshotsService( IndexNameExpressionResolver indexNameExpressionResolver, RepositoriesService repositoriesService, TransportService transportService, - ActionFilters actionFilters + ActionFilters actionFilters, + Tracer tracer ) { this.clusterService = clusterService; this.indexNameExpressionResolver = indexNameExpressionResolver; @@ -220,7 +222,8 @@ public SnapshotsService( clusterService, threadPool, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); if (DiscoveryNode.isClusterManagerNode(settings)) { // addLowPriorityApplier to make sure that Repository will be created before snapshot @@ -3182,7 +3185,8 @@ private class UpdateSnapshotStatusAction extends TransportClusterManagerNodeActi ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver + IndexNameExpressionResolver indexNameExpressionResolver, + Tracer tracer ) { super( UPDATE_SNAPSHOT_STATUS_ACTION_NAME, @@ -3192,7 +3196,8 @@ private class UpdateSnapshotStatusAction extends TransportClusterManagerNodeActi threadPool, actionFilters, UpdateIndexShardSnapshotStatusRequest::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java b/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java index e86b21ae0fd3b..0dbc146e4566b 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java @@ -64,4 +64,14 @@ private AttributeNames() { * Action Name. */ public static final String TRANSPORT_ACTION = "action"; + + /** + * task id. + */ + public static final String TASK_ID = "task_id"; + + /** + * parent task id. + */ + public static final String PARENT_TASK_ID = "p_task_id"; } diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java b/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java index d247d48389fc8..cef9ec12e1eec 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java @@ -12,6 +12,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.http.HttpRequest; import org.opensearch.rest.RestRequest; +import org.opensearch.tasks.Task; import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.transport.Transport; @@ -127,4 +128,28 @@ private static Attributes buildSpanAttributes(String action, Transport.Connectio return attributes; } + public static SpanCreationContext from(Task task, String actionName) { + return new SpanCreationContext(createSpanName(task, actionName), buildSpanAttributes(task, actionName)); + } + + private static Attributes buildSpanAttributes(Task task, String actionName) { + Attributes attributes = Attributes.create().addAttribute(AttributeNames.TRANSPORT_ACTION, actionName); + if (task != null) { + attributes.addAttribute(AttributeNames.TASK_ID, task.getId()); + if (task.getParentTaskId() != null && task.getParentTaskId().isSet()) { + attributes.addAttribute(AttributeNames.PARENT_TASK_ID, task.getParentTaskId().getId()); + } + } + return attributes; + + } + + private static String createSpanName(Task task, String actionName) { + if (task != null) { + return task.getType() + SEPARATOR + task.getAction(); + } else { + return actionName; + } + } + } diff --git a/server/src/test/java/org/opensearch/action/ActionModuleTests.java b/server/src/test/java/org/opensearch/action/ActionModuleTests.java index deb0bb58a5c4d..f31079ff55c1f 100644 --- a/server/src/test/java/org/opensearch/action/ActionModuleTests.java +++ b/server/src/test/java/org/opensearch/action/ActionModuleTests.java @@ -59,6 +59,7 @@ import org.opensearch.rest.action.RestMainAction; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; @@ -102,8 +103,8 @@ public ActionRequestValidationException validate() { } } class FakeTransportAction extends TransportAction { - protected FakeTransportAction(String actionName, ActionFilters actionFilters, TaskManager taskManager) { - super(actionName, actionFilters, taskManager); + protected FakeTransportAction(String actionName, ActionFilters actionFilters, TaskManager taskManager, Tracer tracer) { + super(actionName, actionFilters, taskManager, tracer); } @Override diff --git a/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java b/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java index 20c2b1f17124c..3ffce7d7d7336 100644 --- a/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java +++ b/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java @@ -23,6 +23,7 @@ import org.opensearch.rest.RestRequest; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; @@ -48,7 +49,13 @@ public void testDynamicActionRegistry() { // ExtensionsAction not yet registered ExtensionAction testExtensionAction = new ExtensionAction("extensionId", "actionName"); - ExtensionTransportAction testExtensionTransportAction = new ExtensionTransportAction("test-action", emptyFilters, null, null); + ExtensionTransportAction testExtensionTransportAction = new ExtensionTransportAction( + "test-action", + emptyFilters, + null, + null, + NoopTracer.INSTANCE + ); assertNull(dynamicActionRegistry.get(testExtensionAction)); // Register an extension action @@ -141,7 +148,7 @@ public ActionResponse read(StreamInput in) throws IOException { private static final class TestTransportAction extends TransportAction { protected TestTransportAction(String actionName, ActionFilters actionFilters, TaskManager taskManager) { - super(actionName, actionFilters, taskManager); + super(actionName, actionFilters, taskManager, NoopTracer.INSTANCE); } @Override diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java index a015e671f4872..8e874064fb72a 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java @@ -161,7 +161,8 @@ public void setupForTest() { clusterService, threadPool, new ActionFilters(emptySet()), - new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)) + new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), + NoopTracer.INSTANCE ); // registers action transportService.start(); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java index 10e4ab6388be4..12bc7466d727e 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java @@ -121,7 +121,8 @@ public void setupForTest() { clusterService, threadPool, new ActionFilters(emptySet()), - new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)) + new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), + NoopTracer.INSTANCE ); // registers action transportService.start(); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java index 07e149dd72164..79d3d66745965 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java @@ -177,7 +177,8 @@ abstract class AbstractTestNodesAction { @Inject - public TransportTestTaskAction(ThreadPool threadPool, ClusterService clusterService, TransportService transportService) { + public TransportTestTaskAction( + ThreadPool threadPool, + ClusterService clusterService, + TransportService transportService, + Tracer tracer + ) { super( TestTaskAction.NAME, threadPool, @@ -296,7 +302,8 @@ public TransportTestTaskAction(ThreadPool threadPool, ClusterService clusterServ NodesRequest::new, NodeRequest::new, ThreadPool.Names.GENERIC, - NodeResponse.class + NodeResponse.class, + tracer ); } @@ -428,7 +435,7 @@ public static class TransportUnblockTestTasksAction extends TransportTasksAction UnblockTestTaskResponse> { @Inject - public TransportUnblockTestTasksAction(ClusterService clusterService, TransportService transportService) { + public TransportUnblockTestTasksAction(ClusterService clusterService, TransportService transportService, Tracer tracer) { super( UnblockTestTasksAction.NAME, clusterService, @@ -437,7 +444,8 @@ public TransportUnblockTestTasksAction(ClusterService clusterService, TransportS UnblockTestTasksRequest::new, UnblockTestTasksResponse::new, UnblockTestTaskResponse::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); } diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java index 0759d9a0d4640..aacf57cfc4e66 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java @@ -63,6 +63,7 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskInfo; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.tasks.MockTaskManager; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; @@ -247,7 +248,8 @@ protected TestTasksAction(String actionName, ClusterService clusterService, Tran TestTasksRequest::new, TestTasksResponse::new, TestTaskResponse::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/stats/TransportRemoteStoreStatsActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/stats/TransportRemoteStoreStatsActionTests.java index ed73c2ef6ace5..ddd778eefd99e 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/stats/TransportRemoteStoreStatsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/stats/TransportRemoteStoreStatsActionTests.java @@ -99,7 +99,8 @@ public void setUp() throws Exception { indicesService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), - remoteStoreStatsTrackerFactory + remoteStoreStatsTrackerFactory, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheActionTests.java index 1abd4c06e50e7..9c3af4147187c 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/cache/clear/TransportClearIndicesCacheActionTests.java @@ -30,6 +30,7 @@ import org.opensearch.index.store.remote.filecache.FileCacheTests; import org.opensearch.indices.IndicesService; import org.opensearch.node.Node; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.TransportService; @@ -49,7 +50,8 @@ public class TransportClearIndicesCacheActionTests extends OpenSearchTestCase { mock(IndicesService.class), testNode, mock(ActionFilters.class), - mock(IndexNameExpressionResolver.class) + mock(IndexNameExpressionResolver.class), + NoopTracer.INSTANCE ); private final ClusterBlock writeClusterBlock = new ClusterBlock( diff --git a/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java index ef26bc225b0c7..175dbccbfa210 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java @@ -154,7 +154,8 @@ public void setUp() throws Exception { mock(IndicesService.class), mock(ThreadPool.class), shardStateAction, - mock(ActionFilters.class) + mock(ActionFilters.class), + NoopTracer.INSTANCE ); } @@ -351,7 +352,8 @@ private TransportVerifyShardBeforeCloseAction createAction() { mock(IndicesService.class), mock(ThreadPool.class), mock(ShardStateAction.class), - mock(ActionFilters.class) + mock(ActionFilters.class), + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/flush/TransportShardFlushActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/flush/TransportShardFlushActionTests.java index 09215088bd04b..7c23e27962559 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/flush/TransportShardFlushActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/flush/TransportShardFlushActionTests.java @@ -16,6 +16,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -50,7 +51,8 @@ private TransportShardFlushAction createAction() { mock(IndicesService.class), mock(ThreadPool.class), mock(ShardStateAction.class), - mock(ActionFilters.class) + mock(ActionFilters.class), + NoopTracer.INSTANCE ); } } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java index 2d9ec2b6d3c02..ee081755dd8c5 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java @@ -146,7 +146,8 @@ class TestTransportGetIndexAction extends TransportGetIndexAction { new ActionFilters(emptySet()), new GetIndexActionTests.Resolver(), indicesService, - IndexScopedSettings.DEFAULT_SCOPED_SETTINGS + IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockActionTests.java index 8c4a6c023f9a5..184d2b7e04930 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockActionTests.java @@ -16,6 +16,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -50,7 +51,8 @@ private TransportVerifyShardIndexBlockAction createAction() { mock(IndicesService.class), mock(ThreadPool.class), mock(ShardStateAction.class), - mock(ActionFilters.class) + mock(ActionFilters.class), + NoopTracer.INSTANCE ); } } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshActionTests.java index b2eee904bad38..f407509832599 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshActionTests.java @@ -16,6 +16,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.index.shard.IndexShard; import org.opensearch.indices.IndicesService; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -50,7 +51,8 @@ private TransportShardRefreshAction createAction() { mock(IndicesService.class), mock(ThreadPool.class), mock(ShardStateAction.class), - mock(ActionFilters.class) + mock(ActionFilters.class), + NoopTracer.INSTANCE ); } } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java index fb4e955e95ab9..1b4efa9c65405 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java @@ -80,6 +80,7 @@ import org.opensearch.index.warmer.WarmerStats; import org.opensearch.search.suggest.completion.CompletionStats; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -290,7 +291,8 @@ public void testConditionEvaluationWhenAliasToWriteAndReadIndicesConsidersOnlyPr mockActionFilters, mockIndexNameExpressionResolver, rolloverService, - mockClient + mockClient, + NoopTracer.INSTANCE ); // For given alias, verify that condition evaluation fails when the condition doc count is greater than the primaries doc count diff --git a/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java index f2b6688716e70..cbe05b4bcdcb7 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java @@ -80,7 +80,8 @@ class TestTransportGetSettingsAction extends TransportGetSettingsAction { settingsFilter, new ActionFilters(Collections.emptySet()), new Resolver(), - IndexScopedSettings.DEFAULT_SCOPED_SETTINGS + IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java index 9ef0f85893fc8..99c0cf9e837f8 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java @@ -54,6 +54,7 @@ import org.opensearch.index.VersionType; import org.opensearch.indices.SystemIndices; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.VersionUtils; import org.opensearch.threadpool.ThreadPool; @@ -154,7 +155,8 @@ private void indicesThatCannotBeCreatedTestCase( Settings.EMPTY, new ClusterService(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), null) ), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ) { @Override void executeBulk( diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java index 5410d6a88a5b9..302644f6ce414 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java @@ -70,6 +70,7 @@ import org.opensearch.indices.SystemIndices; import org.opensearch.ingest.IngestService; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.VersionUtils; import org.opensearch.threadpool.ThreadPool; @@ -171,7 +172,8 @@ class TestTransportBulkAction extends TransportBulkAction { SETTINGS, new ClusterService(SETTINGS, new ClusterSettings(SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), null) ), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); } @@ -208,7 +210,8 @@ class TestSingleItemBulkWriteAction extends TransportSingleItemBulkWriteAction listener) {} @@ -243,7 +244,8 @@ public void testTransportMultiGetAction() { clusterService, shardAction, new ActionFilters(emptySet()), - new Resolver() + new Resolver(), + NoopTracer.INSTANCE ) { @Override protected void executeShardAction( @@ -275,7 +277,8 @@ public void testTransportMultiGetAction_withMissingRouting() { clusterService, shardAction, new ActionFilters(emptySet()), - new Resolver() + new Resolver(), + NoopTracer.INSTANCE ) { @Override protected void executeShardAction( diff --git a/server/src/test/java/org/opensearch/action/main/MainActionTests.java b/server/src/test/java/org/opensearch/action/main/MainActionTests.java index b43dc2a80cd37..9f53dd1ddabe5 100644 --- a/server/src/test/java/org/opensearch/action/main/MainActionTests.java +++ b/server/src/test/java/org/opensearch/action/main/MainActionTests.java @@ -113,7 +113,13 @@ public void testMainActionClusterAvailable() { Collections.emptySet(), NoopTracer.INSTANCE ); - TransportMainAction action = new TransportMainAction(settings, transportService, mock(ActionFilters.class), clusterService); + TransportMainAction action = new TransportMainAction( + settings, + transportService, + mock(ActionFilters.class), + clusterService, + NoopTracer.INSTANCE + ); AtomicReference responseRef = new AtomicReference<>(); action.doExecute(mock(Task.class), new MainRequest(), new ActionListener() { @Override diff --git a/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java b/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java index fbac465f946f4..48e85ba6a5a03 100644 --- a/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java +++ b/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java @@ -202,7 +202,8 @@ public void testResyncDoesNotBlockOnPrimaryAction() throws Exception { shardStateAction, new ActionFilters(new HashSet<>()), new IndexingPressureService(Settings.EMPTY, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); assertThat(action.globalBlockLevel(), nullValue()); @@ -255,7 +256,8 @@ private TransportResyncReplicationAction createAction() { mock(ShardStateAction.class), new ActionFilters(new HashSet<>()), mock(IndexingPressureService.class), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); } } diff --git a/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java b/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java index 94ba5b0a8768b..5723b185e214f 100644 --- a/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java +++ b/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java @@ -208,7 +208,8 @@ public String getLocalNodeId() { clusterService, availableProcessors, expected::get, - client + client, + NoopTracer.INSTANCE ) { @Override void executeSearch( @@ -230,7 +231,8 @@ void executeSearch( clusterService, availableProcessors, System::nanoTime, - client + client, + NoopTracer.INSTANCE ) { @Override void executeSearch( diff --git a/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java b/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java index 8d3cdc070c695..1bb18f1722b07 100644 --- a/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java @@ -173,7 +173,8 @@ public Transport.Connection getConnection(String clusterAlias, DiscoveryNode nod transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest(pitId); PlainActionFuture future = newFuture(); @@ -248,7 +249,8 @@ public void getAllPits(ActionListener getAllPitsListener transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest("_all"); PlainActionFuture future = newFuture(); @@ -314,7 +316,8 @@ public Transport.Connection getConnection(String clusterAlias, DiscoveryNode nod transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest(pitId); PlainActionFuture future = newFuture(); @@ -370,7 +373,8 @@ public Transport.Connection getConnection(String clusterAlias, DiscoveryNode nod transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest(pitId); PlainActionFuture future = newFuture(); @@ -435,7 +439,8 @@ public Transport.Connection getConnection(String clusterAlias, DiscoveryNode nod transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest(pitId); PlainActionFuture future = newFuture(); @@ -512,7 +517,8 @@ public void getAllPits(ActionListener getAllPitsListener transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest("_all"); PlainActionFuture future = newFuture(); @@ -585,7 +591,8 @@ public void getAllPits(ActionListener getAllPitsListener transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest("_all"); PlainActionFuture future = newFuture(); @@ -662,7 +669,8 @@ public void getAllPits(ActionListener getAllPitsListener transportService, actionFilters, namedWriteableRegistry, - pitService + pitService, + NoopTracer.INSTANCE ); DeletePitRequest deletePITRequest = new DeletePitRequest("_all"); PlainActionFuture future = newFuture(); diff --git a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java index 48970e2b96add..cce7b94052abf 100644 --- a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java @@ -128,7 +128,8 @@ public String getLocalNodeId() { clusterService, 10, System::nanoTime, - client + client, + NoopTracer.INSTANCE ); PlainActionFuture future = newFuture(); @@ -222,7 +223,8 @@ public String getLocalNodeId() { clusterService, 10, System::nanoTime, - client + client, + NoopTracer.INSTANCE ); // Execute the multi search api and fail if we find an error after executing: diff --git a/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java b/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java index a4f40db365f9a..c56a8fb35a7cf 100644 --- a/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java +++ b/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java @@ -43,6 +43,7 @@ import org.opensearch.node.Node; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; import org.junit.After; @@ -98,7 +99,8 @@ public void testActionFiltersRequest() throws InterruptedException { TransportAction transportAction = new TransportAction( actionName, actionFilters, - new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()) + new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()), + NoopTracer.INSTANCE ) { @Override protected void doExecute(Task task, TestRequest request, ActionListener listener) { @@ -183,7 +185,8 @@ public void exe TransportAction transportAction = new TransportAction( actionName, actionFilters, - new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()) + new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()), + NoopTracer.INSTANCE ) { @Override protected void doExecute(Task task, TestRequest request, ActionListener listener) { diff --git a/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java b/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java index 4305151965ab6..ad444b6431551 100644 --- a/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java @@ -152,7 +152,8 @@ class TestTransportBroadcastByNodeAction extends TransportBroadcastByNodeAction< actionFilters, indexNameExpressionResolver, request, - executor + executor, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java index 9ae1310a8b15c..a8b1f8d21f412 100644 --- a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java @@ -63,6 +63,7 @@ import org.opensearch.discovery.ClusterManagerNotDiscoveredException; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.CapturingTransport; @@ -205,7 +206,7 @@ public void writeTo(StreamOutput out) throws IOException { } class Action extends TransportClusterManagerNodeAction { - Action(String actionName, TransportService transportService, ClusterService clusterService, ThreadPool threadPool) { + Action(String actionName, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, Tracer tracer) { super( actionName, transportService, @@ -213,7 +214,8 @@ class Action extends TransportClusterManagerNodeAction { threadPool, new ActionFilters(new HashSet<>()), Request::new, - new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)) + new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), + tracer ); } @@ -256,7 +258,7 @@ public void testLocalOperationWithoutBlocks() throws ExecutionException, Interru setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, allNodes)); - new Action("internal:testAction", transportService, clusterService, threadPool) { + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE) { @Override protected void clusterManagerOperation(Task task, Request request, ClusterState state, ActionListener listener) { if (clusterManagerOperationFailure) { @@ -293,7 +295,7 @@ public void testDeprecatedMasterOperationWithTaskParameterCanBeCalled() throws E setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, allNodes)); - new Action("internal:testAction", transportService, clusterService, threadPool) { + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE) { @Override protected void masterOperation(Task task, Request request, ClusterState state, ActionListener listener) { if (clusterManagerOperationFailure) { @@ -330,7 +332,7 @@ public void testLocalOperationWithBlocks() throws ExecutionException, Interrupte .build(); setState(clusterService, stateWithBlock); - new Action("internal:testAction", transportService, clusterService, threadPool) { + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE) { @Override protected ClusterBlockException checkBlock(Request request, ClusterState state) { Set blocks = state.blocks().global(); @@ -376,7 +378,7 @@ public void testCheckBlockThrowsException() throws InterruptedException { .build(); setState(clusterService, stateWithBlock); - new Action("internal:testAction", transportService, clusterService, threadPool) { + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE) { @Override protected ClusterBlockException checkBlock(Request request, ClusterState state) { Set blocks = state.blocks().global(); @@ -408,7 +410,7 @@ public void testForceLocalOperation() throws ExecutionException, InterruptedExce setState(clusterService, ClusterStateCreationUtils.state(localNode, randomFrom(localNode, remoteNode, null), allNodes)); - new Action("internal:testAction", transportService, clusterService, threadPool) { + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE) { @Override protected boolean localExecute(Request request) { return true; @@ -423,7 +425,7 @@ public void testClusterManagerNotAvailable() throws ExecutionException, Interrup Request request = new Request().clusterManagerNodeTimeout(TimeValue.timeValueSeconds(0)); setState(clusterService, ClusterStateCreationUtils.state(localNode, null, allNodes)); PlainActionFuture listener = new PlainActionFuture<>(); - new Action("internal:testAction", transportService, clusterService, threadPool).execute(request, listener); + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE).execute(request, listener); assertTrue(listener.isDone()); assertListenerThrows("ClusterManagerNotDiscoveredException should be thrown", listener, ClusterManagerNotDiscoveredException.class); } @@ -432,7 +434,7 @@ public void testClusterManagerBecomesAvailable() throws ExecutionException, Inte Request request = new Request(); setState(clusterService, ClusterStateCreationUtils.state(localNode, null, allNodes)); PlainActionFuture listener = new PlainActionFuture<>(); - new Action("internal:testAction", transportService, clusterService, threadPool).execute(request, listener); + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE).execute(request, listener); assertFalse(listener.isDone()); setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, allNodes)); assertTrue(listener.isDone()); @@ -444,7 +446,7 @@ public void testDelegateToClusterManager() throws ExecutionException, Interrupte setState(clusterService, ClusterStateCreationUtils.state(localNode, remoteNode, allNodes)); PlainActionFuture listener = new PlainActionFuture<>(); - new Action("internal:testAction", transportService, clusterService, threadPool).execute(request, listener); + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE).execute(request, listener); assertThat(transport.capturedRequests().length, equalTo(1)); CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0]; @@ -470,7 +472,7 @@ public void testDelegateToFailingClusterManager() throws ExecutionException, Int ); PlainActionFuture listener = new PlainActionFuture<>(); - new Action("internal:testAction", transportService, clusterService, threadPool).execute(request, listener); + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE).execute(request, listener); CapturingTransport.CapturedRequest[] capturedRequests = transport.getCapturedRequestsAndClear(); assertThat(capturedRequests.length, equalTo(1)); @@ -552,7 +554,7 @@ public void testClusterManagerFailoverAfterStepDown() throws ExecutionException, setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, allNodes)); - new Action("internal:testAction", transportService, clusterService, threadPool) { + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE) { @Override protected void clusterManagerOperation(Request request, ClusterState state, ActionListener listener) throws Exception { @@ -599,7 +601,7 @@ public void testDelegateToClusterManagerOnNodeWithDeprecatedMasterRole() throws setState(clusterService, ClusterStateCreationUtils.state(localNode, remoteNode, allNodes)); PlainActionFuture listener = new PlainActionFuture<>(); - new Action("internal:testAction", transportService, clusterService, threadPool).execute(request, listener); + new Action("internal:testAction", transportService, clusterService, threadPool, NoopTracer.INSTANCE).execute(request, listener); assertThat(transport.capturedRequests().length, equalTo(1)); CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0]; @@ -621,7 +623,13 @@ public void testThrottlingRetryLocalMaster() throws InterruptedException, Broken CyclicBarrier barrier = new CyclicBarrier(2); setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, new DiscoveryNode[] { localNode })); - TransportClusterManagerNodeAction action = new Action("internal:testAction", transportService, clusterService, threadPool) { + TransportClusterManagerNodeAction action = new Action( + "internal:testAction", + transportService, + clusterService, + threadPool, + NoopTracer.INSTANCE + ) { @Override protected void masterOperation(Task task, Request request, ClusterState state, ActionListener listener) { if (exception.getAndSet(false)) { @@ -654,7 +662,13 @@ public void testThrottlingRetryRemoteMaster() throws ExecutionException, Interru ); PlainActionFuture listener = new PlainActionFuture<>(); - TransportClusterManagerNodeAction action = new Action("internal:testAction", transportService, clusterService, threadPool); + TransportClusterManagerNodeAction action = new Action( + "internal:testAction", + transportService, + clusterService, + threadPool, + NoopTracer.INSTANCE + ); action.execute(request, listener); CapturingTransport.CapturedRequest[] capturedRequests = transport.getCapturedRequestsAndClear(); @@ -692,7 +706,13 @@ public void testRetryForDifferentException() throws InterruptedException, Broken CyclicBarrier barrier = new CyclicBarrier(2); setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, new DiscoveryNode[] { localNode })); - TransportClusterManagerNodeAction action = new Action("internal:testAction", transportService, clusterService, threadPool) { + TransportClusterManagerNodeAction action = new Action( + "internal:testAction", + transportService, + clusterService, + threadPool, + NoopTracer.INSTANCE + ) { @Override protected void masterOperation(Task task, Request request, ClusterState state, ActionListener listener) throws Exception { diff --git a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java index 445934b0ccdfd..aecae4c8cd79d 100644 --- a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java @@ -296,7 +296,8 @@ private static class TestTransportNodesAction extends TransportNodesAction< request, nodeRequest, nodeExecutor, - TestNodeResponse.class + TestNodeResponse.class, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java b/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java index 77c9c64ad6611..690bc2316a32c 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java @@ -62,6 +62,7 @@ import org.opensearch.core.indices.breaker.NoneCircuitBreakerService; import org.opensearch.core.rest.RestStatus; import org.opensearch.tasks.Task; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; @@ -136,7 +137,8 @@ public void setUp() throws Exception { transportService, new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), - null + null, + NoopTracer.INSTANCE ); } @@ -269,7 +271,8 @@ private class TestBroadcastReplicationAction extends TransportBroadcastReplicati TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - TransportReplicationAction action + TransportReplicationAction action, + Tracer tracer ) { super( "internal:test-broadcast-replication-action", @@ -278,7 +281,8 @@ private class TestBroadcastReplicationAction extends TransportBroadcastReplicati transportService, actionFilters, indexNameExpressionResolver, - action + action, + tracer ); } diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java index 0bee99f4d5656..0255381d95f12 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java @@ -87,6 +87,7 @@ import org.opensearch.indices.IndexClosedException; import org.opensearch.indices.IndicesService; import org.opensearch.indices.cluster.ClusterStateChanges; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.CapturingTransport; @@ -985,7 +986,8 @@ public void testSeqNoIsSetOnPrimary() { clusterService, shardStateAction, threadPool, - indicesService + indicesService, + NoopTracer.INSTANCE ); action.handlePrimaryRequest(concreteShardRequest, createTransportChannel(listener), null); @@ -1501,7 +1503,16 @@ private class TestAction extends TransportReplicationAction executedOnPrimary + SetOnce executedOnPrimary, + Tracer tracer ) { super( settings, @@ -485,7 +487,8 @@ private abstract class TestAction extends TransportReplicationAction()), Request::new, Request::new, - ThreadPool.Names.SAME + ThreadPool.Names.SAME, + tracer ); this.shardId = Objects.requireNonNull(shardId); this.primary = Objects.requireNonNull(primary); @@ -579,7 +582,8 @@ private class SinglePermitWithBlocksAction extends TestAction { shardId, primary, replica, - new SetOnce<>() + new SetOnce<>(), + NoopTracer.INSTANCE ); this.globalBlock = globalBlock; } @@ -647,7 +651,8 @@ private class AllPermitsThenBlockAction extends TestAction { shardId, primary, replica, - new SetOnce<>() + new SetOnce<>(), + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java index 4a2185d1558f7..582059d5ef1db 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java @@ -37,6 +37,7 @@ import org.opensearch.index.translog.Translog; import org.opensearch.indices.IndicesService; import org.opensearch.indices.SystemIndices; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.CapturingTransport; @@ -137,7 +138,15 @@ public void testIndexingPressureOperationStartedForReplicaNode() { .build(); this.indexingPressureService = new IndexingPressureService(settings, clusterService); - TestAction action = new TestAction(settings, "internal:testAction", transportService, clusterService, shardStateAction, threadPool); + TestAction action = new TestAction( + settings, + "internal:testAction", + transportService, + clusterService, + shardStateAction, + threadPool, + NoopTracer.INSTANCE + ); action.handleReplicaRequest( new TransportReplicationAction.ConcreteReplicaRequest<>( @@ -169,7 +178,15 @@ public void testIndexingPressureOperationStartedForReplicaShard() { .build(); this.indexingPressureService = new IndexingPressureService(settings, clusterService); - TestAction action = new TestAction(settings, "internal:testAction", transportService, clusterService, shardStateAction, threadPool); + TestAction action = new TestAction( + settings, + "internal:testAction", + transportService, + clusterService, + shardStateAction, + threadPool, + NoopTracer.INSTANCE + ); action.handleReplicaRequest( new TransportReplicationAction.ConcreteReplicaRequest<>( @@ -210,7 +227,8 @@ public void testIndexingPressureOperationStartedForPrimaryNode() { transportService, clusterService, shardStateAction, - threadPool + threadPool, + NoopTracer.INSTANCE ); action.handlePrimaryRequest( @@ -249,7 +267,8 @@ public void testIndexingPressureOperationStartedForPrimaryShard() { transportService, clusterService, shardStateAction, - threadPool + threadPool, + NoopTracer.INSTANCE ); action.handlePrimaryRequest( @@ -285,7 +304,15 @@ public void testIndexingPressureOperationStartedForLocalPrimaryNode() { .build(); this.indexingPressureService = new IndexingPressureService(settings, clusterService); - TestAction action = new TestAction(settings, "internal:testAction", transportService, clusterService, shardStateAction, threadPool); + TestAction action = new TestAction( + settings, + "internal:testAction", + transportService, + clusterService, + shardStateAction, + threadPool, + NoopTracer.INSTANCE + ); action.handlePrimaryRequest( new TransportReplicationAction.ConcreteShardRequest<>( @@ -317,7 +344,15 @@ public void testIndexingPressureOperationStartedForLocalPrimaryShard() { .build(); this.indexingPressureService = new IndexingPressureService(settings, clusterService); - TestAction action = new TestAction(settings, "internal:testAction", transportService, clusterService, shardStateAction, threadPool); + TestAction action = new TestAction( + settings, + "internal:testAction", + transportService, + clusterService, + shardStateAction, + threadPool, + NoopTracer.INSTANCE + ); action.handlePrimaryRequest( new TransportReplicationAction.ConcreteShardRequest<>( @@ -376,7 +411,8 @@ protected TestAction( TransportService transportService, ClusterService clusterService, ShardStateAction shardStateAction, - ThreadPool threadPool + ThreadPool threadPool, + Tracer tracer ) { super( settings, @@ -392,7 +428,8 @@ protected TestAction( ignore -> ThreadPool.Names.SAME, false, TransportWriteActionForIndexingPressureTests.this.indexingPressureService, - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + tracer ); } diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java index 9d2069ac16190..b4549f82230bf 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java @@ -477,7 +477,8 @@ protected TestAction(boolean withDocumentFailureOnPrimary, boolean withDocumentF ignore -> ThreadPool.Names.SAME, false, new IndexingPressureService(Settings.EMPTY, TransportWriteActionTests.this.clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); this.withDocumentFailureOnPrimary = withDocumentFailureOnPrimary; this.withDocumentFailureOnReplica = withDocumentFailureOnReplica; @@ -505,7 +506,8 @@ protected TestAction( ignore -> ThreadPool.Names.SAME, false, new IndexingPressureService(settings, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); this.withDocumentFailureOnPrimary = false; this.withDocumentFailureOnReplica = false; diff --git a/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java b/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java index 118b4e596fc66..73468eba78557 100644 --- a/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java @@ -129,7 +129,8 @@ class TestTransportInstanceSingleOperationAction extends TransportInstanceSingle transportService, actionFilters, indexNameExpressionResolver, - request + request, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java b/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java index 0868421fe1d41..4ab1cc3ccec42 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java +++ b/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java @@ -205,7 +205,8 @@ public TaskManager getTaskManager() { mock(IndicesService.class), threadPool, new ActionFilters(emptySet()), - new Resolver() + new Resolver(), + NoopTracer.INSTANCE ) { @Override protected void doExecute( @@ -239,7 +240,8 @@ public void testTransportMultiGetAction() { clusterService, shardAction, new ActionFilters(emptySet()), - new Resolver() + new Resolver(), + NoopTracer.INSTANCE ) { @Override protected void executeShardAction( @@ -271,7 +273,8 @@ public void testTransportMultiGetAction_withMissingRouting() { clusterService, shardAction, new ActionFilters(emptySet()), - new Resolver() + new Resolver(), + NoopTracer.INSTANCE ) { @Override protected void executeShardAction( diff --git a/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java b/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java index 176c94b01c878..a378431f56096 100644 --- a/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java +++ b/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java @@ -44,6 +44,7 @@ import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.threadpool.ThreadPool; import java.util.Collections; @@ -76,7 +77,7 @@ private Actions(Settings settings, ThreadPool threadPool, ActionType[] action private static class InternalTransportAction extends TransportAction { private InternalTransportAction(Settings settings, String actionName, ThreadPool threadPool) { - super(actionName, EMPTY_FILTERS, new TaskManager(settings, threadPool, Collections.emptySet())); + super(actionName, EMPTY_FILTERS, new TaskManager(settings, threadPool, Collections.emptySet()), NoopTracer.INSTANCE); } @Override diff --git a/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java b/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java index 775d113f986ca..36455cfb78ec0 100644 --- a/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java @@ -110,7 +110,8 @@ public void setUpService() { weightedRoutingService, threadPool, new ActionFilters(emptySet()), - mock(IndexNameExpressionResolver.class) + mock(IndexNameExpressionResolver.class), + NoopTracer.INSTANCE ); client = new NodeClient(Settings.EMPTY, threadPool); } diff --git a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java index 627f31502a417..b7911d993b857 100644 --- a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java +++ b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java @@ -107,7 +107,8 @@ public void setTransportServiceAndDefaultClusterState() { clusterService, threadPool, new ActionFilters(emptySet()), - new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)) + new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), + NoopTracer.INSTANCE ); // registers action new TransportClearVotingConfigExclusionsAction( @@ -115,7 +116,8 @@ public void setTransportServiceAndDefaultClusterState() { clusterService, threadPool, new ActionFilters(emptySet()), - new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)) + new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), + NoopTracer.INSTANCE ); // registers action transportService.start(); diff --git a/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java b/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java index 795dc8a624e38..cadd2253e7bc4 100644 --- a/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java +++ b/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java @@ -179,7 +179,8 @@ public void testClusterHealthWaitsForClusterStateApplication() throws Interrupte new ActionFilters(new HashSet<>()), indexNameExpressionResolver, new AllocationService(null, new TestGatewayAllocator(), null, null, null), - null + null, + NoopTracer.INSTANCE ); PlainActionFuture listener = new PlainActionFuture<>(); action.execute(new ClusterHealthRequest().waitForGreenStatus(), listener); diff --git a/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java b/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java index 57883f1e5914a..3a37383c3dda2 100644 --- a/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java +++ b/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java @@ -774,7 +774,8 @@ public void testRegisterHandler() throws Exception { clusterService, settings, client, - identityService + identityService, + NoopTracer.INSTANCE ); verify(mockTransportService, times(9)).registerRequestHandler(anyString(), anyString(), anyBoolean(), anyBoolean(), any(), any()); @@ -892,7 +893,8 @@ private void initialize(ExtensionsManager extensionsManager) { clusterService, settings, client, - identityService + identityService, + NoopTracer.INSTANCE ); } } diff --git a/server/src/test/java/org/opensearch/extensions/action/ExtensionTransportActionsHandlerTests.java b/server/src/test/java/org/opensearch/extensions/action/ExtensionTransportActionsHandlerTests.java index 1dede94c68208..e72a6d0629f98 100644 --- a/server/src/test/java/org/opensearch/extensions/action/ExtensionTransportActionsHandlerTests.java +++ b/server/src/test/java/org/opensearch/extensions/action/ExtensionTransportActionsHandlerTests.java @@ -107,7 +107,8 @@ public void setup() throws Exception { transportService, client, mockActionModule, - null + null, + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java b/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java index 992e37b3f120a..1db14f0662bd7 100644 --- a/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java +++ b/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java @@ -384,7 +384,13 @@ public void testRestSendToExtensionWithNamedRouteCollidingWithDynamicTransportAc DynamicActionRegistry dynamicActionRegistry = actionModule.getDynamicActionRegistry(); ActionFilters emptyFilters = new ActionFilters(Collections.emptySet()); ExtensionAction testExtensionAction = new ExtensionAction("extensionId", "test:action/name"); - ExtensionTransportAction testExtensionTransportAction = new ExtensionTransportAction("test:action/name", emptyFilters, null, null); + ExtensionTransportAction testExtensionTransportAction = new ExtensionTransportAction( + "test:action/name", + emptyFilters, + null, + null, + NoopTracer.INSTANCE + ); assertNull(dynamicActionRegistry.get(testExtensionAction)); dynamicActionRegistry.registerDynamicAction(testExtensionAction, testExtensionTransportAction); diff --git a/server/src/test/java/org/opensearch/index/seqno/GlobalCheckpointSyncActionTests.java b/server/src/test/java/org/opensearch/index/seqno/GlobalCheckpointSyncActionTests.java index 8363ea3757a2b..e36826305f6a8 100644 --- a/server/src/test/java/org/opensearch/index/seqno/GlobalCheckpointSyncActionTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/GlobalCheckpointSyncActionTests.java @@ -135,7 +135,8 @@ public void testTranslogSyncAfterGlobalCheckpointSync() throws Exception { indicesService, threadPool, shardStateAction, - new ActionFilters(Collections.emptySet()) + new ActionFilters(Collections.emptySet()), + NoopTracer.INSTANCE ); final GlobalCheckpointSyncAction.Request primaryRequest = new GlobalCheckpointSyncAction.Request(indexShard.shardId()); if (randomBoolean()) { @@ -178,7 +179,8 @@ private GlobalCheckpointSyncAction createAction() { indicesService, threadPool, shardStateAction, - new ActionFilters(Collections.emptySet()) + new ActionFilters(Collections.emptySet()), + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java index ed04d9a20f18e..086e62b60a270 100644 --- a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java @@ -125,7 +125,8 @@ public void testRetentionLeaseBackgroundSyncActionOnPrimary() throws Interrupted indicesService, threadPool, shardStateAction, - new ActionFilters(Collections.emptySet()) + new ActionFilters(Collections.emptySet()), + NoopTracer.INSTANCE ); final RetentionLeases retentionLeases = mock(RetentionLeases.class); final RetentionLeaseBackgroundSyncAction.Request request = new RetentionLeaseBackgroundSyncAction.Request( @@ -164,7 +165,8 @@ public void testRetentionLeaseBackgroundSyncActionOnReplica() throws WriteStateE indicesService, threadPool, shardStateAction, - new ActionFilters(Collections.emptySet()) + new ActionFilters(Collections.emptySet()), + NoopTracer.INSTANCE ); final RetentionLeases retentionLeases = mock(RetentionLeases.class); final RetentionLeaseBackgroundSyncAction.Request request = new RetentionLeaseBackgroundSyncAction.Request( @@ -206,7 +208,8 @@ public void testBlocks() { indicesService, threadPool, shardStateAction, - new ActionFilters(Collections.emptySet()) + new ActionFilters(Collections.emptySet()), + NoopTracer.INSTANCE ); assertNull(action.indexBlockLevel()); @@ -234,7 +237,8 @@ private RetentionLeaseBackgroundSyncAction createAction() { mock(IndicesService.class), threadPool, shardStateAction, - new ActionFilters(Collections.emptySet()) + new ActionFilters(Collections.emptySet()), + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java index d9bca55a208c2..63a9ac2f2e8ec 100644 --- a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java @@ -125,7 +125,8 @@ public void testRetentionLeaseSyncActionOnPrimary() { shardStateAction, new ActionFilters(Collections.emptySet()), new IndexingPressureService(Settings.EMPTY, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); final RetentionLeases retentionLeases = mock(RetentionLeases.class); final RetentionLeaseSyncAction.Request request = new RetentionLeaseSyncAction.Request(indexShard.shardId(), retentionLeases); @@ -162,7 +163,8 @@ public void testRetentionLeaseSyncActionOnReplica() throws Exception { shardStateAction, new ActionFilters(Collections.emptySet()), new IndexingPressureService(Settings.EMPTY, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); final RetentionLeases retentionLeases = mock(RetentionLeases.class); final RetentionLeaseSyncAction.Request request = new RetentionLeaseSyncAction.Request(indexShard.shardId(), retentionLeases); @@ -203,7 +205,8 @@ public void testBlocks() { shardStateAction, new ActionFilters(Collections.emptySet()), new IndexingPressureService(Settings.EMPTY, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); assertNull(action.indexBlockLevel()); @@ -233,7 +236,8 @@ private RetentionLeaseSyncAction createAction() { shardStateAction, new ActionFilters(Collections.emptySet()), new IndexingPressureService(Settings.EMPTY, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java b/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java index dc4dca80ea110..5da824e264dc2 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java +++ b/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java @@ -263,7 +263,8 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m indicesService, threadPool, null, - actionFilters + actionFilters, + NoopTracer.INSTANCE ); TransportVerifyShardIndexBlockAction transportVerifyShardIndexBlockAction = new TransportVerifyShardIndexBlockAction( SETTINGS, @@ -272,7 +273,8 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m indicesService, threadPool, null, - actionFilters + actionFilters, + NoopTracer.INSTANCE ); final SystemIndices systemIndices = new SystemIndices(emptyMap()); ShardLimitValidator shardLimitValidator = new ShardLimitValidator(SETTINGS, clusterService, systemIndices); @@ -324,7 +326,8 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m clusterSettings, actionFilters, indexNameExpressionResolver, - destructiveOperations + destructiveOperations, + NoopTracer.INSTANCE ); transportOpenIndexAction = new TransportOpenIndexAction( transportService, @@ -333,7 +336,8 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m indexStateService, actionFilters, indexNameExpressionResolver, - destructiveOperations + destructiveOperations, + NoopTracer.INSTANCE ); transportDeleteIndexAction = new TransportDeleteIndexAction( transportService, @@ -342,7 +346,8 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m deleteIndexService, actionFilters, indexNameExpressionResolver, - destructiveOperations + destructiveOperations, + NoopTracer.INSTANCE ); transportUpdateSettingsAction = new TransportUpdateSettingsAction( transportService, @@ -350,7 +355,8 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m threadPool, metadataUpdateSettingsService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ); transportClusterRerouteAction = new TransportClusterRerouteAction( transportService, @@ -358,7 +364,9 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m threadPool, allocationService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE + ); transportCreateIndexAction = new TransportCreateIndexAction( transportService, @@ -366,7 +374,8 @@ public IndexMetadata upgradeIndexMetadata(IndexMetadata indexMetadata, Version m threadPool, createIndexService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ); repositoriesService = new RepositoriesService( diff --git a/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java b/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java index 2cf006176022d..1a98faa04b904 100644 --- a/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java @@ -104,7 +104,8 @@ public void testPublishCheckpointActionOnPrimary() { threadPool, shardStateAction, new ActionFilters(Collections.emptySet()), - mockTargetService + mockTargetService, + NoopTracer.INSTANCE ); final ReplicationCheckpoint checkpoint = new ReplicationCheckpoint(indexShard.shardId(), 1111, 11, 1, Codec.getDefault().getName()); @@ -139,7 +140,8 @@ public void testPublishCheckpointActionOnReplica() { threadPool, shardStateAction, new ActionFilters(Collections.emptySet()), - mockTargetService + mockTargetService, + NoopTracer.INSTANCE ); final ReplicationCheckpoint checkpoint = new ReplicationCheckpoint(indexShard.shardId(), 1111, 11, 1, Codec.getDefault().getName()); @@ -183,7 +185,8 @@ private PublishCheckpointAction createAction() { threadPool, shardStateAction, new ActionFilters(Collections.emptySet()), - mock(SegmentReplicationTargetService.class) + mock(SegmentReplicationTargetService.class), + NoopTracer.INSTANCE ); } diff --git a/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java b/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java index b990e64bf0f18..a631f3b9a28e9 100644 --- a/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java +++ b/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java @@ -54,6 +54,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.plugins.ActionPlugin; import org.opensearch.plugins.Plugin; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -149,7 +150,8 @@ public TransportUpdateInternalOrPrivateAction( final ClusterService clusterService, final ThreadPool threadPool, final ActionFilters actionFilters, - final IndexNameExpressionResolver indexNameExpressionResolver + final IndexNameExpressionResolver indexNameExpressionResolver, + final Tracer tracer ) { super( UpdateInternalOrPrivateAction.NAME, @@ -158,7 +160,8 @@ public TransportUpdateInternalOrPrivateAction( threadPool, actionFilters, UpdateInternalOrPrivateAction.Request::new, - indexNameExpressionResolver + indexNameExpressionResolver, + tracer ); } diff --git a/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java b/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java index 0a1893173e8a7..afe5675ec116d 100644 --- a/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java +++ b/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java @@ -73,6 +73,7 @@ import org.opensearch.plugins.ActionPlugin; import org.opensearch.plugins.PersistentTaskPlugin; import org.opensearch.plugins.Plugin; +import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -563,7 +564,12 @@ public static class TransportTestTaskAction extends TransportTasksAction< TestTaskResponse> { @Inject - public TransportTestTaskAction(ClusterService clusterService, TransportService transportService, ActionFilters actionFilters) { + public TransportTestTaskAction( + ClusterService clusterService, + TransportService transportService, + ActionFilters actionFilters, + Tracer tracer + ) { super( TestTaskAction.NAME, clusterService, @@ -572,7 +578,8 @@ public TransportTestTaskAction(ClusterService clusterService, TransportService t TestTasksRequest::new, TestTasksResponse::new, TestTaskResponse::new, - ThreadPool.Names.MANAGEMENT + ThreadPool.Names.MANAGEMENT, + tracer ); } diff --git a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java index 3fb6764846da6..5edc95b10a4f1 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java @@ -50,6 +50,7 @@ import org.opensearch.search.AbstractSearchTestCase; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; +import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.rest.FakeRestChannel; import org.opensearch.test.rest.FakeRestRequest; import org.opensearch.threadpool.TestThreadPool; @@ -98,7 +99,8 @@ public static void stubValidateQueryAction() { final TransportAction transportAction = new TransportAction<>( ValidateQueryAction.NAME, new ActionFilters(Collections.emptySet()), - taskManager + taskManager, + NoopTracer.INSTANCE ) { @Override protected void doExecute(Task task, ActionRequest request, ActionListener listener) {} diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index 3c31c979ce856..3ec065434e825 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -2008,7 +2008,8 @@ public void onFailure(final Exception e) { indexNameExpressionResolver, repositoriesService, transportService, - actionFilters + actionFilters, + NoopTracer.INSTANCE ); nodeEnv = new NodeEnvironment(settings, environment); final NamedXContentRegistry namedXContentRegistry = new NamedXContentRegistry(Collections.emptyList()); @@ -2120,7 +2121,8 @@ public void onFailure(final Exception e) { shardStateAction, actionFilters, new IndexingPressureService(settings, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ) ), new GlobalCheckpointSyncAction( @@ -2130,7 +2132,8 @@ public void onFailure(final Exception e) { indicesService, threadPool, shardStateAction, - actionFilters + actionFilters, + NoopTracer.INSTANCE ), RetentionLeaseSyncer.EMPTY, SegmentReplicationCheckpointPublisher.EMPTY, @@ -2162,7 +2165,8 @@ public void onFailure(final Exception e) { threadPool, metadataCreateIndexService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); final MappingUpdatedAction mappingUpdatedAction = new MappingUpdatedAction(settings, clusterSettings, clusterService); @@ -2186,7 +2190,8 @@ public void onFailure(final Exception e) { mock(ThreadPool.class) ), mock(RemoteStorePressureService.class), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ); actions.put( BulkAction.INSTANCE, @@ -2209,7 +2214,8 @@ public void onFailure(final Exception e) { indexNameExpressionResolver, new AutoCreateIndex(settings, clusterSettings, indexNameExpressionResolver, new SystemIndices(emptyMap())), new IndexingPressureService(settings, clusterService), - new SystemIndices(emptyMap()) + new SystemIndices(emptyMap()), + NoopTracer.INSTANCE ) ); final RestoreService restoreService = new RestoreService( @@ -2238,7 +2244,8 @@ public void onFailure(final Exception e) { metadataMappingService, actionFilters, indexNameExpressionResolver, - new RequestValidators<>(Collections.emptyList()) + new RequestValidators<>(Collections.emptyList()), + NoopTracer.INSTANCE ) ); actions.put( @@ -2249,7 +2256,8 @@ public void onFailure(final Exception e) { threadPool, metadataMappingService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); final ResponseCollectorService responseCollectorService = new ResponseCollectorService(clusterService); @@ -2297,7 +2305,8 @@ public void onFailure(final Exception e) { namedWriteableRegistry, List.of(), client - ) + ), + NoopTracer.INSTANCE ) ); actions.put( @@ -2308,7 +2317,8 @@ public void onFailure(final Exception e) { threadPool, restoreService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); actions.put( @@ -2320,7 +2330,8 @@ public void onFailure(final Exception e) { new MetadataDeleteIndexService(settings, clusterService, allocationService), actionFilters, indexNameExpressionResolver, - new DestructiveOperations(settings, clusterSettings) + new DestructiveOperations(settings, clusterSettings), + NoopTracer.INSTANCE ) ); actions.put( @@ -2331,7 +2342,8 @@ public void onFailure(final Exception e) { repositoriesService, threadPool, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); actions.put( @@ -2343,7 +2355,8 @@ public void onFailure(final Exception e) { snapshotsService, threadPool, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); actions.put( @@ -2354,7 +2367,8 @@ public void onFailure(final Exception e) { threadPool, snapshotsService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); actions.put( @@ -2365,7 +2379,8 @@ public void onFailure(final Exception e) { threadPool, allocationService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); actions.put( @@ -2376,7 +2391,8 @@ public void onFailure(final Exception e) { threadPool, repositoriesService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); actions.put( @@ -2386,7 +2402,8 @@ public void onFailure(final Exception e) { clusterService, threadPool, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); actions.put( @@ -2405,8 +2422,10 @@ public void onFailure(final Exception e) { actionFilters, nodeEnv, indicesService, - namedXContentRegistry - ) + namedXContentRegistry, + NoopTracer.INSTANCE + ), + NoopTracer.INSTANCE ) ); actions.put( @@ -2417,7 +2436,8 @@ public void onFailure(final Exception e) { threadPool, snapshotsService, actionFilters, - indexNameExpressionResolver + indexNameExpressionResolver, + NoopTracer.INSTANCE ) ); DynamicActionRegistry dynamicActionRegistry = new DynamicActionRegistry(); diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java index 8490ee4fc39bc..d570afecdd487 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java @@ -130,6 +130,7 @@ import org.opensearch.search.MockSearchService; import org.opensearch.test.junit.listeners.LoggingListener; import org.opensearch.test.junit.listeners.ReproduceInfoPrinter; +import org.opensearch.test.telemetry.annotation.SkipTracingStrictValidationRule; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; import org.opensearch.transport.nio.MockNioTransportPlugin; @@ -218,6 +219,9 @@ public abstract class OpenSearchTestCase extends LuceneTestCase { private static final Collection nettyLoggedLeaks = new ArrayList<>(); private HeaderWarningAppender headerWarningAppender; + @Rule + public SkipTracingStrictValidationRule skipTracingStrictValidationRule = new SkipTracingStrictValidationRule(); + @AfterClass public static void resetPortCounter() { portGenerator.set(0); diff --git a/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java b/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java new file mode 100644 index 0000000000000..68d8077535bc1 --- /dev/null +++ b/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java @@ -0,0 +1,29 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.test.telemetry.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation to skip Tracing strict check in fatal scenarios like forced node drop etc. where spans can not even be closed + * in the failure and exception scenarios. This annotation should really be used in the fatal scenarios only. + */ + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface SkipTracingStrictValidation { + /** + * Users should define the reason for using this annotation. + * @return + */ + String reason(); +} diff --git a/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidationRule.java b/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidationRule.java new file mode 100644 index 0000000000000..98adb9dda1785 --- /dev/null +++ b/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidationRule.java @@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.test.telemetry.annotation; + +import org.opensearch.test.telemetry.tracing.StrictCheckSpanProcessor; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; + +/** + * Define the rule for Skipping Trace validation. + */ +public class SkipTracingStrictValidationRule extends TestWatcher { + + @Override + public void starting(Description description) { + SkipTracingStrictValidation annotation = description.getAnnotation(SkipTracingStrictValidation.class); + if (annotation != null) { + StrictCheckSpanProcessor.pauseStrictValidation(); + } + } + + @Override + public void finished(Description description) { + SkipTracingStrictValidation annotation = description.getAnnotation(SkipTracingStrictValidation.class); + if (annotation != null) { + StrictCheckSpanProcessor.resumeStrictValidation(); + } + } + +} diff --git a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/StrictCheckSpanProcessor.java b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/StrictCheckSpanProcessor.java index f7ebb3ee18a9b..d6d70417c46b8 100644 --- a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/StrictCheckSpanProcessor.java +++ b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/StrictCheckSpanProcessor.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; /** * Strict check span processor to validate the spans. @@ -28,10 +29,13 @@ public class StrictCheckSpanProcessor implements SpanProcessor { public StrictCheckSpanProcessor() {} private static Map spanMap = new ConcurrentHashMap<>(); + private final static AtomicBoolean enabled = new AtomicBoolean(true); @Override public void onStart(Span span) { - spanMap.put(span.getSpanId(), toMockSpanData(span)); + if (enabled.get() == true) { + spanMap.put(span.getSpanId(), toMockSpanData(span)); + } } @Override @@ -84,4 +88,22 @@ public static void validateTracingStateOnShutdown() { } } + + /** + * Pauses the strict validation check. + */ + public static void pauseStrictValidation() { + if (enabled.get() == true) { + enabled.set(false); + } + } + + /** + * Resumes the strict validation check. + */ + public static void resumeStrictValidation() { + if (enabled.get() == false) { + enabled.set(true); + } + } } From fbb644fe20750489d0be21ee10bd21b5312f4742 Mon Sep 17 00:00:00 2001 From: Gagan Juneja Date: Mon, 18 Sep 2023 17:38:12 +0530 Subject: [PATCH 7/9] Add CHANGELOG Signed-off-by: Gagan Juneja --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 337573480adfd..42c6d9dcb8bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,6 +94,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Allow parameterization of tests with OpenSearchIntegTestCase.SuiteScopeTestCase annotation ([#9916](https://github.com/opensearch-project/OpenSearch/pull/9916)) - Mute the query profile IT with concurrent execution ([#9840](https://github.com/opensearch-project/OpenSearch/pull/9840)) - Add instrumentation in transport service. ([#10042](https://github.com/opensearch-project/OpenSearch/pull/10042)) +- Add instrumentation in transport action. ([#10096](https://github.com/opensearch-project/OpenSearch/pull/10096)) ### Deprecated From a6133749d83dd76a66557041aba87d288acc9dda Mon Sep 17 00:00:00 2001 From: Gagan Juneja Date: Mon, 18 Sep 2023 18:12:02 +0530 Subject: [PATCH 8/9] Fix java doc Signed-off-by: Gagan Juneja --- .../test/telemetry/annotation/SkipTracingStrictValidation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java b/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java index 68d8077535bc1..89b52f17472b8 100644 --- a/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java +++ b/test/framework/src/main/java/org/opensearch/test/telemetry/annotation/SkipTracingStrictValidation.java @@ -23,7 +23,7 @@ public @interface SkipTracingStrictValidation { /** * Users should define the reason for using this annotation. - * @return + * @return reason for skipping the validation. */ String reason(); } From db2e32ec212483614b649ac9a80c242fc17c019a Mon Sep 17 00:00:00 2001 From: Gagan Juneja Date: Mon, 18 Sep 2023 19:32:56 +0530 Subject: [PATCH 9/9] Fix test case Signed-off-by: Gagan Juneja --- .../telemetry/tracing/TelemetryTracerEnabledSanityIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java b/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java index 14a5f8f142a59..b4e0d1048a48f 100644 --- a/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java +++ b/plugins/telemetry-otel/src/internalClusterTest/java/org/opensearch/telemetry/tracing/TelemetryTracerEnabledSanityIT.java @@ -89,7 +89,7 @@ public void testSanityChecksWhenTracingEnabled() throws Exception { InMemorySingletonSpanExporter exporter = InMemorySingletonSpanExporter.INSTANCE; if (!exporter.getFinishedSpanItems().isEmpty()) { - validators.validate(exporter.getFinishedSpanItems(), 6); + validators.validate(exporter.getFinishedSpanItems(), 2); } }