Skip to content

Commit

Permalink
RUM-2127 Create a SetSyntheticsTestAttribute event
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Nov 15, 2023
1 parent 8196669 commit 210ced7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ internal sealed class RumRawEvent {
override val eventTime: Time = Time()
) : RumRawEvent()

internal data class SetSyntheticsTestAttribute(
val testId: String,
val resultId: String?,
override val eventTime: Time = Time()
) : RumRawEvent()

internal data class WebViewEvent(override val eventTime: Time = Time()) : RumRawEvent()

internal data class SendTelemetry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ internal interface AdvancedRumMonitor : RumMonitor, AdvancedNetworkRumMonitor {
fun sendConfigurationTelemetryEvent(coreConfiguration: TelemetryCoreConfiguration)

fun updatePerformanceMetric(metric: RumPerformanceMetric, value: Double)

fun setSyntheticsAttribute(testId: String, resultId: String?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ internal class DatadogRumMonitor(
handleEvent(RumRawEvent.UpdatePerformanceMetric(metric, value))
}

override fun setSyntheticsAttribute(
testId: String,
resultId: String?
) {
handleEvent(RumRawEvent.SetSyntheticsTestAttribute(testId, resultId))
}

override fun _getInternal(): _RumInternalProxy {
return internalProxy
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,26 @@ internal class DatadogRumMonitorTest {
}
}

@Test
fun `M handle synthetics test attributes W setSyntheticsTestAttribute()`(
@StringForgery fakeTestId: String,
@StringForgery fakeResultId: String
) {
// When
testedMonitor.setSyntheticsAttribute(fakeTestId, fakeResultId)
Thread.sleep(PROCESSING_DELAY)

// Then
argumentCaptor<RumRawEvent.SetSyntheticsTestAttribute> {
verify(mockScope).handleEvent(
capture(),
eq(mockWriter)
)
assertThat(lastValue.testId).isEqualTo(fakeTestId)
assertThat(lastValue.resultId).isEqualTo(fakeResultId)
}
}

@Test
fun `M allow only one thread inside rootScope#handleEvent at the time W handleEvent()`(
forge: Forge
Expand Down

0 comments on commit 210ced7

Please sign in to comment.