io.sentry.spring.boot.jakarta.SentrySpanRestTemplateCustomizer Maven / Gradle / Ivy
The newest version!
package io.sentry.spring.boot.jakarta;
import com.jakewharton.nopen.annotation.Open;
import io.sentry.IScopes;
import io.sentry.spring.jakarta.tracing.SentrySpanClientHttpRequestInterceptor;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.springframework.boot.web.client.RestTemplateCustomizer;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.RestTemplate;
@Open
class SentrySpanRestTemplateCustomizer implements RestTemplateCustomizer {
private final @NotNull SentrySpanClientHttpRequestInterceptor interceptor;
public SentrySpanRestTemplateCustomizer(final @NotNull IScopes scopes) {
this.interceptor = new SentrySpanClientHttpRequestInterceptor(scopes);
}
@Override
public void customize(final @NotNull RestTemplate restTemplate) {
final List existingInterceptors = restTemplate.getInterceptors();
if (!existingInterceptors.contains(this.interceptor)) {
final List interceptors = new ArrayList<>();
interceptors.add(this.interceptor);
interceptors.addAll(existingInterceptors);
restTemplate.setInterceptors(interceptors);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy