-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixtures_test.go
More file actions
99 lines (79 loc) · 1.88 KB
/
Copy pathfixtures_test.go
File metadata and controls
99 lines (79 loc) · 1.88 KB
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 apex
import (
"time"
"github.com/microsoft/ApplicationInsights-Go/appinsights"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
trace "go.opentelemetry.io/otel/trace"
)
type mockTelemetryClient struct {
appinsights.TelemetryClient
tels []appinsights.Telemetry
closeDur time.Duration
}
func (tc *mockTelemetryClient) Track(tel appinsights.Telemetry) {
tc.tels = append(tc.tels, tel)
}
func (tc *mockTelemetryClient) Channel() appinsights.TelemetryChannel {
return &mockTelemetryChannel{closeDur: tc.closeDur}
}
type mockTelemetryChannel struct {
appinsights.TelemetryChannel
closeDur time.Duration
}
func (tc *mockTelemetryChannel) Close(t ...time.Duration) <-chan struct{} {
ch := make(chan struct{})
go func() {
time.Sleep(tc.closeDur)
ch <- struct{}{}
close(ch)
}()
return ch
}
type mockSpan struct {
sdktrace.ReadOnlySpan
name string
kind trace.SpanKind
status sdktrace.Status
startTime time.Time
endTime time.Time
traceId [16]byte
parentId [8]byte
spanId [8]byte
res *resource.Resource
attr []attribute.KeyValue
}
func (s *mockSpan) Name() string {
return s.name
}
func (s *mockSpan) SpanKind() trace.SpanKind {
return s.kind
}
func (s *mockSpan) Status() sdktrace.Status {
return s.status
}
func (s *mockSpan) StartTime() time.Time {
return s.startTime
}
func (s *mockSpan) EndTime() time.Time {
return s.endTime
}
func (s *mockSpan) Parent() trace.SpanContext {
return trace.NewSpanContext(trace.SpanContextConfig{
TraceID: s.traceId,
SpanID: s.parentId,
})
}
func (s *mockSpan) SpanContext() trace.SpanContext {
return trace.NewSpanContext(trace.SpanContextConfig{
TraceID: s.traceId,
SpanID: s.spanId,
})
}
func (s *mockSpan) Resource() *resource.Resource {
return s.res
}
func (s *mockSpan) Attributes() []attribute.KeyValue {
return s.attr
}