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

Error using micrometer-tracing-bridge-brave and a baggage field #157

Closed
ruben-garciapariente opened this issue Feb 7, 2023 · 2 comments
Closed
Labels
bug A general bug
Milestone

Comments

@ruben-garciapariente
Copy link

Hello,

I first opened this problem at Spring Boot spring-projects/spring-boot#34075 but after they have analyzed it they indicate that maybe the problem can come from micrometer.

The error occurs using Spring Boot 3.0.2. The error can be reproduced using https://github.com/ruben-garciapariente/error-tracing-with-brave-baggage/blob/main/src/main/java/com/example/bravetracing/BraveTracingApplication.java

We have used micrometer-tracing-bridge-brave for tracing

<dependency>
	<groupId>io.micrometer</groupId>
	<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>

Configured to instrument async observability as indicated at https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide#async-instrumentation.

	// Example of Async Servlets setup
	@Configuration(proxyBeanMethods = false)
	static class AsyncConfig implements WebMvcConfigurer {
		@Override
		public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
			configurer.setTaskExecutor(new SimpleAsyncTaskExecutor(r -> new Thread(ContextSnapshot.captureAll().wrap(r))));
		}
	}

And we have a controller with asynchronous methods

    @RequestMapping(path = "/callable", produces = "text/html")
    Callable<ResponseEntity<String>> callable() {
        logger.info(String.format("1 - Thread %s - Span %s",Thread.currentThread().getName(), tracer.currentSpan().context().toString()));
        return () -> {
            logger.info(String.format("2 - Thread %s - Span %s",Thread.currentThread().getName(), tracer.currentSpan().context().toString()));
            return ResponseEntity.status(HttpStatus.OK).body("OK");
        };
    }

And we configure the baggage fields


management:
  tracing:
    baggage:
      remote-fields:
        - TEST1
      correlation:
        fields:
          - TEST1

When running the BraveTracingApplicationTests#testCallable test the following error is returned

2023-02-06T13:13:34.900+01:00  INFO [63e0eeee37d15812d3f53ac42c7c8307,d3f53ac42c7c8307,test1] 25824 --- [       Thread-2] c.example.bravetracing.TestController    : 2 - Thread Thread-2 - Span 63e0eeee37d15812d3f53ac42c7c8307/d3f53ac42c7c8307
2023-02-06T13:13:34.923+01:00  INFO [63e0eeee37d15812d3f53ac42c7c8307,a2a553d4c5737736,test1] 25824 --- [           main] c.example.bravetracing.TestController    : Thread main - Span 63e0eeee37d15812d3f53ac42c7c8307/a2a553d4c5737736
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 6.458 s <<< FAILURE! - in com.example.bravetracing.BraveTracingApplicationTests
[ERROR] testCallable  Time elapsed: 0.814 s  <<< FAILURE!
java.lang.AssertionError: Misalignment: popped updateScope false !=  expected false
        at com.example.bravetracing.BraveTracingApplicationTests.testCallable(BraveTracingApplicationTests.java:31)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   BraveTracingApplicationTests.testCallable:31 Misalignment: popped updateScope false !=  expected false

Many thanks

@marcingrzejszczak
Copy link
Contributor

Is it still a problem with the latest 1.0.1 micrometer tracing library?

@marcingrzejszczak marcingrzejszczak added the question Further information is requested label Feb 7, 2023
@ruben-garciapariente
Copy link
Author

ruben-garciapariente commented Feb 8, 2023

The attached example is using micrometer-tracing version 1.0.1

[INFO] +- io.micrometer:micrometer-tracing-bridge-brave:jar:1.0.1:compile
[INFO] |  +- io.micrometer:micrometer-tracing:jar:1.0.1:compile
[INFO] |  |  +- io.micrometer:context-propagation:jar:1.0.0:compile
[INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants