When Elasticsearch starts up, plugins are loaded based on their inter-dependencies. The specific order used is sometimes useful to see. Currently though the actual order cannot be seen. Instead the modules and plugins are logged in name sorted order after all loading has occurred.

We should be more clear about what order the plugins are actually loaded in, though we do need to be careful as to not add too much noise. I suggest moving the "loaded xxx module" message to the actual loading method in PluginsService (it will require passing through whether the code being loaded is a module or plugin).


server/src/main/java/org/elasticsearch/plugins/PluginsService.java
logger.debug(() -> "Loading bundle: " + plugin.getName() + ", creating spi, modular");
            return createSpiModuleLayer(bundle.spiUrls, parentLoader, extendedPlugins.stream().map(LoadedPlugin::layer).toList());
        } else {
            logger.debug(() -> "Loading bundle: " + plugin.getName() + ", creating spi, non-modular");
            return LayerAndLoader.ofLoader(URLClassLoader.newInstance(bundle.spiUrls.toArray(new URL[0]), parentLoader));
        }
    }
    static LayerAndLoader createPlugin(
        PluginBundle bundle,
        ClassLoader pluginParentLoader,
        List<LoadedPlugin> extendedPlugins,
        LayerAndLoader spiLayerAndLoader
    ) {
        final PluginDescriptor plugin = bundle.plugin;
        if (plugin.getModuleName().isPresent()) {
            logger.debug(() -> "Loading bundle: " + plugin.getName() + ", modular");
            var parentLayers = Stream.concat(
                Stream.ofNullable(spiLayerAndLoader != null ? spiLayerAndLoader.layer() : null),
                extendedPlugins.stream().map(LoadedPlugin::layer)
            ).toList();
            return createPluginModuleLayer(bundle, pluginParentLoader, parentLayers);
        } else if (plugin.isStable()) {
            logger.debug(() -> "Loading bundle: " + plugin.getName() + ", non-modular as synthetic module");
            return LayerAndLoader.ofLoader(
                UberModuleClassLoader.getInstance(
                    pluginParentLoader,
                    ModuleLayer.boot(),
                    "synthetic." + toModuleName(plugin.getName()),
                    bundle.allUrls,
                    Set.of("org.elasticsearch.server")