DriverFactory { protected static MetricsProvider createDriverMetrics( Config config, Clock clock ) { if( config.isMetricsEnabled() ) { return new InternalMetricsProvider( clock, config.logging() ); } else { return METRICS_DISABLED_PROVIDER; } }  final Driver newInstance( URI uri, AuthToken authToken, RoutingSettings routingSettings,
                                     RetrySettings retrySettings, Config config, SecurityPlan securityPlan ); final Driver newInstance( URI uri, AuthToken authToken, RoutingSettings routingSettings,
            RetrySettings retrySettings, Config config,  EventLoopGroup eventLoopGroup, SecurityPlan securityPlan );  }
@Test void shouldNotCreateDriverMetrics() { Config config = mock( Config.class ); when( config.isMetricsEnabled() ).thenReturn( false ); MetricsProvider provider = DriverFactory.createDriverMetrics( config, Clock.SYSTEM ); assertThat( provider, is( METRICS_DISABLED_PROVIDER ) ); }
@Test void shouldCreateDriverMetricsIfMonitoringEnabled() { Config config = mock( Config.class ); when( config.isMetricsEnabled() ).thenReturn( true ); when( config.logging() ).thenReturn( Logging.none() ); MetricsProvider provider = DriverFactory.createDriverMetrics( config, Clock.SYSTEM ); assertThat( provider.isMetricsEnabled(), is( true ) ); assertThat( provider instanceof InternalMetricsProvider, is( true ) ); }