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

TraceId is missing in WebFlux controller handlers #31716

Closed
github-actions bot opened this issue Nov 29, 2023 · 1 comment
Closed

TraceId is missing in WebFlux controller handlers #31716

github-actions bot opened this issue Nov 29, 2023 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing type: backport An issue that is a backport of another issue to a maintenance branch type: regression A bug that is also a regression
Milestone

Comments

@github-actions
Copy link
Contributor

Backport of gh-31706

@github-actions github-actions bot added in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing type: backport An issue that is a backport of another issue to a maintenance branch type: regression A bug that is also a regression labels Nov 29, 2023
@github-actions github-actions bot added this to the 6.0.15 milestone Nov 29, 2023
@bclozel bclozel changed the title TraceId/SpanId are missing with Spring Boot 3.1.6 and WebFlux TraceId is missing in WebFlux controller handlers Nov 29, 2023
bclozel added a commit that referenced this issue Nov 29, 2023
Prior to this commit, regressions were introduced with gh-31417:

1. the observation keyvalues would be inconsistent with the HTTP response
2. the observation scope would not cover all controller handlers, causing
  traceIds to be missing

The first issue is caused by the fact that in case of error signals, the
observation was stopped before the response was fully committed, which
means further processing could happen and update the response status.
This commit delays the stop event until the response is committed in
case of errors.

The second problem is caused by the change from a `contextWrite`
operator to using the `tap` operator with a `SignalListener`. The
observation was started in the `doOnSubscription` callback, which is too
late in some cases. If the WebFlux controller handler is synchronous
non-blocking, the execution of the handler is performed before the
subscription happens. This means that for those handlers, the
observation was not started, even if the current observation was
present in the reactor context. This commit changes the
`doOnSubscription` to `doFirst` to ensure that the observation is
started at the right time.

Fixes gh-31715
Fixes gh-31716
@bclozel bclozel self-assigned this Nov 29, 2023
@bclozel
Copy link
Member

bclozel commented Nov 30, 2023

Fixed with edadc79

@bclozel bclozel closed this as completed Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing type: backport An issue that is a backport of another issue to a maintenance branch type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

1 participant