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-3569 Store and filter resource ids between sessions #1747

Merged
merged 13 commits into from
Apr 15, 2024

Conversation

maciejburda
Copy link
Member

@maciejburda maciejburda commented Mar 26, 2024

What and why?

Adds a "between session" duplicate filtering of resources. This local store is wiped after hardcoded 30 days (standard SR retention), which was agreed with the backend in order to reupload images in regular cadence.

How?

Leverages new DataStore inside of the ResourceWriter and stores two values: set of known resource ids and store creation timestamp.

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 for Core, RUM, Trace, Logs, CR and WVT
  • Run unit tests for Session Replay
  • Run integration tests
  • Run smoke tests
  • Run tests for tools/

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Mar 26, 2024

Datadog Report

Branch report: maciey/RUM-3569-store-and-filter-resource-ids
Commit report: 85647cb
Test service: dd-sdk-ios

❌ 1 Failed (0 Known Flaky), 2667 Passed, 0 Skipped, 5m 4.52s Wall Time
🔻 Test Sessions change in coverage: 8 decreased, 4 increased

❌ Failed Tests (1)

  • testWhenMemoryConsumptionGrows - VitalMemoryReaderTest

🔻 Code Coverage Decreases vs Default Branch (8)

This report shows up to 5 code coverage decreases.

  • test DatadogCrashReportingTests iOS 27.87% (-0.69%) - Details
  • test DatadogWebViewTrackingTests iOS 17.15% (-0.66%) - Details
  • test DatadogTraceTests iOS 48.74% (-0.45%) - Details
  • test DatadogTraceTests tvOS 48.86% (-0.38%) - Details
  • test DatadogLogsTests iOS 45.32% (-0.16%) - Details

@maciejburda maciejburda marked this pull request as ready for review March 27, 2024 10:42
@maciejburda maciejburda requested review from a team as code owners March 27, 2024 10:42
Comment on lines +45 to -50
let resources = ResourcesFeature(core: core, configuration: configuration)
try core.register(feature: resources)

let sessionReplay = try SessionReplayFeature(core: core, configuration: configuration)
try core.register(feature: sessionReplay)

let resources = ResourcesFeature(core: core, configuration: configuration)
try core.register(feature: resources)
Copy link
Member Author

Choose a reason for hiding this comment

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

Interestingly enough - this order matters. Since we use resources data store in session replay recorder it requires resources feature to be registered before.

Raises a question if it would make sense to add new function that registers array of features.

Copy link
Member

Choose a reason for hiding this comment

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

It should be no longer the case after we switched from core to dependency on FeatureScope. Starting from #1744 Make FeatureScope always available, the FeatureScope is always available, even before certain feature is registered 🧹.

@ReadWriteLock
private var knownIdentifiers = Set<String>() {
didSet {
if let knownIdentifiers = knownIdentifiers.asData() {
Copy link
Member Author

@maciejburda maciejburda Mar 27, 2024

Choose a reason for hiding this comment

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

resources come in bulks per view tree capture. Because of that it felt good enough to update the data store on didSet.


init(
core: DatadogCoreProtocol
core: DatadogCoreProtocol,
dataStoreResetTime: TimeInterval = TimeInterval(30).days
Copy link
Member Author

@maciejburda maciejburda Mar 27, 2024

Choose a reason for hiding this comment

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

It's minimal effort on our side. Lowest possible SR retention is 30 days. With this, we enable gradual removal of unused image resources. Meaning that if backend clears stored images on their end every 30 days, we'll make sure to reupload only images that we see during the session.

}
}

enum Constants {
Copy link
Member Author

Choose a reason for hiding this comment

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

this and below are internal to be able to access them in tests (avoids reimplementing or retyping)

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.

I left few suggestions on DS usage and FeatureScope integration 🙂

@maciejburda maciejburda requested a review from ncreated March 28, 2024 12:10
@maciejburda maciejburda force-pushed the maciey/RUM-3569-store-and-filter-resource-ids branch from e42f6ca to 0799040 Compare April 2, 2024 12:20
ncreated
ncreated previously approved these changes Apr 3, 2024
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.

With a remark on caching JSON coders, it looks good for DS integration 👍.

Comment on lines +45 to -50
let resources = ResourcesFeature(core: core, configuration: configuration)
try core.register(feature: resources)

let sessionReplay = try SessionReplayFeature(core: core, configuration: configuration)
try core.register(feature: sessionReplay)

let resources = ResourcesFeature(core: core, configuration: configuration)
try core.register(feature: resources)
Copy link
Member

Choose a reason for hiding this comment

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

It should be no longer the case after we switched from core to dependency on FeatureScope. Starting from #1744 Make FeatureScope always available, the FeatureScope is always available, even before certain feature is registered 🧹.

@maciejburda maciejburda force-pushed the maciey/RUM-3569-store-and-filter-resource-ids branch from 0799040 to e2b5005 Compare April 12, 2024 13:27
CHANGELOG.md Outdated

* [FEATURE] Add support for 128 bit trace IDs. See [#1721][]
* [FEATURE] Fatal App Hangs are tracked in RUM. See [#1763][]
* [FIX] Avoid name collision with Required Reason APIs. See [#1774][]

# 2.9.0 / 11-04-2024

* [IMPROVEMENT] Add image duplicate detection between sessions. See [#1747][]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [IMPROVEMENT] Add image duplicate detection between sessions. See [#1747][]

@maciejburda maciejburda merged commit b63af60 into develop Apr 15, 2024
8 checks passed
@maciejburda maciejburda deleted the maciey/RUM-3569-store-and-filter-resource-ids branch April 15, 2024 13:27
This was referenced Apr 16, 2024
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