From 29fca2ffc5f6aea73ebbb0577ad27614269e1e7c Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 15 May 2024 13:41:17 +0200 Subject: [PATCH] fix test --- .../r2dbc/R2dbcAutoConfiguration.java | 6 +----- .../r2dbc/R2dbcInstrumentingPostProcessor.java | 13 +++++++++---- .../AbstractOtelReactiveSpringStarterSmokeTest.java | 7 +------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcAutoConfiguration.java index 91586051027c..94dd904029a5 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcAutoConfiguration.java @@ -31,10 +31,6 @@ public R2dbcAutoConfiguration() {} static R2dbcInstrumentingPostProcessor r2dbcInstrumentingPostProcessor( ObjectProvider openTelemetryProvider, ObjectProvider configPropertiesProvider) { - return new R2dbcInstrumentingPostProcessor( - openTelemetryProvider, - configPropertiesProvider - .getObject() - .getBoolean("otel.instrumentation.common.db-statement-sanitizer.enabled", true)); + return new R2dbcInstrumentingPostProcessor(openTelemetryProvider, configPropertiesProvider); } } diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentingPostProcessor.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentingPostProcessor.java index 38b19a3a4b85..fd9d78359fd0 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentingPostProcessor.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentingPostProcessor.java @@ -7,6 +7,7 @@ import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.instrumentation.r2dbc.v1_0.R2dbcTelemetry; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.r2dbc.spi.ConnectionFactory; import io.r2dbc.spi.ConnectionFactoryOptions; import org.springframework.aop.scope.ScopedProxyUtils; @@ -17,12 +18,13 @@ class R2dbcInstrumentingPostProcessor implements BeanPostProcessor { private final ObjectProvider openTelemetryProvider; - private final boolean statementSanitizationEnabled; + private final ObjectProvider configPropertiesProvider; R2dbcInstrumentingPostProcessor( - ObjectProvider openTelemetryProvider, boolean statementSanitizationEnabled) { + ObjectProvider openTelemetryProvider, + ObjectProvider configPropertiesProvider) { this.openTelemetryProvider = openTelemetryProvider; - this.statementSanitizationEnabled = statementSanitizationEnabled; + this.configPropertiesProvider = configPropertiesProvider; } @Override @@ -30,7 +32,10 @@ public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof ConnectionFactory && !ScopedProxyUtils.isScopedTarget(beanName)) { ConnectionFactory connectionFactory = (ConnectionFactory) bean; return R2dbcTelemetry.builder(openTelemetryProvider.getObject()) - .setStatementSanitizationEnabled(statementSanitizationEnabled) + .setStatementSanitizationEnabled( + configPropertiesProvider + .getObject() + .getBoolean("otel.instrumentation.common.db-statement-sanitizer.enabled", true)) .build() .wrapConnectionFactory(connectionFactory, getConnectionFactoryOptions(connectionFactory)); } diff --git a/smoke-tests-otel-starter/spring-boot-reactive-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelReactiveSpringStarterSmokeTest.java b/smoke-tests-otel-starter/spring-boot-reactive-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelReactiveSpringStarterSmokeTest.java index 7d2d6e344b99..919c9af720b9 100644 --- a/smoke-tests-otel-starter/spring-boot-reactive-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelReactiveSpringStarterSmokeTest.java +++ b/smoke-tests-otel-starter/spring-boot-reactive-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelReactiveSpringStarterSmokeTest.java @@ -68,18 +68,13 @@ void webClientAndWebFluxAndR2dbc() { assertThat(s.getName()) .isEqualToIgnoringCase("SELECT testdb.PLAYER")) .hasAttribute(DbIncubatingAttributes.DB_NAME, "testdb") - .hasAttributesSatisfying( - a -> - assertThat(a.get(DbIncubatingAttributes.DB_SQL_TABLE)) - .isEqualToIgnoringCase("PLAYER")) - .hasAttribute(DbIncubatingAttributes.DB_OPERATION, "SELECT") // 1 is not replaced by ?, // otel.instrumentation.common.db-statement-sanitizer.enabled=false .hasAttributesSatisfying( a -> assertThat(a.get(DbIncubatingAttributes.DB_STATEMENT)) .isEqualToIgnoringCase( - "SELECT PLAYER.* FROM PLAYER WHERE PLAYER.ID = 1 LIMIT ?")) + "SELECT PLAYER.* FROM PLAYER WHERE PLAYER.ID = $1 LIMIT 2")) .hasAttribute(DbIncubatingAttributes.DB_SYSTEM, "h2"))); } }