forked from kubemq-io/kubemq-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace.go
44 lines (38 loc) · 952 Bytes
/
trace.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
package kubemq
import (
"time"
"go.opencensus.io/trace"
)
type Trace struct {
Name string
attributes []trace.Attribute
annotation trace.Annotation
}
func CreateTrace(name string) *Trace {
t := &Trace{
Name: name,
attributes: nil,
annotation: trace.Annotation{},
}
return t
}
func (t *Trace) AddStringAttribute(key string, value string) *Trace {
t.attributes = append(t.attributes, trace.StringAttribute(key, value))
return t
}
func (t *Trace) AddInt64Attribute(key string, value int64) *Trace {
t.attributes = append(t.attributes, trace.Int64Attribute(key, value))
return t
}
func (t *Trace) AddBoolAttribute(key string, value bool) *Trace {
t.attributes = append(t.attributes, trace.BoolAttribute(key, value))
return t
}
func (t *Trace) AddAnnotation(timestamp time.Time, message string) *Trace {
t.annotation = trace.Annotation{
Time: timestamp,
Message: message,
Attributes: nil,
}
return t
}