-
Notifications
You must be signed in to change notification settings - Fork 129
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
RUMM-731 Refactor URLSession
instrumentation to support RUM and Tracing
#262
Merged
ncreated
merged 9 commits into
master
from
ncreated/RUMM-731-refactor-URLSession-instrumentation-to-handle-both-RUM-and-Tracing
Oct 7, 2020
Merged
RUMM-731 Refactor URLSession
instrumentation to support RUM and Tracing
#262
ncreated
merged 9 commits into
master
from
ncreated/RUMM-731-refactor-URLSession-instrumentation-to-handle-both-RUM-and-Tracing
Oct 7, 2020
Conversation
This file contains 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
buranmert
suggested changes
Oct 5, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i haven't looked at tests yet but i guess we can discuss those non-major issues first
...xample/Scenarios/Tracing/NSURLSessionAutoInstrumentation/TracingNSURLSessionViewController.m
Show resolved
Hide resolved
Sources/Datadog/URLSessionAutoInstrumentation/DDURLSessionDelegate.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/URLSessionAutoInstrumentation/URLSessionSwizzler.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/URLSessionAutoInstrumentation/URLSessionSwizzler.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/URLSessionAutoInstrumentation/URLSessionSwizzler.swift
Outdated
Show resolved
Hide resolved
…URLSessionInterceptor`
…dler` and other new or updated components.
ncreated
force-pushed
the
ncreated/RUMM-731-refactor-URLSession-instrumentation-to-handle-both-RUM-and-Tracing
branch
from
October 6, 2020 06:19
03bedfb
to
68706d3
Compare
…mpletion handler in Objective-C
buranmert
approved these changes
Oct 7, 2020
ncreated
deleted the
ncreated/RUMM-731-refactor-URLSession-instrumentation-to-handle-both-RUM-and-Tracing
branch
October 7, 2020 11:09
2 tasks
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.
What and why?
⚙️ This PR applies refactoring to the
URLSession
instrumentation code. Given the requirements of the RUM product, previous implementation didn't scale well to support theURLSessionDelegate
, which is necessary to retrieve network task metrics.With this refactoring:
URLSession.dataTask(with:)
creation methods (vs only 2 before);URLSessionTaskMetrics
object (vs measured in swizzled code);The impact of this refactoring was mitigated by adding integration tests last sprint, in #253.
How?
The
URLSessionTask
task is now observed by two objects:URLSessionSwizzler
- to notify task creation and (in some cases) completion,DDURLSessionDelegate
- to retrieve task metrics and (in other cases) notify the completion.Both talk to the
URLSessionInterceptor
, where interception happens and tracingSpan
is created (throughURLSessionTracingHandler
).Testing strategy is simple and it follows component relationships:
URLSessionSwizzlerTests
ensure that methods onURLSessionInterceptor
are called properly,DDURLSessionDelegateTests
ensure that methods onURLSessionInterceptor
are called properly,URLSessionInterceptorTests
ensure that theSpan
is send to the backend on given circumstances,URLSessionTracingHandlerTests
assert the values of producedSpan
.Although this PR seems big, only its first commit relates to the actual implementation. The rest is duplication of test cases in different scenarios (with 2 new instrumented
URLSession
methods, we have way more cases than before).Review checklist