opentracing-contrib / opentracing-contrib/java-spring-cloud
Application won't start with opentracing.spring.cloud.reactor.enabled=true
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 399
- Forks
- 143
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 22
Description
We have an application that is using Spring Cloud Gateway and is connected to Redis and Jaeger that is deployed in Pivotal Cloud Foundry.
Problem
When not run in Cloud Foundry (i.e. on a host machine) and still connected to Redis/Jaeger everything seems to load fine with the Tracer automatically created using the spring.application.name property which is set in bootstrap.yml file.
bootstrap.yml
opentracing:
jaeger:
udp-sender:
host: jaeger.tld
port: ###
tags:
environment: ci
datacenter: dc1
remote-controlled-sampler:
host: jaeger.tld
port: ###
enabled: true
spring:
web:
enabled: true
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>11</java.version>
<spring-cloud-services.version>2.3.0.RELEASE</spring-cloud-services.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-dependencies</artifactId>
<version>${spring-cloud-services.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
However, when deployed in PCF it fails to start with an error that seems to come from building the Tracer "Service name must not be null or empty"
Stack Trace (sorry for terrible format)
Application run failed\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name \'tracingWebClientBeanPostProcessor\' defined in class path resource [io/opentracing/contrib/spring/web/starter/WebClientTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method \'tracingWebClientBeanPostProcessor\' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'tracer\' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.opentracing.Tracer]: Factory method \'tracer\' threw exception; nested exception is java.lang.IllegalArgumentException: Service name must not be null or empty\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:538)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:241)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:723)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536)\n 2021-01-06T18:51:32.25-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:62)\n 2021-01-06T18:51:32.26-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)\n 2021-01-06T18:51:32.26-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)\n 2021-01-06T18:51:32.26-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)\n 2021-01-06T18:51:32.26-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.boot.SpringApplication.run(SpringApplication.java:315)\n 2021-01-06T18:51:32.26-0500 [APP/PROC/WEB/0] OUT \tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
What we have tried
- We have been able to run just connected to Redis in PCF while disabling all opentracing.jaeger.enable=false with no issue
- We have been able to run just connected to Jaeger in PCF before bringing in Redis libraries with no issue.
- Added Redis/Jaeger while disabling opentracing.spring.cloud.redis.enabled=false which still throws the same error (This seems odd since bringing in Redis was the suspicion of what would have broken Opentracing)
- Added Redis/Jaeger while systematically disabling other tech one by one until opentracing.spring.cloud.reactor.enabled=false. This seems to eliminate the error and the application is able to start, but we can't figure out why this would have been fine until Redis was added to the mix. Also, we really don't love the idea of disabling this as it leaves a blindspot.
Thought is that the way/order the ReactorTracingAutoConfiguration runs it isn't allowing Spring to have set properties with @Value annotation on them. Specifically, the JaegerConfigurationProperties.serviceName field. Also, it seemed odd when looking through many of the TechBlahAutoConfiguration classes in all the starter projects that ReactorTracingAutoConfiguration is missing the @AutoConfigureAfter({TracerAutoConfiguration.class}) annotation that most of the others have. It seems this is only reproducible while deployed in PCF which handles the connection to Redis Tile, but that makes me believe there is a bug in the AutoConfiguration classes here which fire out of order in that scenario.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing ReactorTracingAutoConfiguration with TracerAutoConfiguration and JaegerAutoConfiguration, focusing on the reported missing @AutoConfigureAfter relationship and how JaegerConfigurationProperties.serviceName is populated. Reproduce the startup failure with reactor tracing enabled in the PCF, Redis, and Jaeger setup described. Done means the application starts in that environment with reactor tracing enabled and a non-empty service name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100