-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace_data.go
More file actions
45 lines (37 loc) · 882 Bytes
/
trace_data.go
File metadata and controls
45 lines (37 loc) · 882 Bytes
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
// Copyright 2024 tailsampling-go contributors
// Adapted from OpenTelemetry Collector Contrib
// Licensed under the Apache License, Version 2.0
package tailsampling
import (
"container/list"
"go.opentelemetry.io/otel/sdk/trace"
)
const MaxSpansPerTrace = 100
type traceData struct {
spans []trace.ReadOnlySpan
spanCount int
queueElement *list.Element
}
func (td *traceData) addSpan(span trace.ReadOnlySpan) bool {
if td.spanCount >= MaxSpansPerTrace {
return false
}
td.spans = append(td.spans, span)
td.spanCount++
return true
}
func (td *traceData) getTraceData() *TraceData {
return &TraceData{
ReceivedBatches: td.spans,
SpanCount: td.spanCount,
}
}
func (td *traceData) hasRootSpan() bool {
for _, span := range td.spans {
parent := span.Parent()
if !parent.IsValid() || parent.IsRemote() {
return true
}
}
return false
}