Skip to content

Commit 330cd89

Browse files
committed
most things working
1 parent 6c13ecb commit 330cd89

File tree

16 files changed

+359
-158
lines changed

16 files changed

+359
-158
lines changed

instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,15 @@ dependencies {
120120

121121
// Spring Boot 4
122122
add("javaSpring4CompileOnly", files(sourceSets.main.get().output.classesDirs))
123-
// add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-starter-web:4.0.0")
124123
add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-starter-kafka:4.0.0")
125124
add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-autoconfigure:4.0.0")
126125
add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-jdbc:4.0.0")
127126
add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-starter-jdbc:4.0.0")
128127
add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-restclient:4.0.0")
129-
// add("javaSpring4CompileOnly", "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
130-
// add("javaSpring4CompileOnly", project(":instrumentation:spring:spring-web:spring-web-3.1:library"))
131-
// add("javaSpring4CompileOnly", project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library"))
128+
add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-starter-data-mongodb:4.0.0")
132129
add("javaSpring4CompileOnly", project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library"))
133130
add("javaSpring4CompileOnly", project(":instrumentation:spring:spring-kafka-2.7:library"))
134-
// add("javaSpring4CompileOnly", project(":instrumentation:micrometer:micrometer-1.5:library"))
131+
add("javaSpring4CompileOnly", project(":instrumentation:mongo:mongo-3.1:library"))
135132
}
136133

137134
val latestDepTest = findProperty("testLatestDeps") as Boolean
@@ -202,14 +199,10 @@ testing {
202199
val testSpring4 by registering(JvmTestSuite::class) {
203200
dependencies {
204201
implementation(project())
205-
// implementation("org.springframework.boot:spring-boot-starter-web:4.0.0")
206-
implementation("org.springframework.boot:spring-boot-starter-jdbc:4.0.0")
207202
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
203+
implementation("org.springframework.boot:spring-boot-starter-jdbc:4.0.0")
208204
implementation("org.springframework.boot:spring-boot-restclient:4.0.0")
209205
implementation("org.springframework.boot:spring-boot-starter-kafka:4.0.0")
210-
// implementation(project(":instrumentation:spring:spring-web:spring-web-3.1:library"))
211-
// implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library"))
212-
// implementation("jakarta.servlet:jakarta.servlet-api:6.1.0")
213206
implementation("org.springframework.boot:spring-boot-starter-test:4.0.0") {
214207
exclude("org.junit.vintage", "junit-vintage-engine")
215208
}

instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/mongo/MongoClientInstrumentationAutoConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation;
1313
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.InstrumentationConfigUtil;
1414
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
15+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
1516
import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer;
1617
import org.springframework.context.annotation.Bean;
1718
import org.springframework.context.annotation.Configuration;
@@ -22,6 +23,8 @@
2223
*/
2324
@ConditionalOnClass({MongoClientSettings.class, MongoClientSettingsBuilderCustomizer.class})
2425
@ConditionalOnEnabledInstrumentation(module = "mongo")
26+
@ConditionalOnMissingClass(
27+
"org.springframework.boot.mongodb.autoconfigure.MongoClientSettingsBuilderCustomizer")
2528
@Configuration
2629
public class MongoClientInstrumentationAutoConfiguration {
2730

instrumentation/spring/spring-boot-autoconfigure/src/main/javaSpring4/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/kafka/ConcurrentKafkaListenerContainerFactorySpringBoot4PostProcessor.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

instrumentation/spring/spring-boot-autoconfigure/src/main/javaSpring4/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/kafka/KafkaInstrumentationSpringBoot4AutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ static SpringKafkaTelemetry getTelemetry(
6363
havingValue = "true",
6464
matchIfMissing = true)
6565
@ConditionalOnMissingBean
66-
static ConcurrentKafkaListenerContainerFactorySpringBoot4PostProcessor
66+
static ConcurrentKafkaListenerContainerFactoryPostProcessor
6767
otelKafkaListenerContainerFactoryBeanPostProcessor(
6868
ObjectProvider<OpenTelemetry> openTelemetryProvider,
6969
ObjectProvider<InstrumentationConfig> configProvider) {
70-
return new ConcurrentKafkaListenerContainerFactorySpringBoot4PostProcessor(
70+
return new ConcurrentKafkaListenerContainerFactoryPostProcessor(
7171
() -> getTelemetry(openTelemetryProvider, configProvider));
7272
}
7373
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.mongo;
7+
8+
import com.mongodb.MongoClientSettings;
9+
import io.opentelemetry.api.OpenTelemetry;
10+
import io.opentelemetry.instrumentation.api.incubator.config.internal.InstrumentationConfig;
11+
import io.opentelemetry.instrumentation.mongo.v3_1.MongoTelemetry;
12+
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation;
13+
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.InstrumentationConfigUtil;
14+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
15+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
16+
import org.springframework.boot.mongodb.autoconfigure.MongoClientSettingsBuilderCustomizer;
17+
import org.springframework.context.annotation.Bean;
18+
import org.springframework.context.annotation.Configuration;
19+
20+
/**
21+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
22+
* any time.
23+
*/
24+
@ConditionalOnClass({MongoClientSettings.class, MongoClientSettingsBuilderCustomizer.class})
25+
@ConditionalOnEnabledInstrumentation(module = "mongo")
26+
@ConditionalOnMissingClass(
27+
"org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer")
28+
@Configuration
29+
public class MongoClientInstrumentationSpringBoot4AutoConfiguration {
30+
31+
@Bean
32+
MongoClientSettingsBuilderCustomizer customizer(
33+
OpenTelemetry openTelemetry, InstrumentationConfig config) {
34+
return builder ->
35+
builder.addCommandListener(
36+
MongoTelemetry.builder(openTelemetry)
37+
.setStatementSanitizationEnabled(
38+
InstrumentationConfigUtil.isStatementSanitizationEnabled(
39+
config, "otel.instrumentation.mongo.statement-sanitizer.enabled"))
40+
.build()
41+
.newCommandListener());
42+
}
43+
}

instrumentation/spring/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfigura
33
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.annotations.InstrumentationAnnotationsAutoConfiguration,\
44
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.kafka.KafkaInstrumentationAutoConfiguration,\
55
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.mongo.MongoClientInstrumentationAutoConfiguration,\
6+
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.mongo.MongoClientInstrumentationSpringBoot4AutoConfiguration,\
67
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.logging.OpenTelemetryAppenderAutoConfiguration,\
78
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.jdbc.JdbcInstrumentationAutoConfiguration,\
89
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.micrometer.MicrometerBridgeAutoConfiguration,\

instrumentation/spring/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfigura
22
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.annotations.InstrumentationAnnotationsAutoConfiguration
33
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.kafka.KafkaInstrumentationAutoConfiguration
44
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.kafka.KafkaInstrumentationSpringBoot4AutoConfiguration
5-
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.mongo.MongoClientInstrumentationAutoConfiguration
5+
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.mongo.MongoClientInstrumentationSpringBoot4AutoConfiguration
66
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.logging.OpenTelemetryAppenderAutoConfiguration
77
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.jdbc.JdbcInstrumentationAutoConfiguration
88
io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.jdbc.JdbcInstrumentationSpringBoot4AutoConfiguration

smoke-tests-otel-starter/spring-boot-4/build.gradle.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@ otelJava {
1010
}
1111

1212
dependencies {
13-
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
14-
1513
implementation("org.springframework.boot:spring-boot-starter-web")
1614
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
1715
implementation("org.springframework.boot:spring-boot-starter-kafka")
18-
testImplementation("org.springframework:spring-aop")
19-
testImplementation("org.aspectj:aspectjweaver")
16+
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
17+
implementation("org.springframework:spring-aop")
18+
implementation("org.aspectj:aspectjweaver")
19+
implementation("org.apache.commons:commons-dbcp2")
2020
runtimeOnly("com.h2database:h2")
21+
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
2122

2223
implementation(project(":smoke-tests-otel-starter:spring-boot-common"))
2324

2425
testImplementation("org.springframework.boot:spring-boot-starter-test")
2526
testImplementation("org.springframework.boot:spring-boot-resttestclient")
27+
testImplementation("org.springframework.boot:spring-boot-starter-data-mongodb")
2628
testImplementation(project(":instrumentation:spring:starters:spring-boot-starter"))
2729
testImplementation(project(":smoke-tests-otel-starter:spring-smoke-testing"))
2830
testImplementation("org.springframework.boot:spring-boot-starter-kafka")
2931
testImplementation("org.testcontainers:testcontainers-junit-jupiter")
3032
testImplementation("org.testcontainers:testcontainers-kafka")
33+
testImplementation("org.testcontainers:testcontainers-mongodb")
3134
}
3235

3336
springBoot {

smoke-tests-otel-starter/spring-boot-4/src/test/java/io/opentelemetry/spring/smoketest/AbstractJvmKafkaSpringStarterSmokeTest.java

Lines changed: 0 additions & 79 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.spring.smoketest;
7+
8+
import org.junit.jupiter.api.condition.EnabledInNativeImage;
9+
import org.springframework.boot.test.context.SpringBootTest;
10+
11+
/**
12+
* GraalVM native image doesn't support Testcontainers in our case, so the docker container is
13+
* started manually before running the tests.
14+
*
15+
* <p>In other cases, it does work, e.g. <a
16+
* href="https://info.michael-simons.eu/2023/10/25/run-your-integration-tests-against-testcontainers-with-graalvm-native-image/">here</a>,
17+
* it's not yet clear why it doesn't work in our case.
18+
*
19+
* <p>In CI, this is done in reusable-native-tests.yml. If you want to run the tests locally, you
20+
* need to start the container manually: see .github/workflows/reusable-native-tests.yml for the
21+
* command.
22+
*/
23+
@SpringBootTest(
24+
classes = {
25+
OtelSpringStarterSmokeTestApplication.class,
26+
SpringSmokeOtelConfiguration.class,
27+
AbstractKafkaSpringStarterSmokeTest.KafkaConfig.class
28+
},
29+
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
30+
@EnabledInNativeImage // see AbstractJvmKafkaSpringStarterSmokeTest for the JVM test
31+
@RequiresDockerCompose
32+
class GraalVmNativeKafkaSpringStarterSmokeTest extends AbstractKafkaSpringStarterSmokeTest {}

0 commit comments

Comments
 (0)