RUMM-1154 User can add attributes to auto instrumented RUM Resources #473
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.
What and why?
📦 This PR adds
rumResourceAttributesProvider
API, which makes it possible to add extra attributes to RUM Resources collected automatically:The
provider
block is called for eachURLSessionTask
intercepted by the SDK. The implementation should look into task information and return custom attributes for RUM Resource, e.g. send redacted response headers or decode response body and send its additional context. This block is also called for RUM Errors created for resources failed on transport.This is a counterpart of DataDog/dd-sdk-android#520 introduced in
dd-sdk-android
.How?
The implementation starts with passing the
provider
block through configuration object toURLSessionRUMResourcesHandler
as we do for other stuff.URLSessionInterceptor
is extended with additional method:taskReceivedData(task:data:)
which is called from two places:URLSesionSwizzler
- for requests sent with completion block,DDURLSessionDelegate
- for requests sent with no completion block.About the public API, I considered few other choices:
provider
parameter toDDURLSessionDelegate.init()
- this would require also exposing it inURLSessionInterceptor
(for no-delegate usage including Alamofire extension),provider
parameter to existing.trackURLSession(firstPartyHosts:)
as both are mutually related - this would make the discovery of this new feature harder (the doc comment for.trackURLSession
is already huge).The proposed API should keep things simple: the feature can announced by its API name and the mutual relationship with
trackURLSession
is solved by installing misconfiguration warning.All related unit tests pass on iOS 14.3, 13.4, 12.4 and 11.1.
Review checklist