Skip to content

Commit

Permalink
use same fallback logic as agent
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed May 16, 2024
1 parent 9fce7e5 commit 645dd40
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
return JdbcTelemetry.builder(openTelemetryProvider.getObject())
.setStatementSanitizationEnabled(
InstrumentationConfigUtil.isStatementSanitizationEnabled(
configPropertiesProvider.getObject(), "otel.instrumentation.jdbc.statement-sanitizer.enabled")
)
configPropertiesProvider.getObject(),
"otel.instrumentation.jdbc.statement-sanitizer.enabled"))
.build()
.wrap(dataSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ public MongoClientSettingsBuilderCustomizer customizer(
builder.addCommandListener(
MongoTelemetry.builder(openTelemetry)
.setStatementSanitizationEnabled(
InstrumentationConfigUtil.isStatementSanitizationEnabled(config,
"otel.instrumentation.mongo.statement-sanitizer.enabled"))
InstrumentationConfigUtil.isStatementSanitizationEnabled(
config, "otel.instrumentation.mongo.statement-sanitizer.enabled"))
.build()
.newCommandListener());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
ConnectionFactory connectionFactory = (ConnectionFactory) bean;
return R2dbcTelemetry.builder(openTelemetryProvider.getObject())
// there is no instrumentation-specific property, so we use the common one
.setStatementSanitizationEnabled(InstrumentationConfigUtil.isStatementSanitizationEnabled(configPropertiesProvider
.getObject(),"otel.instrumentation.common.db-statement-sanitizer.enabled"))
.setStatementSanitizationEnabled(
InstrumentationConfigUtil.isStatementSanitizationEnabled(
configPropertiesProvider.getObject(),
"otel.instrumentation.common.db-statement-sanitizer.enabled"))
.build()
.wrapConnectionFactory(connectionFactory, getConnectionFactoryOptions(connectionFactory));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.spring.autoconfigure.internal;

import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;

public class InstrumentationConfigUtil {
private InstrumentationConfigUtil() {
}
private InstrumentationConfigUtil() {}

public static boolean isStatementSanitizationEnabled(ConfigProperties config, String key) {
return config.getBoolean(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
classes = {OtelSpringStarterSmokeTestApplication.class, SpringSmokeOtelConfiguration.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnabledInNativeImage // see JvmMongodbSpringStarterSmokeTest for the JVM test
@EnabledInGithubActions
@RequiresDockerComposeEnvVariable
public class GraalVmNativeMongodbSpringStarterSmokeTest
extends AbstractMongodbSpringStarterSmokeTest {}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ static class TestConfiguration {
public void loadData() {
jdbcTemplate
.getObject()
.execute("create table customer (id bigint not null, name varchar not null, primary key (id))");
.execute(
"create table customer (id bigint not null, name varchar not null, primary key (id))");
}

@Bean
Expand Down

This file was deleted.

0 comments on commit 645dd40

Please sign in to comment.