@@ -93,27 +93,35 @@ void shouldRegisterRuntimeTelemetryByDefault() {
9393 }
9494
9595 @ Test
96- void shouldSkipRuntimeTelemetryWhenDisabledBySystemProperty () {
97- System .setProperty ("otel.instrumentation.runtime-telemetry.enabled" , "false" );
98- try {
99- new OtelModule (OpenTelemetry .noop ()).install (application );
100- } finally {
101- System .clearProperty ("otel.instrumentation.runtime-telemetry.enabled" );
102- }
96+ void shouldSkipRuntimeTelemetryWhenDisabledByConfig () {
97+ when (application .getConfig ()).thenReturn (rootConfig );
98+ when (rootConfig .hasPath ("otel.instrumentation.runtime-telemetry.enabled" )).thenReturn (true );
99+ when (rootConfig .getBoolean ("otel.instrumentation.runtime-telemetry.enabled" )).thenReturn (false );
100+
101+ new OtelModule (OpenTelemetry .noop ()).install (application );
103102
104103 verify (application , never ()).onStop (any (AutoCloseable .class ));
105104 }
106105
107106 @ Test
108- void shouldSkipRuntimeTelemetryWhenDisabledByConfig () {
107+ void shouldRegisterRuntimeTelemetryWhenEnabledByConfig () {
109108 when (application .getConfig ()).thenReturn (rootConfig );
110109 when (rootConfig .hasPath ("otel.instrumentation.runtime-telemetry.enabled" )).thenReturn (true );
111- when (rootConfig .getValue ("otel.instrumentation.runtime-telemetry.enabled" ))
112- .thenReturn (ConfigValueFactory .fromAnyRef (false ));
110+ when (rootConfig .getBoolean ("otel.instrumentation.runtime-telemetry.enabled" )).thenReturn (true );
113111
114112 new OtelModule (OpenTelemetry .noop ()).install (application );
115113
116- verify (application , never ()).onStop (any (AutoCloseable .class ));
114+ verify (application ).onStop (any (AutoCloseable .class ));
115+ }
116+
117+ @ Test
118+ void shouldRegisterRuntimeTelemetryWhenConfigHasNoSetting () {
119+ when (application .getConfig ()).thenReturn (rootConfig );
120+ when (rootConfig .hasPath ("otel.instrumentation.runtime-telemetry.enabled" )).thenReturn (false );
121+
122+ new OtelModule (OpenTelemetry .noop ()).install (application );
123+
124+ verify (application ).onStop (any (AutoCloseable .class ));
117125 }
118126
119127 @ Test
0 commit comments