diff --git a/modules/tracer-otel/src/main/java/org/opensearch/tracing/OTelTracerModulePlugin.java b/modules/tracer-otel/src/main/java/org/opensearch/tracing/OTelTracerModulePlugin.java index 845028cf9c7b9..dc5790ba984e0 100644 --- a/modules/tracer-otel/src/main/java/org/opensearch/tracing/OTelTracerModulePlugin.java +++ b/modules/tracer-otel/src/main/java/org/opensearch/tracing/OTelTracerModulePlugin.java @@ -10,6 +10,7 @@ import io.opentelemetry.api.OpenTelemetry; import org.opensearch.common.settings.Settings; +import org.opensearch.common.util.FeatureFlags; import org.opensearch.plugins.Plugin; import org.opensearch.plugins.TracerPlugin; import org.opensearch.threadpool.ThreadPool; @@ -18,6 +19,8 @@ import java.util.Map; import java.util.function.Supplier; +import static org.opensearch.common.util.FeatureFlags.TRACER; + /** * Tracer plugin based on Otel */ @@ -32,10 +35,13 @@ public OTelTracerModulePlugin() {} @Override public Settings additionalSettings() { - return Settings.builder() - // set Otel tracer as default tracer - .put(TracerModule.TRACER_DEFAULT_TYPE_SETTING.getKey(), OTEL_TRACER_NAME) - .build(); + if (FeatureFlags.isEnabled(TRACER)) { + return Settings.builder() + // set Otel tracer as default tracer + .put(TracerModule.TRACER_DEFAULT_TYPE_SETTING.getKey(), OTEL_TRACER_NAME) + .build(); + } + return Settings.EMPTY; } @Override diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 1be07a7c29675..9b0f98a8eaaaf 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -651,15 +651,8 @@ public void apply(Settings value, Settings current, Settings previous) { RemoteRefreshSegmentPressureSettings.MIN_CONSECUTIVE_FAILURES_LIMIT, RemoteRefreshSegmentPressureSettings.UPLOAD_BYTES_MOVING_AVERAGE_WINDOW_SIZE, RemoteRefreshSegmentPressureSettings.UPLOAD_BYTES_PER_SEC_MOVING_AVERAGE_WINDOW_SIZE, - RemoteRefreshSegmentPressureSettings.UPLOAD_TIME_MOVING_AVERAGE_WINDOW_SIZE, + RemoteRefreshSegmentPressureSettings.UPLOAD_TIME_MOVING_AVERAGE_WINDOW_SIZE - // Settings related to Tracing framework - TracerSettings.TRACER_LEVEL_SETTING, - TracerSettings.TRACER_EXPORTER_DELAY_SETTING, - TracerSettings.TRACER_EXPORTER_BATCH_SIZE_SETTING, - TracerSettings.TRACER_EXPORTER_MAX_QUEUE_SIZE_SETTING, - TracerModule.TRACER_DEFAULT_TYPE_SETTING, - TracerModule.TRACER_TYPE_SETTING ) ) ); @@ -678,6 +671,15 @@ public void apply(Settings value, Settings current, Settings previous) { IndicesService.CLUSTER_REMOTE_STORE_REPOSITORY_SETTING, IndicesService.CLUSTER_REMOTE_TRANSLOG_STORE_ENABLED_SETTING, IndicesService.CLUSTER_REMOTE_TRANSLOG_REPOSITORY_SETTING + ), + List.of(FeatureFlags.TRACER), + List.of( + TracerSettings.TRACER_LEVEL_SETTING, + TracerSettings.TRACER_EXPORTER_DELAY_SETTING, + TracerSettings.TRACER_EXPORTER_BATCH_SIZE_SETTING, + TracerSettings.TRACER_EXPORTER_MAX_QUEUE_SIZE_SETTING, + TracerModule.TRACER_TYPE_SETTING, + TracerModule.TRACER_DEFAULT_TYPE_SETTING ) ); } diff --git a/server/src/main/java/org/opensearch/common/settings/FeatureFlagSettings.java b/server/src/main/java/org/opensearch/common/settings/FeatureFlagSettings.java index 19a5808579d50..61b0cfb7dab88 100644 --- a/server/src/main/java/org/opensearch/common/settings/FeatureFlagSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/FeatureFlagSettings.java @@ -39,7 +39,8 @@ protected FeatureFlagSettings( FeatureFlags.EXTENSIONS_SETTING, FeatureFlags.IDENTITY_SETTING, FeatureFlags.SEARCH_PIPELINE_SETTING, - FeatureFlags.CONCURRENT_SEGMENT_SEARCH_SETTING + FeatureFlags.CONCURRENT_SEGMENT_SEARCH_SETTING, + FeatureFlags.TRACER_SETTING ) ) ); diff --git a/server/src/main/java/org/opensearch/common/util/FeatureFlags.java b/server/src/main/java/org/opensearch/common/util/FeatureFlags.java index a26b4006bb31e..ee1e4dbe19759 100644 --- a/server/src/main/java/org/opensearch/common/util/FeatureFlags.java +++ b/server/src/main/java/org/opensearch/common/util/FeatureFlags.java @@ -63,6 +63,11 @@ public class FeatureFlags { */ public static final String CONCURRENT_SEGMENT_SEARCH = "opensearch.experimental.feature.concurrent_segment_search.enabled"; + /** + * Gates the functionality of tracing framework. + */ + public static final String TRACER = "opensearch.experimental.feature.tracer.enabled"; + /** * Should store the settings from opensearch.yml. */ @@ -105,6 +110,8 @@ public static boolean isEnabled(String featureFlagName) { public static final Setting IDENTITY_SETTING = Setting.boolSetting(IDENTITY, false, Property.NodeScope); + public static final Setting TRACER_SETTING = Setting.boolSetting(TRACER, false, Property.NodeScope); + public static final Setting CONCURRENT_SEGMENT_SEARCH_SETTING = Setting.boolSetting( CONCURRENT_SEGMENT_SEARCH, false, diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index bd50f6521608d..3e1f5679bf4db 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -256,6 +256,7 @@ import static java.util.stream.Collectors.toList; import static org.opensearch.common.util.FeatureFlags.SEARCH_PIPELINE; +import static org.opensearch.common.util.FeatureFlags.TRACER; import static org.opensearch.env.NodeEnvironment.collectFileCacheDataPath; import static org.opensearch.index.ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED_ATTRIBUTE_KEY; @@ -1012,11 +1013,13 @@ protected Node( searchModule.getIndexSearcherExecutor(threadPool) ); - final TracerSettings tracerSettings = new TracerSettings(settings, clusterService.getClusterSettings()); - List tracerPlugins = pluginsService.filterPlugins(TracerPlugin.class); - TracerModule tracerModule = new TracerModule(settings, tracerPlugins, threadPool, tracerSettings); - TracerManager.initTracerManager(tracerSettings, tracerModule.getTracerSupplier(), tracerModule.getTracerHeaderInjector()); - resourcesToClose.add(TracerManager::closeTracer); + if (FeatureFlags.isEnabled(TRACER)) { + final TracerSettings tracerSettings = new TracerSettings(settings, clusterService.getClusterSettings()); + List tracerPlugins = pluginsService.filterPlugins(TracerPlugin.class); + TracerModule tracerModule = new TracerModule(settings, tracerPlugins, threadPool, tracerSettings); + TracerManager.initTracerManager(tracerSettings, tracerModule.getTracerSupplier(), tracerModule.getTracerHeaderInjector()); + resourcesToClose.add(TracerManager::closeTracer); + } final List> tasksExecutors = pluginsService.filterPlugins(PersistentTaskPlugin.class) .stream() @@ -1475,7 +1478,9 @@ public synchronized void close() throws IOException { toClose.add(() -> stopWatch.stop().start("node_environment")); toClose.add(injector.getInstance(NodeEnvironment.class)); toClose.add(stopWatch::stop); - toClose.add(TracerManager::closeTracer); + if (FeatureFlags.isEnabled(TRACER)) { + toClose.add(TracerManager::closeTracer); + } if (logger.isTraceEnabled()) { toClose.add(() -> logger.trace("Close times for each service:\n{}", stopWatch.prettyPrint()));