File tree Expand file tree Collapse file tree 4 files changed +31
-5
lines changed
dd-sdk-android-internal/src/main/java/com/datadog/android/internal/utils
features/dd-sdk-android-trace-internal/src/test/kotlin/com/datadog/trace/core
integrations/dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace Expand file tree Collapse file tree 4 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,10 @@ package com.datadog.android.internal.utils
17
17
* ```
18
18
* now could be written as:
19
19
* ```kotlin
20
- val writer = featuredSdkCore.getFeature(Feature.TRACING_FEATURE_NAME)
21
- ?.unwrap<Feature>()
22
- ?.tryCastTo<com.datadog.android.trace.InternalCoreWriterProvider>()
23
- ?.getCoreTracerWriter()
20
+ val writer = featuredSdkCore.getFeature(Feature.TRACING_FEATURE_NAME)
21
+ ?.unwrap<Feature>()
22
+ ?.tryCastTo<com.datadog.android.trace.InternalCoreWriterProvider>()
23
+ ?.getCoreTracerWriter()
24
24
* ```
25
25
*/
26
26
inline fun <reified R > Any.tryCastTo (): R ? {
Original file line number Diff line number Diff line change @@ -92,13 +92,15 @@ internal class CoreSpanBuilderTest : DDCoreSpecification() {
92
92
val expectedResource = " fakeResource"
93
93
val expectedService = " fakeService"
94
94
val expectedType = " fakeType"
95
+ val expectedOrigin = " fakeOrigin"
95
96
96
97
// When
97
98
val thirdSpan = tracer
98
99
.buildSpan(instrumentationName, expectedName)
99
100
.withServiceName(" foo" )
100
101
.withResourceName(expectedResource)
101
102
.withServiceName(expectedService)
103
+ .withOrigin(expectedOrigin)
102
104
.withErrorFlag()
103
105
.withSpanType(expectedType)
104
106
.start()
@@ -110,6 +112,7 @@ internal class CoreSpanBuilderTest : DDCoreSpecification() {
110
112
assertThat(context.errorFlag).isTrue
111
113
assertThat(context.serviceName).isEqualTo(expectedService)
112
114
assertThat(context.spanType).isEqualTo(expectedType)
115
+ assertThat(context.origin).isEqualTo(expectedOrigin)
113
116
}
114
117
115
118
@ParameterizedTest
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ import org.junit.jupiter.api.Test
30
30
import org.junit.jupiter.params.ParameterizedTest
31
31
import org.junit.jupiter.params.provider.Arguments
32
32
import org.junit.jupiter.params.provider.MethodSource
33
+ import org.mockito.kotlin.any
34
+ import org.mockito.kotlin.doReturn
33
35
import org.mockito.kotlin.mock
34
36
import org.mockito.kotlin.times
35
37
import org.mockito.kotlin.verify
@@ -510,6 +512,27 @@ internal class DDSpanTest : DDCoreSpecification() {
510
512
assertThat(span.samplingPriority()).isEqualTo(PrioritySampling .UNSET .toInt())
511
513
}
512
514
515
+ @Test
516
+ fun `W drop T unregisterSpan is called` () {
517
+ val mockTrace = mock<PendingTrace > {
518
+ on { rootSpan } doReturn mock()
519
+ }
520
+
521
+ val mockContext = mock<DDSpanContext > {
522
+ on { traceId } doReturn mock<DDTraceId >()
523
+ on { trace } doReturn mockTrace
524
+ }
525
+
526
+ val span = tracer
527
+ .buildSpan(instrumentationName, " testSpan" )
528
+ .asChildOf(mockContext)
529
+ .start() as DDSpan
530
+
531
+ span.drop()
532
+
533
+ verify(mockTrace).unregisterSpan(any())
534
+ }
535
+
513
536
@Test
514
537
fun `error priorities should be respected` () {
515
538
// Given
Original file line number Diff line number Diff line change @@ -853,7 +853,7 @@ internal constructor(
853
853
private const val AGENT_PSR_ATTRIBUTE = " _dd.agent_psr"
854
854
private const val WRITER_PROVIDER_INTERFACE_NOT_IMPLEMENTED_ERROR_MESSAGE =
855
855
" The Tracing feature is not implementing the InternalCoreWriterProvider interface." +
856
- " No tracing data will be sent."
856
+ " No tracing data will be sent."
857
857
858
858
private val DEFAULT_LOCAL_TRACER_FACTORY : (SdkCore , Set <TracingHeaderType >) -> AgentTracer .TracerAPI =
859
859
{ sdkCore, tracingHeaderTypes: Set <TracingHeaderType > ->
You can’t perform that action at this time.
0 commit comments