@@ -34,7 +34,7 @@ var testingSpan = &model.Span{
34
34
SpanID : model .NewSpanID (1 ),
35
35
Process : & model.Process {
36
36
ServiceName : "serviceName" ,
37
- Tags : model.KeyValues {} ,
37
+ Tags : [] model.KeyValue ( nil ) ,
38
38
},
39
39
OperationName : "operationName" ,
40
40
Tags : model.KeyValues {
@@ -43,14 +43,14 @@ var testingSpan = &model.Span{
43
43
},
44
44
Logs : []model.Log {
45
45
{
46
- Timestamp : time .Now (),
46
+ Timestamp : time .Now (). UTC () ,
47
47
Fields : []model.KeyValue {
48
48
model .String ("logKey" , "logValue" ),
49
49
},
50
50
},
51
51
},
52
52
Duration : time .Second * 5 ,
53
- StartTime : time .Unix (300 , 0 ),
53
+ StartTime : time .Unix (300 , 0 ). UTC () ,
54
54
}
55
55
56
56
var childSpan1 = & model.Span {
@@ -128,6 +128,14 @@ var childSpan2_1 = &model.Span{
128
128
StartTime : time .Unix (300 , 0 ),
129
129
}
130
130
131
+ // This kind of trace cannot be serialized
132
+ var nonSerializableSpan = & model.Span {
133
+ Process : & model.Process {
134
+ ServiceName : "naughtyService" ,
135
+ },
136
+ StartTime : time .Date (0 , 0 , 0 , 0 , 0 , 0 , 0 , time .UTC ),
137
+ }
138
+
131
139
func withPopulatedMemoryStore (f func (store * Store )) {
132
140
memStore := NewStore ()
133
141
memStore .WriteSpan (context .Background (), testingSpan )
@@ -210,6 +218,34 @@ func TestStoreGetTraceSuccess(t *testing.T) {
210
218
})
211
219
}
212
220
221
+ func TestStoreGetAndMutateTrace (t * testing.T ) {
222
+ withPopulatedMemoryStore (func (store * Store ) {
223
+ trace , err := store .GetTrace (context .Background (), testingSpan .TraceID )
224
+ assert .NoError (t , err )
225
+ assert .Len (t , trace .Spans , 1 )
226
+ assert .Equal (t , testingSpan , trace .Spans [0 ])
227
+ assert .Len (t , trace .Spans [0 ].Warnings , 0 )
228
+
229
+ trace .Spans [0 ].Warnings = append (trace .Spans [0 ].Warnings , "the end is near" )
230
+
231
+ trace , err = store .GetTrace (context .Background (), testingSpan .TraceID )
232
+ assert .NoError (t , err )
233
+ assert .Len (t , trace .Spans , 1 )
234
+ assert .Equal (t , testingSpan , trace .Spans [0 ])
235
+ assert .Len (t , trace .Spans [0 ].Warnings , 0 )
236
+ })
237
+ }
238
+
239
+ func TestStoreGetTraceError (t * testing.T ) {
240
+ withPopulatedMemoryStore (func (store * Store ) {
241
+ store .traces [testingSpan .TraceID ] = & model.Trace {
242
+ Spans : []* model.Span {nonSerializableSpan },
243
+ }
244
+ _ , err := store .GetTrace (context .Background (), testingSpan .TraceID )
245
+ assert .Error (t , err )
246
+ })
247
+ }
248
+
213
249
func TestStoreGetTraceFailure (t * testing.T ) {
214
250
withPopulatedMemoryStore (func (store * Store ) {
215
251
trace , err := store .GetTrace (context .Background (), model.TraceID {})
@@ -282,6 +318,15 @@ func TestStoreGetEmptyTraceSet(t *testing.T) {
282
318
})
283
319
}
284
320
321
+ func TestStoreFindTracesError (t * testing.T ) {
322
+ withPopulatedMemoryStore (func (store * Store ) {
323
+ err := store .WriteSpan (context .Background (), nonSerializableSpan )
324
+ assert .NoError (t , err )
325
+ _ , err = store .FindTraces (context .Background (), & spanstore.TraceQueryParameters {ServiceName : "naughtyService" })
326
+ assert .Error (t , err )
327
+ })
328
+ }
329
+
285
330
func TestStoreFindTracesLimitGetsMostRecent (t * testing.T ) {
286
331
storeSize , querySize := 100 , 10
287
332
0 commit comments