Skip to content

Commit 2c6ccbb

Browse files
committed
RUM-10930: ignore sample priority in metrics in case if not set
1 parent 54017bc commit 2c6ccbb

File tree

6 files changed

+12
-16
lines changed

6 files changed

+12
-16
lines changed

features/dd-sdk-android-trace-internal/src/test/kotlin/com/datadog/trace/core/DDSpanTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ internal class DDSpanTest : DDCoreSpecification() {
499499

500500
// Then
501501
val expectedLimit = if (limit == Int.MAX_VALUE) null else limit
502-
assertThat(span.spanSamplingPriority).isEqualTo(PrioritySampling.UNSET.toInt())
502+
assertThat(span.traceSamplingPriority).isNull()
503503

504504
// When
505505
span.setSpanSamplingPriority(rate, limit)
@@ -509,7 +509,7 @@ internal class DDSpanTest : DDCoreSpecification() {
509509
.isEqualTo(SamplingMechanism.SPAN_SAMPLING_RATE)
510510
assertThat(span.getTag(DDSpanContext.SPAN_SAMPLING_RULE_RATE_TAG)).isEqualTo(rate)
511511
assertThat(span.getTag(DDSpanContext.SPAN_SAMPLING_MAX_PER_SECOND_TAG)).isEqualTo(expectedLimit)
512-
assertThat(span.spanSamplingPriority).isEqualTo(PrioritySampling.UNSET.toInt())
512+
assertThat(span.traceSamplingPriority).isNull()
513513
}
514514

515515
@Test

features/dd-sdk-android-trace-otel/src/test/kotlin/com/datadog/android/trace/opentelemetry/OtelTracerBuilderProviderTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ internal class OtelTracerBuilderProviderTest {
369369

370370
// Then
371371
val priority = delegateSpan.samplingPriority
372-
assertThat(priority).isEqualTo(DatadogTracingConstants.PrioritySampling.USER_KEEP.toInt())
372+
assertThat(priority).isEqualTo(DatadogTracingConstants.PrioritySampling.SAMPLER_KEEP)
373373
}
374374

375375
@Test
376-
fun `M use user-drop priority W buildSpan { provide not keep sample rate }`() {
376+
fun `M use sampler-drop priority W buildSpan { provide not keep sample rate }`() {
377377
// Given
378378
val tracer = testedOtelTracerProviderBuilder
379379
.setPartialFlushThreshold(1)
@@ -392,11 +392,11 @@ internal class OtelTracerBuilderProviderTest {
392392

393393
// Then
394394
val priority = delegateSpan.samplingPriority
395-
assertThat(priority).isEqualTo(DatadogTracingConstants.PrioritySampling.USER_DROP)
395+
assertThat(priority).isEqualTo(DatadogTracingConstants.PrioritySampling.SAMPLER_DROP)
396396
}
397397

398398
@Test
399-
fun `M use user-keep or user-not-keep priority W buildSpan { provided random sample rate }`(
399+
fun `M use sampler-keep or sampler-not-keep priority W buildSpan { provided random sample rate }`(
400400
@DoubleForgery(min = 0.0, max = 100.0) sampleRate: Double,
401401
forge: Forge
402402
) {
@@ -423,9 +423,9 @@ internal class OtelTracerBuilderProviderTest {
423423
}
424424
spans.forEach { it.end() }
425425
val droppedSpans =
426-
delegatedSpans.filter { it.samplingPriority == DatadogTracingConstants.PrioritySampling.USER_DROP.toInt() }
426+
delegatedSpans.filter { it.samplingPriority == DatadogTracingConstants.PrioritySampling.SAMPLER_DROP }
427427
val keptSpans =
428-
delegatedSpans.filter { it.samplingPriority == DatadogTracingConstants.PrioritySampling.USER_KEEP.toInt() }
428+
delegatedSpans.filter { it.samplingPriority == DatadogTracingConstants.PrioritySampling.SAMPLER_KEEP }
429429

430430
// Then
431431
assertThat(droppedSpans.size + keptSpans.size).isEqualTo(numberOfSpans)

features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/domain/event/CoreTracerSpanToSpanEventMapper.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ internal class CoreTracerSpanToSpanEventMapper(
6565
// TODO RUM-10805 - make it back private and re-create objects in tests
6666
internal fun resolveMetrics(event: DDSpan): SpanEvent.Metrics {
6767
val metrics = resolveMetricsFromSpanContext(event).apply {
68-
if (event.spanSamplingPriority != PrioritySampling.UNSET.toInt()) {
68+
val spanSamplingPriority = event.spanSamplingPriority
69+
if (spanSamplingPriority != PrioritySampling.UNSET.toInt()) {
6970
// This required for backward compatibility with AndroidTracer that
7071
// don't add the sampling priority if it not set for current span.
71-
this[DDSpanContext.PRIORITY_SAMPLING_KEY] = event.spanSamplingPriority
72+
this[DDSpanContext.PRIORITY_SAMPLING_KEY] = spanSamplingPriority
7273
}
7374
}
7475
return SpanEvent.Metrics(

features/dd-sdk-android-trace/src/test/kotlin/com/datadog/android/utils/forge/CoreDDSpanForgeryFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal class CoreDDSpanForgeryFactory : ForgeryFactory<DDSpan> {
6060
whenever(it.parentId).thenReturn(parentId)
6161
whenever(it.baggage).thenReturn(baggageItems)
6262
whenever(it.tags).thenReturn(tagsAndMetrics)
63-
whenever(it.spanSamplingPriority).thenReturn(samplingPriority)
63+
whenever(it.traceSamplingPriority).thenReturn(samplingPriority)
6464
whenever(it.links).thenReturn(spanLinks)
6565
}
6666
return mockDDSpan

reliability/single-fit/okhttp/src/test/kotlin/com/datadog/android/okhttp/SpanExtIntegrationTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class SpanExtIntegrationTest {
9696
mockServer.shutdown()
9797
}
9898

99-
10099
@Test
101100
fun `M return expected events W withinSpan {two composite spans}`() {
102101
registerTracer(partialFlushMinSpans = 1)
@@ -115,7 +114,6 @@ class SpanExtIntegrationTest {
115114
val rootSpanJson = eventsWritten[0].asJson()
116115
val childSpanJson = eventsWritten[1].asJson()
117116

118-
119117
assertThat(isCalled).isTrue
120118
SpansPayloadAssert.assertThat(rootSpanJson)
121119
.hasEnv(expectedEnv)
@@ -175,7 +173,6 @@ class SpanExtIntegrationTest {
175173
val child1Json = checkNotNull(eventsJson[level1ChildSpanId])
176174
val child2Json = checkNotNull(eventsJson[level2ChildSpanId])
177175

178-
179176
assertThat(isCalled).isTrue
180177
SpansPayloadAssert.assertThat(rootSpanJson)
181178
.hasEnv(expectedEnv)
@@ -242,7 +239,6 @@ class SpanExtIntegrationTest {
242239
val rootSpanJson = eventsWritten[0].asJson()
243240
val childSpanJson = eventsWritten[1].asJson()
244241

245-
246242
assertThat(isCalled).isTrue
247243
SpansPayloadAssert.assertThat(rootSpanJson)
248244
.hasEnv(expectedEnv)

reliability/single-fit/okhttp/src/test/kotlin/com/datadog/android/okhttp/tests/assertj/SpansPayloadAssert.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ internal class SpansPayloadAssert(actual: JsonObject) :
116116
return this
117117
}
118118

119-
120119
fun hasResource(resource: String): SpanAssert {
121120
val actualResource = actualSpan.getString(RESOURCE_KEY)
122121
assertThat(actualResource).overridingErrorMessage(

0 commit comments

Comments
 (0)