Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cdc-service/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions cdc-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -69,10 +66,5 @@ eureka:
logging:
level:
root: INFO
com:
xtrmetl: DEBUG
io:
debezium: INFO
org:
springframework:
web: DEBUG
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading