-
Notifications
You must be signed in to change notification settings - Fork 27
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
Use new propagation context API #281
Conversation
Initial version of the propagation API. Main points: - The propagated context is always immutable and consist of different propagated elements similar to Kotlin Coroutines context - Propagated element can implement `ThreadPropagatedContextElement` to setup/restore thread locals - The propagated state is never captured but the context needs to be extended and pushed down the downstream - The capturing API is not needed anymore, this should eliminate a lot of overhead from the reactive code - The context is automatically propagated to the Kotlin coroutines - In the Reactor context should be propagated as whole with utility method to extract/extend it (The Reactor context needs to be modified manually) - The implementation is using try-resources to propagate the contest without extra overhead, this might change in the future to support scoped local, but at this moment, I think this is the best solution. I want to merge this first PR to have the orther work mergable. Next PRs will remove the existing instrumentation propagation, add docs etc. There are already examples how it should be used: - Tracing micronaut-projects/micronaut-tracing#281 - Micronaut Data micronaut-projects/micronaut-data#2189 (This is a big PR because of the changes in the TX management and removal of forked Spring TX code)
The build is failing locally with:
|
// Optional<?> body = response.getBody(); | ||
// if (body.isPresent()) { | ||
// Object o = body.get(); | ||
// if (Publishers.isConvertibleToPublisher(o)) { | ||
// Class<?> type = o.getClass(); | ||
// Publisher<?> resultPublisher = Publishers.convertPublisher(conversionService, o, Publisher.class); | ||
// Publisher<?> scopedPublisher = new ScopePropagationPublisher<>( | ||
// resultPublisher, | ||
// openTracer, | ||
// openTracer.activeSpan() | ||
// ); | ||
// | ||
// response.body(Publishers.convertPublisher(conversionService, scopedPublisher, type)); | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this code if it is not needed
@@ -14,4 +14,4 @@ | |||
# limitations under the License. | |||
# | |||
|
|||
Args = --initialize-at-run-time=io.micronaut.tracing.instrument.kotlin.HttpCoroutineTracingDispatcherFactory | |||
Args = --initialize-at-run-time=io.micronaut.tracing.brave.http.HttpTracingFactor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file can be deleted
tracing-brave-http/src/test/groovy/io/micronaut/tracing/brave/BraveTracerFactorySpec.groovy
Show resolved
Hide resolved
@@ -14,4 +14,4 @@ | |||
# limitations under the License. | |||
# | |||
|
|||
Args = --initialize-at-run-time=io.micronaut.tracing.brave.BraveTracerFactory,io.micronaut.tracing.brave.instrument.http.HttpTracingFactory,io.micronaut.tracing.brave.log.Slf4jCurrentTraceContextFactory,io.micronaut.tracing.brave.sender.HttpClientSenderFactory | |||
Args = --initialize-at-run-time=io.micronaut.tracing.brave.BraveTracerFactory,io.micronaut.tracing.brave.log.Slf4jCurrentTraceContextFactory,io.micronaut.tracing.brave.sender.HttpClientSenderFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file can be deleted
@@ -802,15 +808,15 @@ class HttpTracingSpec extends Specification { | |||
spanCustomizer.activeSpan()?.setBaggageItem('foo', 'bar') | |||
Flux.from(tracedClient.continuedRx(name)) | |||
.flatMap({ String res -> | |||
assert spanCustomizer.activeSpan()?.getBaggageItem('foo') == 'bar' | |||
// assert spanCustomizer.activeSpan()?.getBaggageItem('foo') == 'bar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this validation needs to be present or deleted?
return tracedClient.nestedReactive2(res) | ||
}) | ||
} | ||
|
||
@Get('/nestedReactive2/{name}') | ||
@SingleResult | ||
Publisher<Integer> nestedReactive2(String name) { | ||
assert spanCustomizer.activeSpan()?.getBaggageItem('foo') == 'bar' | ||
// assert spanCustomizer.activeSpan()?.getBaggageItem('foo') == 'bar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this validation needs to be present or deleted?
SonarCloud Quality Gate failed. |
The PR is moving to the new propagation API introduced in Micronaut 4.
Also: