Spring-cloud-sleuth: zuul's traceid not pass to oauth-server

Created on 18 Aug 2017  路  25Comments  路  Source: spring-cloud/spring-cloud-sleuth

  1. zuul-server
    security.oauth2.resource.userInfoUri = http://${AUTH_SERVER_HOST}:${AUTH_SERVER_PORT}/uaa/user
@SpringBootApplication
@EnableZuulProxy
@EnableDiscoveryClient
@EnableResourceServer
public class Application {

    private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);


    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //SpringApplication.run(Application.class, args);
        new SpringApplicationBuilder(Application.class).web(true).run(args);
    }
  1. picture
    xxx

zuul---->auth-server is missing, why?
thanks very much for your help !

bug

Most helpful comment

ok, thanks, i will feedback tomorrow,time to sleep,^_^

All 25 comments

Is AuthServer using Sleuth too ?

@marcingrzejszczak
yes

pom.xml

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>

conf:

spring.rabbitmq.host = ${RABBITMQ_SERVER_HOST}
spring.rabbitmq.port = ${RABBITMQ_PORT}
spring.rabbitmq.username = ${RABBITMQ_USER}
spring.rabbitmq.password = ${RABBITMQ_PASSWORD}`

and the data in mysql:
yyy

but the traceid is new , not pass from zuul

You have the wrong dependency...

Change spring-cloud-sleuth-zipkin-stream to spring-cloud-sleuth-stream. I understand that you are sending spans via messaging? The first one is the Zipkin collector and you want to send spans to Zipkin. If you send spans via HTTP change spring-cloud-sleuth-zipkin-stream to spring-cloud-starter-zipkin.

@marcingrzejszczak
you mean the zipkin-server use: spring-cloud-sleuth-zipkin-stream
but the client use: spring-cloud-sleuth-stream ?

thanks, i have try the above solution, but it not works yet, seems not this reason.
because:

zuul-server log: traceId: 11c0211bcd23189c
zuul

then, the auth-server log:
auth

doesn't search the traceId
the auth-server create new traceId ,not pass from the zuul-server

and the auth-server could send message to zipkin-server normal:
zipkin

Could you please start pasting the logs instead of screenshots? Could you also upload your sample applications somewhere? It will be difficult for me to analyze the problem without the real apps

@marcingrzejszczak
code: https://github.com/junneyang/xxproject

auth-server zuul-server and zipkin-server all in:
xxproject/support/ fold

thnaks

Ok, one more question. Could you please run the sample again but turn on the Sleuth's logs to DEBUG in Auth server. Then please upload it here as a file. I'd like to see if the headers are there.

Also can you please try it out with the latest Dalston snapshots? I have a hunch that it's related to OAuth2 template that we have only fixed in the latest snapshots.

ok, thanks, i will feedback tomorrow,time to sleep,^_^

a low-level question, how to find the latest Dalston snapshots? thanks

Just pick the Dalston.BUILD-SNAPSHOT version here http://projects.spring.io/spring-cloud/ and copy it to your project

app.log.txt

@marcingrzejszczak
the auth-server log

you mean the Finchley M1?

vv2

No, I mean a snapshot version. Any snapshot version.

still not work
the snapshot auth-server log:
snapshot-app.log.txt

Did you put snapshot versions in all applications? Can you post the logs or the client app too?

  1. Code: https://github.com/junneyang/xxproject
  2. auth-server zuul-server product-api-service's sleuth log level: DEBUG
  3. Test Step:
  1. all logs:
    log.tar.gz

thanks for your help

I'm trying to go through this sample but it's so gigantic that it's difficult to work with. Is there an option to prepare just 2 applications. Zuul and Authentication server and a simple script how to run these things together? I'd like to debug how Zuul is sending a request to the Authentication server. Cause it seems that it's not passing the tracing information for some reason. Thanks!

@marcingrzejszczak

mvn package

  1. source bootstrap.rc && java -jar support/config-server/target/config-server-1.0.0-RELEASE.jar
  2. source bootstrap.rc && java -jar support/auth-server/target/auth-server-1.0.0-RELEASE.jar
  3. source bootstrap.rc && SPRING_CLOUD_CONFIG_PROFILE=${EUREKA_SERVER01} java -jar support/eureka-server/target/eureka-server-1.0.0-RELEASE.jar
  4. source bootstrap.rc && SPRING_CLOUD_CONFIG_PROFILE=${EUREKA_SERVER02} java -jar support/eureka-server/target/eureka-server-1.0.0-RELEASE.jar
  5. source bootstrap.rc && java -jar support/zuul-server/target/zuul-server-1.0.0-RELEASE.jar

thanks for your kindly help!

@marcingrzejszczak
when i refer this issue: https://github.com/spring-cloud/spring-cloud-sleuth/issues/581

add this

@Bean
    public UserInfoRestTemplateCustomizer userInfoRestTemplateCustomizer(
            TraceRestTemplateInterceptor traceRestTemplateInterceptor) {
        return restTemplate -> {
            List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(
                    restTemplate.getInterceptors());
            interceptors.add(traceRestTemplateInterceptor);
            restTemplate.setInterceptors(interceptors);
        };
    }

to zuul, product-api-service it works!

aaa

Ha! Actually I know why it's not working. I've created a Bean Post Processor and I'm wrapping a UserInfoRestTemplateCustomizer with a trace representation. But what if there's not a single one defined? Then nothing happens. That's why if there's no UserInfoRestTemplateCustomizer defined then one should be applied. I'll add a fix in a second

Ok it's fixed. Can you check against latest snapshots? And ensure that you don't have the manual UserInfoRestTemplateCustomizer set

I'm sorry, I tried to run the sample locally but I didn't manage to do it. With the latest changes things should work fine so I'll close the issue and if you find out that there are still some problems just feel free to reopen it.

fixed by https://github.com/spring-cloud/spring-cloud-sleuth/commit/6d25738ec41aab2d2ebe3c152be7271a3dc57649

Was this page helpful?
0 / 5 - 0 ratings