-
Notifications
You must be signed in to change notification settings - Fork 63
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-2076 Add the Configuration#setVitalsMonitorUpdateFrequency API #926
RUMM-2076 Add the Configuration#setVitalsMonitorUpdateFrequency API #926
Conversation
c559098
to
7720585
Compare
* Defines the frequency at which mobile vitals monitor updates the data. | ||
*/ | ||
enum class VitalsUpdateFrequency( | ||
internal val frequencyInMs: Long |
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.
This should be renamed periodInMs
.
Frequency is measured in Hertz. The value in ms is the period (the inverse of frequency). E.g. for a period of 100ms, the frequency is 10 Hz.
if (configuration.vitalsMonitorUpdateFrequency != VitalsUpdateFrequency.NEVER) { | ||
initializeVitalMonitors(configuration.vitalsMonitorUpdateFrequency.frequencyInMs) | ||
} |
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.
Two quick things, first of all, it'd make the onInitialize
method easier to read if you'd call just
initializeVitalMonitors(configuration.vitalsMonitorUpdateFrequency)
and did the check just there. Also let's only extract the periodInMs
when it's actually needed
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.
I had it like that in the first place, honestly was not sure which way would be better as doing the check in the method means a premature return, sometimes I like to avoid this. But yeah, I think it looks cleaner like that.
fun `M use the given frequency W setVitalsMonitorUpdateFrequency`(forge: Forge) { | ||
// Given | ||
val fakeFrequency = forge.aValueFrom(VitalsUpdateFrequency::class.java) | ||
|
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.
fun `M use the given frequency W setVitalsMonitorUpdateFrequency`(forge: Forge) { | |
// Given | |
val fakeFrequency = forge.aValueFrom(VitalsUpdateFrequency::class.java) | |
fun `M use the given frequency W setVitalsMonitorUpdateFrequency`( | |
@Forgery fakeFrequency: VitalsUpdateFrequency | |
) { |
@@ -217,9 +220,17 @@ internal class RumFeatureTest : SdkFeatureTest<Any, Configuration.Feature.RUM, R | |||
} | |||
|
|||
@Test | |||
fun `𝕄 setup vital monitors 𝕎 initialize()`() { | |||
fun `𝕄 setup vital monitors 𝕎 initialize { frequency != NEVER }`(forge: Forge) { |
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.
@ParameterizedTest
@EnumSource(VitalsUpdateFrequency::class, names = ["NEVER"], mode = EnumSource.Mode.EXCLUDE)
fun `𝕄 setup vital monitors 𝕎 initialize { frequency != NEVER }`(fakeFrequency: VitalsUpdateFrequency) {
…
)
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.
Yeah...make sense to have a parameterized test here instead.
@@ -311,15 +371,38 @@ internal class RumFeatureTest : SdkFeatureTest<Any, Configuration.Feature.RUM, R | |||
} | |||
|
|||
@Test | |||
fun `𝕄 initialize vital executor 𝕎 initialize()`() { | |||
fun `𝕄 initialize vital executor 𝕎 initialize { frequency != NEVER }()`(forge: Forge) { |
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.
@ParameterizedTest
@EnumSource(VitalsUpdateFrequency::class, names = ["NEVER"], mode = EnumSource.Mode.EXCLUDE)
fun `𝕄 initialize vital executor 𝕎 initialize { frequency != NEVER }`(fakeFrequency: VitalsUpdateFrequency) {
…
)
@@ -737,7 +749,8 @@ internal constructor( | |||
viewTrackingStrategy = ActivityViewTrackingStrategy(false), | |||
longTaskTrackingStrategy = MainLooperLongTaskStrategy(DEFAULT_LONG_TASK_THRESHOLD_MS), | |||
rumEventMapper = NoOpEventMapper(), | |||
backgroundEventTracking = false | |||
backgroundEventTracking = false, | |||
vitalsMonitorUpdateFrequency = VitalsUpdateFrequency.AVERAGE |
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.
so we are moving from 100 ms to 500 ms by default?
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.
Yeah, that was the agreement :)
dd-sdk-android/src/main/kotlin/com/datadog/android/rum/internal/RumFeature.kt
Show resolved
Hide resolved
7720585
to
a835ed6
Compare
Codecov Report
@@ Coverage Diff @@
## develop #926 +/- ##
===========================================
- Coverage 82.86% 82.76% -0.10%
===========================================
Files 263 265 +2
Lines 8977 9006 +29
Branches 1449 1449
===========================================
+ Hits 7438 7453 +15
- Misses 1144 1159 +15
+ Partials 395 394 -1
|
@@ -81,6 +87,11 @@ internal class RumFeatureTest : SdkFeatureTest<Any, Configuration.Feature.RUM, R | |||
mockChoreographerInstance(mockChoreographer) | |||
} | |||
|
|||
@AfterEach | |||
fun `stop RUM`() { | |||
RumFeature.stop() |
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.
I think it is not needed, because parent class SdkFeatureTest
will do a call to the testedFeature#stop
dd-sdk-android/dd-sdk-android/src/test/kotlin/com/datadog/android/core/internal/SdkFeatureTest.kt
Line 113 in 0b30629
testedFeature.stop() |
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.
Friday: I approved, but then I realized that we have no E2E test added for this new API.
* @param frequency as [VitalsUpdateFrequency] | ||
* @see [VitalsUpdateFrequency] | ||
*/ | ||
fun setVitalsUpdateFrequency(frequency: VitalsUpdateFrequency): Builder { |
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.
We need to add the E2E test for this 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.
Good point, I will add a task for this.
9983485
to
d0feae5
Compare
@@ -199,17 +210,18 @@ internal object RumFeature : SdkFeature<Any, Configuration.Feature.RUM>() { | |||
|
|||
private fun initializeVitalMonitor( | |||
vitalReader: VitalReader, | |||
vitalObserver: VitalObserver | |||
vitalObserver: VitalObserver, | |||
updateFrequencyInMs: Long |
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.
This should be named periodInMs
too
d0feae5
to
b63545e
Compare
What does this PR do?
In this PR we are introduce a new API :
ConfigurationBuilder.setVitalsUpdateFrequency(frequency)
where the frequency is an enum :This will allow the client to customise the update frequency for mobile vitals reader or disable this feature.
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)