3

Hi am using the below tracing framework in my spring boot project.

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
    <version>3.3.1</version>
</dependency>

I get the following exception when I start my application.

┌─────┐
|  org.springframework.cloud.netflix.zuul.ZuulProxyAutoConfiguration (field private java.util.List org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration.configurers)
↑     ↓
|  io.opentracing.contrib.spring.web.starter.ServerTracingAutoConfiguration (field private java.util.regex.Pattern io.opentracing.contrib.spring.web.starter.ServerTracingAutoConfiguration.skipPattern)
↑     ↓
|  skipPattern defined in class path resource [io/opentracing/contrib/spring/web/starter/SkipPatternAutoConfiguration.class]
↑     ↓
|  org.springframework.cloud.client.CommonsClientAutoConfiguration$ActuatorConfiguration (field private java.util.List org.springframework.cloud.client.CommonsClientAutoConfiguration$ActuatorConfiguration.hasFeatures)
└─────┘

I can get rid of the error by placing the below attribute in my application.yml file. However, I do not know the impact of this flag.. Can someone throw some light on the consequence of this setting?

  spring:
    web:
      ignoreAutoConfiguredSkipPatterns: true
Sujal Mandal
  • 975
  • 1
  • 14
  • 29

2 Answers2

1

The ignoreAutoConfiguredSkipPatterns property is responsible for building skipPattern value in TracingFilter. When ignoreAutoConfiguredSkipPatterns is false or not configured, skipPattern value will contain regular expression pattern to exclude certain paths from tracing (e.g. pattern is defined as /health|/status then URL http://localhost:5000/context/health won't be traced). If ignoreAutoConfiguredSkipPatterns is true, then skipPattern value will be null, then request will be traced in TracingFilter

P.S. As for me, issue is related with spring.cloud.features.enabled flag, that flag is enabled by default and as result hasFeatures field creates a circular dependency, please check code below:

@Configuration(proxyBeanMethods = false)
public class CommonsClientAutoConfiguration {  
  ...

  @Configuration(proxyBeanMethods = false)
  @ConditionalOnClass(Endpoint.class)
  @ConditionalOnProperty(value = "spring.cloud.features.enabled", matchIfMissing = true)
  protected static class ActuatorConfiguration {

    @Autowired(required = false)
    private List<HasFeatures> hasFeatures = new ArrayList<>();

    @Bean
    @ConditionalOnAvailableEndpoint
    public FeaturesEndpoint featuresEndpoint() {
        return new FeaturesEndpoint(this.hasFeatures);
    }

  }
  ...
}
saver
  • 2,541
  • 1
  • 9
  • 14
  • my application is still using ZUUL proxy, so if I disable spring.cloud.features.enabled, then I should be able to get rid of this issue safely? Thanks for answering! – Sujal Mandal Feb 18 '22 at 06:28
  • I don't have the whole config, but by assumption - yes – saver Feb 18 '22 at 09:41
1

The issue you have mentioned is caused to due to circular dependency. All the above library in the error log use Spring Boot actuator and autoconfigure libraries.
There are few known Github issues. You can find details in the skip-pattern circular dependency and Zuul Proxy circular dependency.

Solution is correct

spring.web.ignoreAutoConfiguredSkipPatterns: true

I see that @saver has provided good information. I would like to explain in a bit details.

By opentracing-spring-jaeger-cloud-starter dependency all the applications are automatically instrumented with a OpenTracing agent, that will create traces/spans related to internal operations (app, db, cache etc. etc.).

There is class called SkipPatternAutoConfiguration which configures all the actuator skip patterns. So, your issue is related to here

Through the TracingFilter, all sampled incoming requests result in creation of a Span. By the skip-pattern property we configure which URIs we would like to skip. By default, all the spring boot actuator endpoints are automatically added to the skip pattern. If you want to disable this behavior set *.skip-patterns to true.

The reason I have used * here because this skip pattern is used by a lot of libraries which use telemetry and tracing. e.g. Opentracing, Sleuth, Spring cloud actuatorsetc.

The property you have set is read by ConditionalOnProperty

 @ConditionalOnProperty(value = "opentracing.spring.web.ignoreAutoConfiguredSkipPatterns", havingValue = "false", matchIfMissing = true)

Default value is matchIfMissing = true , so whenever you don't provide the value application tries to configure the skip-pattern. It fails here for you in the circular dependency. As now you have set ignoreAutoConfiguredSkipPatterns to true, the property havingValue = "false" doesn't satisfy and skip patterns are not configured. Hence, the issue will not reproduce.

Few links:
SkipPatternAutoConfiguration
ServerTracingAutoConfiguration
CommonsClientAutoConfiguration
ZuulProxyAutoConfiguration

TriS
  • 3,668
  • 3
  • 11
  • 25