Debian Codegraph @

pdata/ptrace/traces.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace"
5
6 // MarkReadOnly marks the Traces as shared so that no further modifications can be done on it.
7 func (ms Traces) MarkReadOnly() {
8 ms.getState().MarkReadOnly()
9 }
10
11 // IsReadOnly returns true if this Traces instance is read-only.
12 func (ms Traces) IsReadOnly() bool {
13 return ms.getState().IsReadOnly()
14 }
15
16 // SpanCount calculates the total number of spans.
17 func (ms Traces) SpanCount() int {
18 spanCount := 0
19 rss := ms.ResourceSpans()
20 for i := 0; i < rss.Len(); i++ {
21 rs := rss.At(i)
22 ilss := rs.ScopeSpans()
23 for j := 0; j < ilss.Len(); j++ {
24 spanCount += ilss.At(j).Spans().Len()
25 }
26 }
27 return spanCount
28 }