-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
49 lines (45 loc) · 1.11 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"testing"
"github.com/vmihailenco/msgpack/v5"
)
func TestDeserialiseMsgPackTrace(t *testing.T) {
// Setup
testSpan := ddspan{
Service: "clowncar.consumer",
Name: "kafka.consume",
Resource: "Consume Topic kumamon-pics",
TraceID: 2621704535220764017,
SpanID: 5480210989507178917,
ParentID: 2621704535220764017,
Start: 1670560555960703334,
Duration: 1025388084,
Error: 0,
Meta: map[string]string{
"system.pid": "1",
"runtime.id": "da557be3-da3a-4f3d-8aa5-86c4339fcfbc",
"env": "test",
"_dd.p.dm": "-3",
},
Metrics: map[string]float64{
"_sampling_priority_v1": 2,
"partition": 0,
"offset": 57,
"_dd.top_level": 1,
},
Type: "synthetics",
}
traceBundle := ddtraces{ddtrace{testSpan}}
payload, err := msgpack.Marshal(traceBundle)
if err != nil {
t.Fatal(err)
}
// Actual test
unpackedTraces, err := deserialiseMsgpackTraces(payload)
if err != nil {
t.Fatalf("Received an error: %v", err)
}
if len(unpackedTraces) == 0 {
t.Fatal("Received 0 traces in deserialised trace bundle")
}
}