/
droppedspan.go
48 lines (42 loc) · 1.23 KB
/
droppedspan.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
package tracer
import (
"sync"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
)
// droppedSpan represents a span which was dropped by the local sampler.
type droppedSpan struct {
traceID uint64
once sync.Once
sctx *droppedSpanContext
}
func (*droppedSpan) SetTag(_ string, _ interface{}) {}
func (*droppedSpan) SetOperationName(_ string) {}
func (*droppedSpan) BaggageItem(_ string) string { return "" }
func (*droppedSpan) SetBaggageItem(_ string, val string) {}
func (*droppedSpan) Finish(_ ...ddtrace.FinishOption) {}
// Context returns the span context of this dropped span. It ensures that distributed
// parts of a trace are also dropped, in order to avoid broken traces, but that they
// do reach the agent for stats computations.
func (d *droppedSpan) Context() ddtrace.SpanContext {
d.once.Do(func() {
sctx := &spanContext{
spanID: d.traceID,
traceID: d.traceID,
trace: &trace{
priority: func(i float64) *float64 {
return &i
}(ext.PriorityUserReject),
},
}
d.sctx = &droppedSpanContext{
droppedSpan: d,
spanContext: sctx,
}
})
return d.sctx
}
type droppedSpanContext struct {
*spanContext
droppedSpan *droppedSpan
}