public void registerPublisher(Function<NodeEngine, MetricsPublisher> registerFunction) {
        if (config.isEnabled()) {
            MetricsPublisher publisher = registerFunction.apply(nodeEngine);
            publishers.add(publisher);
            scheduleMetricsCollectorIfNeeded();
        } else {
            logger.fine("Custom publisher is not registered with function %s as the metrics system is disabled",
                    registerFunction);
        }
    }
@Test
    public void testMetricsCollectedIfMetricsEnabledAndMcJmxDisabledButCustomPublisherRegistered() {
        config.getMetricsConfig()
              .setEnabled(true);
        config.getMetricsConfig().getManagementCenterConfig()
              .setEnabled(false);
        config.getMetricsConfig().getJmxConfig()
              .setEnabled(false);

        MetricsPublisher publisherMock = mock(MetricsPublisher.class);
        MetricsService metricsService = prepareMetricsService();
        metricsService.registerPublisher(nodeEngine -> publisherMock);

        assertTrueEventually(() -> {
            verify(publisherMock, atLeastOnce()).publishDouble(any(), anyDouble());
            verify(publisherMock, atLeastOnce()).publishLong(any(), anyLong());
        });
    }