<T extends MetricsPlugin> T getPlugin(String name) {
        String classKey = name.isEmpty() ? "class" : name + ".class";
        String pluginClassName = getString(classKey);
        if (pluginClassName == null || pluginClassName.isEmpty()) {
            return null;
        }
        try {
            Class<?> pluginClass = Class.forName(pluginClassName);
            @SuppressWarnings("unchecked")
            T plugin = (T) pluginClass.newInstance();
            plugin.init(name.isEmpty() ? this : subset(name));
            return plugin;
        } catch (Exception e) {
            throw new MetricsConfigException("Error creating plugin: " + pluginClassName, e);
        }
    }