Repository navigation
Add request-side URL/body span attributes; split up RawTask._result - #331
Merged
Merged
Conversation
RawTask's span now sets url.scheme, server.address, server.port, url.path and http.request.body.size alongside the existing http.request.method/url.full — matching what async-http-client's own built-in tracing gained in swift-server/async-http-client#906 (released in 1.36.1). url.query is deliberately left out since query strings can carry tokens/PII. Also splits RawTask._result(environment:), which had grown into one ~210-line function covering hook notification, executor/network-path validation, client resolution, and the whole span lifecycle, into focused private methods. Behavior and task-local propagation timing (the ServiceContext/EventLoop-hop workaround this file exists for) are unchanged; the extracted methods are called synchronously in the same task, so no propagation boundary moved. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #331 +/- ##
=======================================
Coverage 98.61% 98.61%
=======================================
Files 5 5
Lines 1082 1082
=======================================
Hits 1067 1067
Misses 15 15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
url.scheme,server.address,server.port,url.path, andhttp.request.body.sizeto the request spanRawTaskstarts, on top of the existinghttp.request.method/url.full. This mirrors whatasync-http-client's own built-in tracing gained in swift-server/async-http-client#906 (released in 1.36.1) — previously it only sethttp.request.method.url.queryis deliberately left out since query strings can carry tokens/PII that shouldn't land on a span by default.RawTask._result(environment:), which had grown into one ~210-line function doing hook notification, executor/network-path validation, client resolution, and the whole span lifecycle, into focused private methods (notifyDescriptorHooks,validateRequiredExecutor,waitForNetworkPath,resolveClient,runSession,executeTraced,startRequestSpan,setURLAttributes,endRequestSpan).Why breaking-changes
No public API changed — this is an internal refactor plus additive span attributes. Labeled
breaking-changesper explicit request rather than an assessment that anything actually breaks for consumers.Design notes
ServiceContext.currentsurvives, instead of delegating toasync-http-client's tracing, which loses it on anEventLoophop) is unaffected, since the extracted methods are still called synchronously within the same task — no newTask/EventLoopboundary was introduced.server.portfalls back to the scheme's default (80/443) when the URL has none, mirroringasync-http-client'sDeconstructedURL/Scheme.defaultPort.Test plan
swift build— clean buildswift test --filter "RequestServiceContextTests|SessionTests|RawTask"— 50/50 passingswift test --filter RequestDLTests— full suite, 1123/1123 passing🤖 Generated with Claude Code