Repository navigation
RUM-17009: Preserve application attribution without an active RUM session #3970
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
Draft
+2,443
−1,470
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
26 changes: 26 additions & 0 deletions
26
dd-sdk-android-internal/src/main/java/com/datadog/android/internal/rum/RumSessionContext.kt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| * Copyright 2016-Present Datadog, Inc. | ||
| */ | ||
|
|
||
| package com.datadog.android.internal.rum | ||
|
|
||
| /** | ||
| * Snapshot of an existing RUM session, including sampled-out and expired sessions. | ||
| * | ||
| * @property id RUM session identifier. | ||
| * @property state Tracking state of the session. | ||
| * @property startReason Trigger that created the session. | ||
| * @property isActive Whether the session scope is active. | ||
| * @property sampleRate Session sampling rate as a percentage, from 0 to 100. | ||
| * @property hasTimeseries Whether the session has collected timeseries data. | ||
| */ | ||
| data class RumSessionContext( | ||
| val id: String, | ||
| val state: RumSessionState, | ||
| val startReason: RumSessionStartReason, | ||
| val isActive: Boolean, | ||
| val sampleRate: Float, | ||
| val hasTimeseries: Boolean | ||
| ) |
This file contains hidden or 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
This file contains hidden or 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
25 changes: 25 additions & 0 deletions
25
...xtures/kotlin/com/datadog/android/internal/tests/elmyr/RumSessionContextForgeryFactory.kt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| * Copyright 2016-Present Datadog, Inc. | ||
| */ | ||
|
|
||
| package com.datadog.android.internal.tests.elmyr | ||
|
|
||
| import com.datadog.android.internal.rum.RumSessionContext | ||
| import com.datadog.android.internal.rum.RumSessionStartReason | ||
| import com.datadog.android.internal.rum.RumSessionState | ||
| import fr.xgouchet.elmyr.Forge | ||
| import fr.xgouchet.elmyr.ForgeryFactory | ||
| import java.util.UUID | ||
|
|
||
| class RumSessionContextForgeryFactory : ForgeryFactory<RumSessionContext> { | ||
| override fun getForgery(forge: Forge): RumSessionContext = RumSessionContext( | ||
| id = forge.getForgery<UUID>().toString(), | ||
| state = forge.aValueFrom(RumSessionState::class.java), | ||
| startReason = forge.aValueFrom(RumSessionStartReason::class.java), | ||
| isActive = forge.aBool(), | ||
| sampleRate = forge.aFloat(min = 0f, max = 100f), | ||
| hasTimeseries = forge.aBool() | ||
| ) | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
is it just for an additional guard?
onContextUpdateargument for the context is ofMaptype, so it is not mutable unless receiver tries to cast to the mutable map explicitly (unlikely, I think).as a price to pay - extra object allocation and iteration to copy.
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.
Mapprevents writes through that reference, but the producer still mutates the underlying object. Session replay retains that reference, for example, so subsequent updates change its previous context too.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.
can you point to the code you are referencing?
HashMap(currentContext)is also only top-level copy, not the deep one.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.
SessionReplayRumContextProvider.onContextUpdate()retains the map withrumContext = context. On the next update,publishRumContext()clears and repopulates that same map before notifying receivers, sopreviousViewIdalready contains the new value and the view change is missed.Yes it's a shallow snapshot. I think it's enough for this issue because the IDs are immutable strings and the producer replaces top-level entries.