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

@jaydeluca jaydeluca marked this pull request as ready for review November 28, 2025 20:24
@jaydeluca jaydeluca requested a review from a team as a code owner November 28, 2025 20:24
@jaydeluca jaydeluca changed the title [Spring Starter] Spring boot 4 support (WIP) [Spring Starter] Spring boot 4 support Nov 28, 2025
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?

*/
@ConditionalOnClass({MongoClientSettings.class, MongoClientSettingsBuilderCustomizer.class})
@ConditionalOnEnabledInstrumentation(module = "mongo")
@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 is this 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

Comment on lines +43 to +44
JdbcInstrumentationSpringBoot4AutoConfiguration.class,
DataSourceAutoConfiguration.class))
Copy link
Contributor

Choose a reason for hiding this comment

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

since only there 2 lines are different perhaps it would make sense to introduce a testing module and share code for these tests? idk maybe other tests required more changes.

Copy link
Member

Choose a reason for hiding this comment

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

yeah - I think that could work


// Exclude Spring Boot specific tests from compilation when testLatestDeps is true
// These tests are covered by testSpring4 suite
if (latestDepTest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes when we have a separate suite for new version we limit the latest dep in base version to 1.+ and in version 2 suite either set the version to 2.0 or latest.release depending on the latest dep flag. Would that also work here? Or maybe it would help if these tests were moved to a separate suite and the main test directory would only contain tests that work on all versions?

import org.testcontainers.utility.DockerImageName;

@DisabledInNativeImage // See GraalVmNativeKafkaSpringStarterSmokeTest for the GraalVM native test
class KafkaSpringStarterSmokeTest extends AbstractKafkaSpringStarterSmokeTest {
Copy link
Member

Choose a reason for hiding this comment

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

should be able to extend AbstractJvmKafkaSpringStarterSmokeTest if the auto config class is passed to ctor or can be overridden

(same for mongo)


// JFR based metrics
for (String metric :
List.of(
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 we can also extract a superclass here to avoid the duplication

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