forked from flachnetz/dd-zipkin-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjaeger_test.go
99 lines (89 loc) · 2.53 KB
/
jaeger_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package codec
import (
"github.com/flachnetz/dd-zipkin-proxy/proxy"
. "github.com/onsi/gomega"
"strings"
"testing"
"time"
)
func TestParseJaeger(t *testing.T) {
g := NewGomegaWithT(t)
spans, err := ParseJaeger(strings.NewReader(encodedJaeger))
g.Expect(err).ToNot(HaveOccurred())
g.Expect(spans).To(HaveLen(1))
g.Expect(spans[0]).To(Equal(proxy.Span{
Id: 0xbeaf,
Trace: 0xdead,
Parent: 0xaaaa,
Name: "getconnection",
Service: "core-services",
// timestamp is also picked from the CS/CR if available
Timestamp: proxy.Timestamp(1560276970 * time.Second),
// duration is taken from the CS/CR if available
Duration: 1000 * time.Millisecond,
Tags: map[string]string{
"lc": "postgres",
tagProtocolVersion: tagJaeger,
},
Timings: proxy.Timings{
CS: proxy.Timestamp(1560276970 * time.Second),
CR: proxy.Timestamp(1560276971 * time.Second),
},
}))
}
const encodedJaeger = `
{
"data": [
{
"traceID": "dead",
"spans": [
{
"traceID": "dead",
"spanID": "beaf",
"operationName": "getconnection",
"references": [
{
"refType": "CHILD_OF",
"traceID": "dead",
"spanID": "aaaa"
}
],
"startTime": 1560276970000000,
"duration": 1000000,
"tags": [
{
"key": "component",
"type": "string",
"value": "postgres"
},
{
"key": "internal.span.format",
"type": "string",
"value": "zipkin"
},
{
"key": "span.kind",
"type": "string",
"value": "client"
}
],
"logs": [],
"processID": "p1",
"warnings": null
}
],
"processes": {
"p1": {
"serviceName": "core-services",
"tags": []
}
},
"warnings": null
}
],
"total": 0,
"limit": 0,
"offset": 0,
"errors": null
}
`