Skip to content

Conversation

@idelpivnitskiy
Copy link
Member

Motivation:

AbstractOpenTelemetryFilter manually subscribes to response and its payload body but does not share context on subscribe. In result, AsyncContext propagation is incorrect when OTEL filters are in place.

Modifications:

  • Add shareContextOnSubscribe() before subscribing response single and its payload Publisher.
  • Add a test that uses our utility to verify correct AsyncContext propagation.

Result:

AsyncContext state is correctly propagated through stages of response processing when OTEL filters are in place.

Motivation:

`AbstractOpenTelemetryFilter` manually subscribes to response and its
payload body but does not share context on subscribe. In result,
`AsyncContext` propagation is incorrect when OTEL filters are in place.

Modifications:

- Add `shareContextOnSubscribe()` before subscribing response single and
its payload Publisher.
- Add a test that uses our utility to verify correct AsyncContext
propagation.

Result:

`AsyncContext` state is correctly propagated through stages of
response processing when OTEL filters are in place.

@Test
void verifyAsyncContextVisibility() throws Exception {
verifyServerFilterAsyncContextVisibility(new OpenTelemetryHttpServerFilter());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryce-anderson I found the utility I was describing to you the other day and decided to submit a PR to demonstrate how to use it. We only have it for the server-side for now. It helps assert that filter in question does not break AsyncContext propagation.

@idelpivnitskiy idelpivnitskiy merged commit 087b1bc into apple:main Mar 29, 2025
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the otel-ctx branch March 29, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants