REPLAY-1887 Provide the uploadFrequency per feature#1533
Conversation
xgouchet
left a comment
There was a problem hiding this comment.
It works, my main concern is making the core configuration's upload frequency optional.
It would be better to keep the core configuration mandatory, and make individual features override optional. If you flip the resolveUploadFrequency logic to the following, it would work better (that way people can just override the one feature they want a different upload frequency)
private fun resolveUploadFrequency(
coreFeature: CoreFeature,
storageConfiguration: FeatureStorageConfiguration
): UploadFrequency {
return storageConfiguration.uploadFrequency ?: coreFeature.uploadFrequency
}
Tks @xgouchet, I think that's even better for now. My idea was that at some point we will drop this API at the core level as it doesn't make sense to have it anymore there. We could simplify it by having this only in the |
32f490b to
5555a4a
Compare
ncreated
left a comment
There was a problem hiding this comment.
The override logic looks good 👌
5555a4a to
fb29a38
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1533 +/- ##
===========================================
- Coverage 83.62% 83.36% -0.26%
===========================================
Files 438 440 +2
Lines 14854 14871 +17
Branches 2237 2239 +2
===========================================
- Hits 12421 12396 -25
- Misses 1868 1884 +16
- Partials 565 591 +26
|
| val uploadFrequency: UploadFrequency? = null, | ||
| val batchSize: BatchSize? = null |
There was a problem hiding this comment.
it makes more sense to put default values into the DEFAULT object maybe?
There was a problem hiding this comment.
actually not...I prefer NULL, it's easier when I resolve them (if it is set here I take this one if not I take the core one)
There was a problem hiding this comment.
Yes, what I mean is to keep nullable type here, but put default null value to the DEFAULT object.
There was a problem hiding this comment.
hmm let me look into that, not sure I understand :)
There was a problem hiding this comment.
oh yeah, I see your point, done ;)
|
|
||
| import com.datadog.android.api.storage.FeatureStorageConfiguration | ||
|
|
||
| internal class BatchingDelayResolver { |
There was a problem hiding this comment.
imo it is a bit too much of abstractions, let's maybe just mock values returned by the wrappedFeature in the SdkFeature? Same for another resolver.
There was a problem hiding this comment.
I get your point, in the same time I prefer to have them separated and do not mix responsibilities. It's way easier for unit testing. I also suspect that this logic will change later so in that case SdkFeature will not change anymore and we will just change the resolver. What do you think ?
There was a problem hiding this comment.
not a fan of the overhead introduced by the resolvers either, it would be cleaner to not use them IMO
There was a problem hiding this comment.
I will try to add these as private methods instead, just need to find a better way to test it without too much noise.
| private val networkInfoProvider: NetworkInfoProvider, | ||
| private val systemInfoProvider: SystemInfoProvider, | ||
| uploadFrequency: UploadFrequency, | ||
| internal val uploadFrequency: UploadFrequency, |
| } | ||
|
|
||
| @Test | ||
| fun `M provide the core frequency W resolveUploadFrequency{not provide in storage config}`() { |
There was a problem hiding this comment.
| fun `M provide the core frequency W resolveUploadFrequency{not provide in storage config}`() { | |
| fun `M provide the core frequency W resolveUploadFrequency{not provided in storage config}`() { |
cd35303 to
702f13d
Compare
702f13d to
81fa32a
Compare
| * @property uploadFrequency the desired upload frequency policy | ||
| * @property batchSize the desired batch size policy |
There was a problem hiding this comment.
minor: maybe we should say, that if not explicitly provided, then value will be taken from the core configuration.
| whenever(mockWrappedFeature.storageConfiguration) | ||
| .thenReturn(fakeStorageConfig) | ||
| // When | ||
|
|
||
| testedFeature.initialize(appContext.mockInstance) |
There was a problem hiding this comment.
| whenever(mockWrappedFeature.storageConfiguration) | |
| .thenReturn(fakeStorageConfig) | |
| // When | |
| testedFeature.initialize(appContext.mockInstance) | |
| whenever(mockWrappedFeature.storageConfiguration) | |
| .thenReturn(fakeStorageConfig) | |
| // When | |
| testedFeature.initialize(appContext.mockInstance) |
| } | ||
|
|
||
| @Test | ||
| fun `𝕄 initialize the storage 𝕎 initialize()`() { |
There was a problem hiding this comment.
with core batch size probably is missing in the name?
There was a problem hiding this comment.
I am considering this as default initialization so wanted to keep it as that in the test description
81fa32a to
6118490
Compare
What does this PR do?
This PR is follow - up on the ios PR where we are providing a custom (batchSize, uploadFrequency) configuration for Session Replay feature to decrease the number of sessions with corrupted/not-enough records.
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)