-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e.tempo.reader.js
104 lines (92 loc) · 4.43 KB
/
e2e.tempo.reader.js
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
100
101
102
const {_it, axiosGet, clokiExtUrl, storage} = require("./common");
_it('should read otlp', async () => {
const span = storage.test_span
const res = await axiosGet(`http://${clokiExtUrl}/api/traces/${span.spanContext().traceId.toUpperCase()}/json`)
const data = res.data
data.resourceSpans[0].instrumentationLibrarySpans[0].spans[0].attributes.sort((a,b) => a.key.localeCompare(b.key))
const validation = data.resourceSpans[0].instrumentationLibrarySpans[0].spans[0]
delete validation.traceID
delete validation.traceId
delete validation.spanID
delete validation.spanId
delete validation.startTimeUnixNano
delete validation.endTimeUnixNano
delete validation.events[0].timeUnixNano
expect(validation).toMatchSnapshot()
}, ['should send otlp'])
_it('should read zipkin', async () => {
await new Promise(resolve => setTimeout(resolve, 500))
const res = await axiosGet(`http://${clokiExtUrl}/api/traces/0000000000000000d6e9329d67b6146c/json`)
console.log(res.data)
const data = res.data
const validation = data.resourceSpans[0].instrumentationLibrarySpans[0].spans[0]
expect(validation.spanID).toEqual('1234ef45')
delete validation.traceID
delete validation.spanID
delete validation.spanId
delete validation.startTimeUnixNano
delete validation.endTimeUnixNano
expect(validation).toMatchSnapshot()
}, ['should send zipkin'])
_it('should read /tempo/spans', async () => {
await new Promise(resolve => setTimeout(resolve, 500))
const res = await axiosGet(`http://${clokiExtUrl}/api/traces/0000000000000000d6e9329d67b6146d/json`)
console.log(res.data)
const data = res.data
const validation = data.resourceSpans[0].instrumentationLibrarySpans[0].spans[0]
expect(validation.spanID).toEqual('1234ef46')
delete validation.traceID
delete validation.spanID
delete validation.spanId
delete validation.startTimeUnixNano
delete validation.endTimeUnixNano
expect(validation).toMatchSnapshot()
}, ['should post /tempo/spans'])
_it('should read /api/v2/spans', async () => {
await new Promise(resolve => setTimeout(resolve, 500))
const res = await axiosGet(`http://${clokiExtUrl}/api/traces/0000000000000000d6e9329d67b6146e/json`)
const data = res.data
const validation = data.resourceSpans[0].instrumentationLibrarySpans[0].spans[0]
expect(validation.spanID).toEqual('1234ef46')
delete validation.traceID
delete validation.spanID
delete validation.spanId
delete validation.startTimeUnixNano
delete validation.endTimeUnixNano
expect(validation).toMatchSnapshot()
}, ['should post /tempo/spans'])
_it('should read /api/search/tags', async () => {
const res = await axiosGet(`http://${clokiExtUrl}/api/search/tags`)
const data = res.data
for (const tagname of ['http.method', 'http.path', 'service.name', 'name']) {
expect(data.find(t => t === tagname)).toBeTruthy();
}
}, ['should post /tempo/spans', 'should send zipkin', 'should post /tempo/spans'])
_it('should read /api/search/tag/.../values', async () => {
for (const tagname of [['http.method', 'GET'],
['http.path', '/tempo/spans'],
['service.name', 'node script'],
['name', 'span from http']]) {
console.log(`http://${clokiExtUrl}/api/search/tag/${tagname[0]}/values`)
const res = await axiosGet(`http://${clokiExtUrl}/api/search/tag/${tagname[0]}/values`)
const data = res.data.tagValues
console.log(data)
expect(data.find(t => t === tagname[1])).toBeTruthy();
}
}, ['should post /tempo/spans', 'should send zipkin', 'should post /tempo/spans'])
_it('should get /api/search', async () => {
console.log(`http://${clokiExtUrl}/api/search?tags=${
encodeURIComponent('service.name="node script"')
}&minDuration=900ms&maxDuration=1100ms&start=${Math.floor(Date.now() / 1000) - 300}&end=${Math.floor(Date.now() / 1000)+1}`)
const res = await axiosGet(`http://${clokiExtUrl}/api/search?tags=${
encodeURIComponent('service.name="node script"')
}&minDuration=900ms&maxDuration=1100ms&start=${Math.floor(Date.now() / 1000) - 300}&end=${Math.floor(Date.now() / 1000)+1}`)
const data = res.data.traces[0]
delete data['startTimeUnixNano']
expect(data).toMatchSnapshot()
}, ['should /api/v2/spans'])
_it('should get /api/echo', async () => {
const res = await axiosGet(`http://${clokiExtUrl}/api/echo`)
const data = res.data
expect(data).toEqual('echo')
})