-
Notifications
You must be signed in to change notification settings - Fork 0
/
span.go
165 lines (142 loc) · 5.71 KB
/
span.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// This file is generated, DO NOT EDIT. It comes from the corresponding .zzzgo file
package xop
import (
"time"
"github.com/xoplog/xop-go/xopat"
"github.com/xoplog/xop-go/xopbase"
"github.com/xoplog/xop-go/xoptrace"
"github.com/mohae/deepcopy"
)
// Request provides access to the span that describes the overall
// request. Metadata may be added at the request level.
func (logger *Logger) Request() *Span {
return logger.request.capSpan
}
// Request provides access to the current span
// Metadata may be added at the span level.
func (logger *Logger) Span() *Span {
return logger.capSpan
}
func (span *Span) TraceState() xoptrace.State { return span.seed.traceBundle.State }
func (span *Span) TraceBaggage() xoptrace.Baggage { return span.seed.traceBundle.Baggage }
func (span *Span) ParentTrace() xoptrace.Trace { return span.seed.traceBundle.Parent.Copy() }
func (span *Span) Trace() xoptrace.Trace { return span.seed.traceBundle.Trace.Copy() }
func (span *Span) Bundle() xoptrace.Bundle { return span.seed.traceBundle.Copy() }
func (span *Span) eft() *Span {
span.logger.hasActivity(true)
return span
}
// Int64 adds a int64 key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Int64(k *xopat.Int64Attribute, v int64) *Span {
span.base.MetadataInt64(k, v)
return span.eft()
}
// EmbeddedEnum adds a kev/value attribute to the Span. The key and the value
// are bundled together: the key is derrived from the type of the Enum.
// Alternatively, use xopat.KeyedEnumAttribute() to create functions
// to add enum key/value pairs where the key and value are specified
// separately. See xopconst.SpanType for an example of creating an
// EmbeddedEnum.
// The return value does not need to be used.
func (span *Span) EmbeddedEnum(kv xopat.EmbeddedEnum) *Span {
return span.Enum(kv.EnumAttribute(), kv)
}
// AnyImmutable adds a key/value attribute to the current Span. The provided
// value must be immutable. If it is not, then there could be race conditions
// or the value that ends up logged could be different from the value at the
// time when AnyImmutible was called.
//
// While the AnyAttribute has an expectation
// for the type of the value, that type may or may not be checked depending
// on the base logger being used.
// The return value does not need to be used.
func (span *Span) AnyImmutable(k *xopat.AnyAttribute, v interface{}) *Span {
span.base.MetadataAny(k, xopbase.ModelArg{
Model: v,
})
return span.eft()
}
// Any adds a key/value attribute to the current Span. The provided
// value may be copied using github.com/mohae/deepcopy if any of the
// base loggers hold the value instead of immediately serializing it.
// While the AnyAttribute has an expectation
// for the type of the value, that type may or may not be checked depending
// on the base logger being used.
// The return value does not need to be used.
func (span *Span) Any(k *xopat.AnyAttribute, v interface{}) *Span {
if span.logger.span.referencesKept {
v = deepcopy.Copy(v)
}
span.base.MetadataAny(k, xopbase.ModelArg{
Model: v,
})
return span.eft()
}
// Bool adds a bool key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Bool(k *xopat.BoolAttribute, v bool) *Span {
span.base.MetadataBool(k, v)
return span.eft()
}
// Enum adds a xopat.Enum key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Enum(k *xopat.EnumAttribute, v xopat.Enum) *Span {
span.base.MetadataEnum(k, v)
return span.eft()
}
// Float64 adds a float64 key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Float64(k *xopat.Float64Attribute, v float64) *Span {
span.base.MetadataFloat64(k, v)
return span.eft()
}
// Link adds a xoptrace.Trace key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Link(k *xopat.LinkAttribute, v xoptrace.Trace) *Span {
span.base.MetadataLink(k, v)
return span.eft()
}
// String adds a string key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) String(k *xopat.StringAttribute, v string) *Span {
span.base.MetadataString(k, v)
return span.eft()
}
// Time adds a time.Time key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Time(k *xopat.TimeAttribute, v time.Time) *Span {
span.base.MetadataTime(k, v)
return span.eft()
}
// should skip Int64
// Duration adds a time.Duration key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Duration(k *xopat.DurationAttribute, v time.Duration) *Span {
span.base.MetadataInt64(&k.Int64Attribute, int64(v))
return span.eft()
}
// Int adds a int key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Int(k *xopat.IntAttribute, v int) *Span {
span.base.MetadataInt64(&k.Int64Attribute, int64(v))
return span.eft()
}
// Int16 adds a int16 key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Int16(k *xopat.Int16Attribute, v int16) *Span {
span.base.MetadataInt64(&k.Int64Attribute, int64(v))
return span.eft()
}
// Int32 adds a int32 key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Int32(k *xopat.Int32Attribute, v int32) *Span {
span.base.MetadataInt64(&k.Int64Attribute, int64(v))
return span.eft()
}
// Int8 adds a int8 key/value attribute to the current Span.
// The return value does not need to be used.
func (span *Span) Int8(k *xopat.Int8Attribute, v int8) *Span {
span.base.MetadataInt64(&k.Int64Attribute, int64(v))
return span.eft()
}