Repository navigation
fix(http): enclose proceed in handler span lifecycle and propagate span in UserAgent and UrlReplace handlers - #2219
Merged
Vincent Biret (baywet) merged 2 commits intoOct 26, 2026
Conversation
…an in UserAgent and UrlReplace handlers
Contributor
Author
|
Following up on our middleware work in okHttp, this PR aligns the OpenTelemetry span lifecycle in UserAgentHandler and UrlReplaceHandler:
All unit tests and the full okHttp module test suite (./gradlew :components:http:okHttp:test) pass cleanly locally. Whenever convenient, please take a look. |
Contributor
Author
|
I've updated the PR with strengthened regression tests for both
All okHttp tests pass cleanly ( |
Vincent Biret (baywet)
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Encloses downstream execution (
chain.proceed) within the active span lifecycle inUserAgentHandlerandUrlReplaceHandlerand propagates the handler span onto the outgoing request tag (Span.class) so child spans remain properly nested within the tracing hierarchy.Fix
UserAgentHandler.java:chain.proceed(builder.build())into thetryblock before thefinallyblock, ensuringspan.end()andscope.close()execute only after downstream execution completes.Span.classon the outgoing request (builder.tag(Span.class, span)), enabling downstream middleware and transport calls to attach as child spans.UrlReplaceHandler.java:chain.proceed(request)into thetryblock before thefinallyblock, ensuringspan.end()andscope.close()accurately measure total duration including downstream transport.Span.classon the outgoing request (request.newBuilder().tag(Span.class, span).build()).UserAgentHandlerTest.java: AddedenclosesProceedAndPropagatesSpanverifying downstream receives the tagged span.UrlReplaceHandlerTest.java: AddedtestUrlReplaceHandler_propagatesSpanverifying span propagation tochain.proceed.Testing
cc Vincent Biret (@baywet)