Skip to content

Commit

Permalink
Enable profiling plugin by default
Browse files Browse the repository at this point in the history
Originally the profiling plugin required to set `search.max_buckets` to
a higher value than the current default. Had we enabled the profiling
plugin by default, we would have changed the default value of that
setting for all clusters implicitly. Due to a different bootstrapping
process of the profiling solution, we do not require to change any
settings anymore in the plugin. With this commit we therefore enable the
plugin by default.

Relates elastic#91640
  • Loading branch information
danielmitterdorfer committed Jan 10, 2023
1 parent 8fc2d6a commit 3e47415
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal, otherSettings))
.put(ProfilingPlugin.PROFILING_ENABLED.getKey(), true)
.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME)
.put(NetworkModule.HTTP_TYPE_KEY, Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.aggregations.MultiBucketConsumerService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.tracing.Tracer;
import org.elasticsearch.watcher.ResourceWatcherService;
Expand All @@ -39,7 +38,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.function.Supplier;

import static java.util.Collections.singletonList;
Expand All @@ -48,15 +46,12 @@ public class ProfilingPlugin extends Plugin implements ActionPlugin {
private static final Logger logger = LogManager.getLogger(ProfilingPlugin.class);
public static final Setting<Boolean> PROFILING_ENABLED = Setting.boolSetting(
"xpack.profiling.enabled",
false,
true,
Setting.Property.NodeScope
);
private static final int REQUIRED_MAX_BUCKETS = 150_000;
private final Settings settings;
private final boolean enabled;

public ProfilingPlugin(Settings settings) {
this.settings = settings;
this.enabled = PROFILING_ENABLED.get(settings);
}

Expand Down Expand Up @@ -116,31 +111,6 @@ public List<Setting<?>> getSettings() {
return List.of(PROFILING_ENABLED);
}

@Override
public Settings additionalSettings() {
// workaround until https://github.com/elastic/elasticsearch/issues/91776 is implemented
final Settings.Builder builder = Settings.builder();
if (enabled) {
if (MultiBucketConsumerService.MAX_BUCKET_SETTING.exists(settings) == false) {
logger.debug("Overriding [{}] to [{}].", MultiBucketConsumerService.MAX_BUCKET_SETTING, REQUIRED_MAX_BUCKETS);
builder.put(MultiBucketConsumerService.MAX_BUCKET_SETTING.getKey(), REQUIRED_MAX_BUCKETS);
} else {
Integer configuredMaxBuckets = MultiBucketConsumerService.MAX_BUCKET_SETTING.get(settings);
if (configuredMaxBuckets != null && configuredMaxBuckets < REQUIRED_MAX_BUCKETS) {
final String message = String.format(
Locale.ROOT,
"Profiling requires [%s] to be set at least to [%d] but was configured to [%d].",
MultiBucketConsumerService.MAX_BUCKET_SETTING.getKey(),
REQUIRED_MAX_BUCKETS,
configuredMaxBuckets
);
throw new IllegalArgumentException(message);
}
}
}
return builder.build();
}

@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return List.of(new ActionHandler<>(GetProfilingAction.INSTANCE, TransportGetProfilingAction.class));
Expand Down

0 comments on commit 3e47415

Please sign in to comment.