Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-configure observations for RestClients #38500

Closed
atrepczik opened this issue Nov 22, 2023 · 0 comments
Closed

Auto-configure observations for RestClients #38500

atrepczik opened this issue Nov 22, 2023 · 0 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@atrepczik
Copy link

atrepczik commented Nov 22, 2023

I was trying out Spring Boot 3.2.0-RC2 and was quite surprised that a RestClient created via RestClient.builder().build() is not auto-instrumented like RestTemplate and WebClient currently are. If I create a RestClientCustomizer in a similar fashion to RestTemplateObservationConfiguration, then observations are properly created for HTTP requests as one could expect:

	@Bean
	RestClientCustomizer observationRestClientCustomizer(
			ObservationRegistry observationRegistry,
			ObjectProvider<ClientRequestObservationConvention> customConvention,
			ObservationProperties properties) {
		String name = properties.getHttp().getClient().getRequests().getName();
		ClientRequestObservationConvention observationConvention = customConvention
			.getIfAvailable(() -> new DefaultClientRequestObservationConvention(name));
		return builder -> builder
				.observationRegistry(observationRegistry)
				.observationConvention(observationConvention);
	}

Adding this as an auto configuration would improve the out-of-the-box experience for the new RestClient.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 22, 2023
@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Nov 22, 2023
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Nov 22, 2023
@philwebb philwebb modified the milestones: 3.2.x, 3.2.0 Nov 22, 2023
@mhalbritter mhalbritter self-assigned this Nov 23, 2023
@mhalbritter mhalbritter changed the title Provide a RestClientObservationConfiguration Auto-configure observations for RestClients Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants