diff --git a/cdc-service/src/main/resources/application-local.yml b/cdc-service/src/main/resources/application-local.yml new file mode 100644 index 00000000..8b1aaf12 --- /dev/null +++ b/cdc-service/src/main/resources/application-local.yml @@ -0,0 +1,17 @@ +spring: + config: + activate: + on-profile: local + +management: + tracing: + sampling: + probability: 1.0 + +logging: + level: + com: + xtrmetl: DEBUG + org: + springframework: + web: DEBUG diff --git a/cdc-service/src/main/resources/application.yml b/cdc-service/src/main/resources/application.yml index b299ebc9..ca4fcb9f 100644 --- a/cdc-service/src/main/resources/application.yml +++ b/cdc-service/src/main/resources/application.yml @@ -46,9 +46,6 @@ xtrmetl: ddl-blocked-prefixes: ${REPLICA_DDL_BLOCKED_PREFIXES:DROP TABLE,DROP SCHEMA,DROP DATABASE,TRUNCATE} management: - tracing: - sampling: - probability: 1.0 zipkin: tracing: endpoint: http://${ZIPKIN_HOST:localhost}:9412/api/v2/spans @@ -69,10 +66,5 @@ eureka: logging: level: root: INFO - com: - xtrmetl: DEBUG io: debezium: INFO - org: - springframework: - web: DEBUG diff --git a/cdc-service/src/test/java/com/xtrmetl/cdc/config/CdcObservabilityProfileContractTest.java b/cdc-service/src/test/java/com/xtrmetl/cdc/config/CdcObservabilityProfileContractTest.java new file mode 100644 index 00000000..6520b32c --- /dev/null +++ b/cdc-service/src/test/java/com/xtrmetl/cdc/config/CdcObservabilityProfileContractTest.java @@ -0,0 +1,52 @@ +package com.xtrmetl.cdc.config; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; +import org.springframework.core.io.ClassPathResource; + +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Guards the deployable CDC configuration against silently enabling local-debug observability. + */ +class CdcObservabilityProfileContractTest { + + @Test + void baseConfigurationDoesNotForceDebugLoggingOrFullTraceSampling() { + Properties properties = load("application.yml"); + + assertNull(properties.getProperty("management.tracing.sampling.probability"), + "base CDC configuration must retain Spring Boot's bounded default sampling policy"); + assertNull(properties.getProperty("logging.level.com.xtrmetl"), + "base CDC configuration must not force application DEBUG logging"); + assertNull(properties.getProperty("logging.level.org.springframework.web"), + "base CDC configuration must not force Spring Web DEBUG logging"); + } + + @Test + void localProfileExplicitlyRestoresDeveloperVerboseObservability() { + ClassPathResource localProfile = new ClassPathResource("application-local.yml"); + assertTrue(localProfile.exists(), + "local CDC profile must preserve the opt-in developer observability contract"); + + Properties properties = load("application-local.yml"); + assertEquals("local", properties.getProperty("spring.config.activate.on-profile")); + assertEquals("1.0", properties.getProperty("management.tracing.sampling.probability")); + assertEquals("DEBUG", properties.getProperty("logging.level.com.xtrmetl")); + assertEquals("DEBUG", properties.getProperty("logging.level.org.springframework.web")); + } + + private static Properties load(String resourceName) { + YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean(); + yaml.setResources(new ClassPathResource(resourceName)); + Properties properties = yaml.getObject(); + if (properties == null) { + throw new IllegalStateException("Could not load " + resourceName); + } + return properties; + } +}