@@ -11,12 +11,14 @@ import com.datadog.android.api.feature.Feature
11
11
import com.datadog.android.api.feature.FeatureScope
12
12
import com.datadog.android.api.feature.FeatureSdkCore
13
13
import com.datadog.android.core.internal.utils.loggableStackTrace
14
+ import com.datadog.android.core.internal.utils.toHexString
14
15
import com.datadog.android.internal.utils.loggableStackTrace
15
16
import com.datadog.android.log.LogAttributes
16
17
import com.datadog.android.trace.utils.verifyLog
17
18
import com.datadog.android.utils.forge.Configurator
18
19
import com.datadog.legacy.trace.api.DDTags
19
20
import com.datadog.opentracing.DDSpan
21
+ import com.datadog.opentracing.DDSpanContext
20
22
import fr.xgouchet.elmyr.Forge
21
23
import fr.xgouchet.elmyr.annotation.Forgery
22
24
import fr.xgouchet.elmyr.annotation.LongForgery
@@ -62,16 +64,22 @@ internal class AndroidSpanLogsHandlerTest {
62
64
@Mock
63
65
lateinit var mockSpan: DDSpan
64
66
65
- @LongForgery
67
+ @Mock
68
+ lateinit var mockSpanContext: DDSpanContext
69
+
70
+ @LongForgery(min = 1 )
66
71
var fakeTraceId: Long = 0L
67
72
68
73
@LongForgery
69
74
var fakeSpanId: Long = 0L
70
75
71
76
@BeforeEach
72
77
fun `set up` () {
78
+ whenever(mockSpan.context()) doReturn mockSpanContext
73
79
whenever(mockSpan.traceId) doReturn BigInteger .valueOf(fakeTraceId)
74
80
whenever(mockSpan.spanId) doReturn BigInteger .valueOf(fakeSpanId)
81
+ whenever(mockSpanContext.traceId) doReturn BigInteger .valueOf(fakeTraceId)
82
+ whenever(mockSpanContext.toSpanId()) doReturn fakeSpanId.toString()
75
83
76
84
whenever(
77
85
mockSdkCore.getFeature(Feature .LOGS_FEATURE_NAME )
@@ -103,7 +111,7 @@ internal class AndroidSpanLogsHandlerTest {
103
111
" message" to AndroidSpanLogsHandler .DEFAULT_EVENT_MESSAGE ,
104
112
" attributes" to mapOf (
105
113
Fields .EVENT to event,
106
- LogAttributes .DD_TRACE_ID to fakeTraceId.toString( ),
114
+ LogAttributes .DD_TRACE_ID to fakeTraceId.toHexString().padStart( 32 , ' 0 ' ),
107
115
LogAttributes .DD_SPAN_ID to fakeSpanId.toString()
108
116
)
109
117
)
@@ -131,7 +139,7 @@ internal class AndroidSpanLogsHandlerTest {
131
139
" message" to AndroidSpanLogsHandler .DEFAULT_EVENT_MESSAGE ,
132
140
" attributes" to mapOf (
133
141
Fields .EVENT to event,
134
- LogAttributes .DD_TRACE_ID to fakeTraceId.toString( ),
142
+ LogAttributes .DD_TRACE_ID to fakeTraceId.toHexString().padStart( 32 , ' 0 ' ),
135
143
LogAttributes .DD_SPAN_ID to fakeSpanId.toString()
136
144
),
137
145
" timestamp" to TimeUnit .MICROSECONDS .toMillis(timestampMicros)
@@ -147,7 +155,7 @@ internal class AndroidSpanLogsHandlerTest {
147
155
val fields = forge.aMap { anAlphabeticalString() to anAsciiString() }
148
156
val logAttributes = fields.toMutableMap()
149
157
.apply {
150
- put(LogAttributes .DD_TRACE_ID , fakeTraceId.toString( ))
158
+ put(LogAttributes .DD_TRACE_ID , fakeTraceId.toHexString().padStart( 32 , ' 0 ' ))
151
159
put(LogAttributes .DD_SPAN_ID , fakeSpanId.toString())
152
160
}
153
161
@@ -184,7 +192,7 @@ internal class AndroidSpanLogsHandlerTest {
184
192
val fields = forge.aMap { anAlphabeticalString() to anAsciiString() }
185
193
val logAttributes = fields.toMutableMap()
186
194
.apply {
187
- put(LogAttributes .DD_TRACE_ID , fakeTraceId.toString( ))
195
+ put(LogAttributes .DD_TRACE_ID , fakeTraceId.toHexString().padStart( 32 , ' 0 ' ))
188
196
put(LogAttributes .DD_SPAN_ID , fakeSpanId.toString())
189
197
}
190
198
@@ -216,7 +224,7 @@ internal class AndroidSpanLogsHandlerTest {
216
224
217
225
val logAttributes = fields.toMutableMap()
218
226
.apply {
219
- put(LogAttributes .DD_TRACE_ID , fakeTraceId.toString( ))
227
+ put(LogAttributes .DD_TRACE_ID , fakeTraceId.toHexString().padStart( 32 , ' 0 ' ))
220
228
put(LogAttributes .DD_SPAN_ID , fakeSpanId.toString())
221
229
}
222
230
@@ -262,7 +270,7 @@ internal class AndroidSpanLogsHandlerTest {
262
270
263
271
val logAttributes = fields.toMutableMap()
264
272
.apply {
265
- put(LogAttributes .DD_TRACE_ID , fakeTraceId.toString( ))
273
+ put(LogAttributes .DD_TRACE_ID , fakeTraceId.toHexString().padStart( 32 , ' 0 ' ))
266
274
put(LogAttributes .DD_SPAN_ID , fakeSpanId.toString())
267
275
}
268
276
@@ -304,7 +312,7 @@ internal class AndroidSpanLogsHandlerTest {
304
312
305
313
val logAttributes = fields.toMutableMap()
306
314
.apply {
307
- put(LogAttributes .DD_TRACE_ID , fakeTraceId.toString( ))
315
+ put(LogAttributes .DD_TRACE_ID , fakeTraceId.toHexString().padStart( 32 , ' 0 ' ))
308
316
put(LogAttributes .DD_SPAN_ID , fakeSpanId.toString())
309
317
}
310
318
@@ -353,7 +361,7 @@ internal class AndroidSpanLogsHandlerTest {
353
361
354
362
val logAttributes = fields.toMutableMap()
355
363
.apply {
356
- put(LogAttributes .DD_TRACE_ID , fakeTraceId.toString( ))
364
+ put(LogAttributes .DD_TRACE_ID , fakeTraceId.toHexString().padStart( 32 , ' 0 ' ))
357
365
put(LogAttributes .DD_SPAN_ID , fakeSpanId.toString())
358
366
}
359
367
@@ -404,7 +412,7 @@ internal class AndroidSpanLogsHandlerTest {
404
412
405
413
val logAttributes = fields.toMutableMap()
406
414
.apply {
407
- put(LogAttributes .DD_TRACE_ID , fakeTraceId.toString( ))
415
+ put(LogAttributes .DD_TRACE_ID , fakeTraceId.toHexString().padStart( 32 , ' 0 ' ))
408
416
put(LogAttributes .DD_SPAN_ID , fakeSpanId.toString())
409
417
}
410
418
0 commit comments