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

RUMM-2334 Use DatadogContext in V1 scopes #981

Merged
merged 9 commits into from
Sep 12, 2022

Conversation

maxep
Copy link
Member

@maxep maxep commented Aug 29, 2022

What and why?

While working on Feature communication through Core Context, I realised that we cannot apply synchronisation while maintaining 2 contexts. It is time to fade away DatadogV1Context in favor of DatadogContext.

How?

Date Provider

The DateProvider is no longer part of context, it is now injected as part of the configuration, the goal is to let feature create a timestamp outside of the Event Write Context. The configuration will be revisited when doing the split.

Persisting DatadogV1Context Usage

DatadogV1Context still exists for Crash-Reporting and WebView-Tracking integrations which do not use the Event Write Context.

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

@maxep maxep force-pushed the maxep/RUMM-2334/v2-context-in-scope branch 2 times, most recently from 683c8c4 to 144c192 Compare August 29, 2022 21:04
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Aug 30, 2022

Datadog Report

Branch report: maxep/RUMM-2334/v2-context-in-scope
Commit report: 35b394f

dd-sdk-ios 0 Failed, 0 New Flaky, 1943 Passed, 0 Skipped, 17m39.99s Wall Time

@maxep maxep force-pushed the maxep/RUMM-2334/v2-context-in-scope branch 2 times, most recently from c4c7c66 to 05775fa Compare August 30, 2022 08:13
@maxep maxep self-assigned this Aug 30, 2022
var networkConnectionInfo: NetworkConnectionInfo = .unknown
var networkConnectionInfo: NetworkConnectionInfo?
Copy link
Member Author

Choose a reason for hiding this comment

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

Making this optional to keep previous behavior.

@maxep maxep force-pushed the maxep/RUMM-2334/v2-context-in-scope branch 2 times, most recently from d275f69 to b135773 Compare August 30, 2022 09:11
@maxep maxep force-pushed the maxep/RUMM-2334/v2-context-in-scope branch from c058c91 to db2072a Compare August 30, 2022 12:10
queue.async {
let transformedCommand = self.transform(command: command)
core.v1.scope(for: RUMFeature.self)?.eventWriteContext { context, writer in
self.queue.sync {
Copy link
Member Author

Choose a reason for hiding this comment

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

All 3 Features now perform sync on the event write context. This is not set in stone, and I'm exploring ways of synchronising Features with the shared context.

Copy link
Member

Choose a reason for hiding this comment

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

👍 Just submitted my review on that 🙂. Definitely, we need to explore the impact of this in high load situations. I'll think of possible solutions as well.

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 great in overall 👌. I feel that the V1Context layer we added now pays off in this migration 🙌.

The main concern I have is about performing queue.sync {} in Features, but I believe this is exactly the topic we're now exploring, right?

Comment on lines -118 to +111
queue.sync {
self.queue.sync {
Copy link
Member

Choose a reason for hiding this comment

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

@maxep Does lack of queue.async {} here correspond to Features context synchronisation issue we've been debating about?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! still exploring solution. It will be change in future PR.

Comment on lines +10 to 16
init(context: DatadogContext) {
self.init(device: context.device)
}

init(context: DatadogV1Context) {
self.init(device: context.device)
}
Copy link
Member

Choose a reason for hiding this comment

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

We need both because of V1 context leftover in Crash Reporting, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.. crash reporting and web view tracking. Both integration are still using v1 context

@maxep maxep marked this pull request as ready for review September 1, 2022 13:52
@maxep maxep requested a review from a team as a code owner September 1, 2022 13:52
@maxep maxep requested a review from ncreated September 2, 2022 13:42
attributes: .concurrent
qos: .utility
Copy link
Member

Choose a reason for hiding this comment

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

Given it is serial now, it no longer makes sense to do .barrier in following code, no?

func write(block: @escaping (inout DatadogContext) -> Void) {
   queue.async(flags: .barrier)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, .barrier will have no effect on the serial queue, but I would like to keep it for now and move back to concurrency with a better threading design later.

Copy link
Member

Choose a reason for hiding this comment

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

Got it 👌. Good to go as it is targeting feature branch 👍

@maxep maxep merged commit caff7b0 into feature/v2 Sep 12, 2022
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.

2 participants