Skip to content

Conversation

@jaydeluca
Copy link
Member

@jaydeluca jaydeluca commented Nov 26, 2025

Related to #14906

Notes:

  • it seems that native graal spring boot 4 apps only work with java 25, so I've limited the graal smoke tests to 25+

I tried to avoid as much duplication as I could, If anyone has suggestions on areas to revisit, I can try again

@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label Nov 26, 2025
@jaydeluca jaydeluca force-pushed the spring-boot-4-autoconfigure branch from 0949e97 to 330cd89 Compare November 26, 2025 13:18
@George-C-Odes
Copy link

Would that resolve the missing metrics going to mimir on spring boot 4 setup using the java agent @jaydeluca ?
Do you have an ETA?

@jaydeluca
Copy link
Member Author

@George-C-Odes there is no ETA, im working on this as I can.

@jaydeluca
Copy link
Member Author

my goal is to get this all completed before the next release 🤞. This is just the spring boot starter, there are still other javaagent instrumentations that need to be fixed too

Copy link
Member

@zeitlinger zeitlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great to see that the code size is getting smaller now 😄

@ConditionalOnBean({DataSource.class})
@ConditionalOnMissingClass(
"org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration") // Spring Boot 4+
@ConditionalOnClass(DataSourceAutoConfiguration.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment back? e.g. "removed in Spring Boot 4"

@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingClass(
"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration") // Spring Boot 2 & 3
@ConditionalOnClass(DataSourceAutoConfiguration.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

condition looks identical to boot 3

DefaultKafkaProducerFactoryCustomizer.class
})
@ConditionalOnMissingBean(name = "otelKafkaProducerFactoryCustomizer")
@ConditionalOnMissingClass(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not needed anymore?

@Autowired private RestTemplateBuilder restTemplateBuilder;
@Autowired private JdbcTemplate jdbcTemplate;

abstract void makeClientCall();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

public JdbcInstrumentationSpringBoot4AutoConfiguration() {}

@Bean
// static to avoid "is not eligible for getting processed by all BeanPostProcessors" warning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really for this PR but I suspect that (proxyBeanMethods = false) has the same effect as making the method static. If I remember correctly the warning was triggered by proxying the configuration class methods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right - that would be a nice follow-up PR

Comment on lines 37 to 42
@Bean
DefaultKafkaProducerFactoryCustomizer otelKafkaProducerFactoryCustomizer(
OpenTelemetry openTelemetry) {
KafkaTelemetry kafkaTelemetry = KafkaTelemetry.create(openTelemetry);
return producerFactory -> producerFactory.addPostProcessor(kafkaTelemetry::wrap);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually only this bean is different for spring boot 4. Wondering whether it would make sense to move this bean into separate (maybe nested?) configuration class so that the other beans wouldn't need to be copy-pasted. Or is that too much effort?

Copy link
Member

@zeitlinger zeitlinger Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the imports are also different for the others

image

() -> getTelemetry(openTelemetryProvider, configProvider));
}

@ConditionalOnClass(DefaultKafkaProducerFactoryCustomizer.class)
Copy link
Contributor

@laurit laurit Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also need to add @ConditionalOnEnabledInstrumentation(module = "kafka") here or is it somehow automatically inherited from the outer class?
Imo the way it is now pushing this into a nested configuration class doesn't make sense. If you'd remove DefaultKafkaProducerFactoryCustomizer condition from the outer class and only leave it on the inner class then the outer class could also be used for spring boot 4 and you'd only need to provide a spring boot 4 version of what the inner class does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it somehow automatically inherited from the outer class?

yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo the way it is now pushing this into a nested configuration class doesn't make sense

agree - does it work if you inline the bean method?

@@ -1,2 +1,2 @@
Comparing source compatibility of opentelemetry-spring-boot-autoconfigure-2.23.0-SNAPSHOT.jar against opentelemetry-spring-boot-autoconfigure-2.22.0.jar
Comparing source compatibility of opentelemetry-spring-boot-autoconfigure-2.23.0-SNAPSHOT.jar against
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm still trying to figure this out. the build is failing for this

Run # need to "git add" in case any generated files did not already exist
Diff detected - did you run './gradlew jApiCmp'?
docs/apidiffs/current_vs_latest/opentelemetry-spring-boot-autoconfigure.txt
diff --git a/docs/apidiffs/current_vs_latest/opentelemetry-spring-boot-autoconfigure.txt b/docs/apidiffs/current_vs_latest/opentelemetry-spring-boot-autoconfigure.txt
index 7e15cee7..9dfa3287 100644
--- a/docs/apidiffs/current_vs_latest/opentelemetry-spring-boot-autoconfigure.txt
+++ b/docs/apidiffs/current_vs_latest/opentelemetry-spring-boot-autoconfigure.txt
@@ -1,2 +1,2 @@
-Comparing source compatibility of opentelemetry-spring-boot-autoconfigure-2.23.0-SNAPSHOT.jar against opentelemetry-spring-boot-autoconfigure-2.22.0.jar
+Comparing source compatibility of opentelemetry-spring-boot-autoconfigure-2.23.0-SNAPSHOT.jar against
No changes.
\ No newline at end of file

and when i run ./gradlew :instrumentation:spring:spring-boot-autoconfigure:jApiCmp or ./gradlew jApiCmp I get the same result.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try deleting the file and rebasing against main?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it for you

@laurit laurit added this to the v2.23.0 milestone Dec 4, 2025
// Spring Boot 2 & 3
"org.springframework.boot.autoconfigure.kafka.DefaultKafkaProducerFactoryCustomizer")
@Configuration
public class KafkaInstrumentationSpringBoot4AutoConfiguration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this class still needed? Tests pass without it.

exclude("ch.qos.logback", "logback-classic")
}
// testSpring2: configure Spring Boot 3.x dependencies for latest dep testing
if (name == "testSpring2Implementation") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this does not involve any latest dep checks this will bump the version to latest spring 3 even in regular tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants