Skip to content
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

RUM-717 feat!: Add network instrumentation for async/await URLSession APIs #1394

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

ganeshnj
Copy link
Contributor

@ganeshnj ganeshnj commented Jul 26, 2023

What and why?

Fixes #1288

How?

https://datadoghq.atlassian.net/wiki/spaces/RUMP/pages/3130426092

TLDR

Dogfood: https://github.com/DataDog/shopist-ios/pull/55

Customers no longer have to implement Datadog delegate to instrument rather they can simply use high level APIs.

  1. Enable URLSessionTracking either via RUM or Trace
RUM.enable()

or

Trace.enable()
  1. Enable session tracking per delegate
let delegate = MyDelegate() // implements URLSessionTaskDelegate
URLSessionInstrumentation.enable(with: .init(delegate: delegate))
  • instrumentation now works for async-await APIs too.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes

Custom CI job configuration (optional)

  • Run unit tests
  • Run integration tests
  • Run smoke tests

@ganeshnj ganeshnj requested a review from a team as a code owner July 26, 2023 08:56
@ganeshnj ganeshnj marked this pull request as draft July 26, 2023 08:56
@ganeshnj ganeshnj changed the title RUMM-3319 fix: use swizzle URLSessionTask for iOS 15 & above for netw… RUMM-3319 fix: use swizzle URLSessionTask for iOS 15 & above for network instrumentation Jul 26, 2023
@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from f5a06fe to e9edac7 Compare July 28, 2023 11:18
@ganeshnj ganeshnj changed the title RUMM-3319 fix: use swizzle URLSessionTask for iOS 15 & above for network instrumentation RUMM-3319 fix: swizzle URLSessionTask for network instrumentation Jul 28, 2023
@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from abf8ee6 to c875fc6 Compare September 6, 2023 08:32
@ganeshnj ganeshnj changed the title RUMM-3319 fix: swizzle URLSessionTask for network instrumentation RUM-717 fix: swizzle URLSessionTask for network instrumentation Sep 6, 2023
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Sep 6, 2023

Datadog Report

Branch report: ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask
Commit report: 178a83b

dd-sdk-ios: 0 Failed, 0 New Flaky, 118 Passed, 0 Skipped, 2m 19.45s Wall Time

@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from 632156f to 96d8edf Compare September 7, 2023 16:53
@ganeshnj ganeshnj marked this pull request as ready for review September 8, 2023 08:27
@ganeshnj ganeshnj changed the title RUM-717 fix: swizzle URLSessionTask for network instrumentation RUM-717 fix!: swizzle URLSessionTask for network instrumentation Sep 8, 2023
Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

Only preliminary feedbacks for now, I need more time 🙏.

Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

Nice work here!

In additions to @ncreated comments, I've left some suggestions. One important topic is delegate instance vs. type when enabling the instrumentation, I think we should be clear that we are instrumenting the class and not the instance.

Copy link
Member

@maciejburda maciejburda left a comment

Choose a reason for hiding this comment

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

Overall looks good! +1 to other's comments + a few minor ones from my side

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Sep 18, 2023

Datadog Report

Branch report: ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask
Commit report: c324433

dd-sdk-ios: 1 Failed (0 Known Flaky), 0 New Flaky, 2289 Passed, 0 Skipped, 5m 17.83s Wall Time

❌ Failed Tests (1)

  • testConcurrentBinding - URLSessionDataDelegateSwizzlerTests - Details

    Expand for error
     Abort trap. Check error.crash_log for the full crash log.
    

Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

Looks neat 👌. I left few questions. On top of it:

  • Shouldn't we mark DDURLSessionDelegate as deprecated?
  • What about exposing this new API in Objective-C?

@ganeshnj
Copy link
Contributor Author

Looks neat 👌. I left few questions. On top of it:

  • Shouldn't we mark DDURLSessionDelegate as deprecated?
  • What about exposing this new API in Objective-C?

Added objc interfaces - good call. Some tests are also updated along with this.

Deprecation - I will handle in seperate PR as it is very specific and shouldn't be coupled.

Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

It looks great!! It's a complex logic but you were able to keep it readable, well done 👍

I've one remaining concern in various swizzler where properties are exposed while a lock is required.

Copy link
Member

@maciejburda maciejburda left a comment

Choose a reason for hiding this comment

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

Great effort!

One potential blocker on associated object implementation

@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from 2267484 to 30b731f Compare September 21, 2023 15:23
ncreated
ncreated previously approved these changes Sep 22, 2023
Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

Looks good 👌. Solid work 👍. Have we ran unit tests with iOS 12 - 15 Simulators? (to make sure it works and we won't have nightly job problems after merge)

maxep
maxep previously approved these changes Sep 22, 2023
Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

Thank you @ganeshnj for addressing all our comments and questions, it looks great!

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Sep 28, 2023

Datadog Report

Branch report: ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask
Commit report: fcbe440

dd-sdk-ios: 0 Failed, 0 New Flaky, 5486 Passed, 0 Skipped, 29m 43.75s Wall Time

@ganeshnj ganeshnj dismissed stale reviews from maxep and ncreated via 91f3118 September 28, 2023 09:16
@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from 507fa89 to e1de388 Compare September 28, 2023 11:27
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Oct 5, 2023

Datadog Report

Branch report: ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask
Commit report: 97deb72

dd-sdk-ios: 0 Failed, 0 New Flaky, 2659 Passed, 0 Skipped, 30m 19.31s Wall Time

ncreated
ncreated previously approved these changes Oct 9, 2023
CHANGELOG.md Outdated Show resolved Hide resolved
@ganeshnj ganeshnj changed the title RUM-717 fix!: swizzle URLSessionTask for network instrumentation RUM-717 feat!: Add network instrumentation for async/await URLSession APIs Oct 9, 2023
maxep
maxep previously approved these changes Oct 10, 2023
Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

🚀

maciejburda
maciejburda previously approved these changes Oct 10, 2023
Copy link
Member

@maciejburda maciejburda left a comment

Choose a reason for hiding this comment

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

LGTM

TestUtilities/Helpers/XCTestCase.swift Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@ganeshnj ganeshnj dismissed stale reviews from maciejburda and maxep via 39c138e October 12, 2023 15:20
@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from 39c138e to f1ef9db Compare October 12, 2023 15:36
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Oct 12, 2023

Datadog Report

Branch report: ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask
Commit report: 0b56eb5

dd-sdk-ios: 0 Failed, 0 New Flaky, 2697 Passed, 0 Skipped, 28m 1.83s Wall Time

maciejburda
maciejburda previously approved these changes Oct 13, 2023
ncreated
ncreated previously approved these changes Oct 13, 2023
@ganeshnj ganeshnj dismissed stale reviews from ncreated and maciejburda via 404021c October 18, 2023 08:00
@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from f1ef9db to 404021c Compare October 18, 2023 08:00
@ganeshnj ganeshnj force-pushed the ganeshnj/fix/RUMM-3319-swizzle-urlsessiontask branch from 404021c to 0b56eb5 Compare October 18, 2023 14:29
Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

🚀

@ganeshnj ganeshnj merged commit 438a467 into develop Oct 18, 2023
11 checks passed
@maxep maxep mentioned this pull request Nov 8, 2023
8 tasks
@maxep maxep mentioned this pull request Dec 13, 2023
8 tasks
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.

Network traffic (= traces) not captured for URLSession.data(...) methods
4 participants