Debian Codegraph @

pdata/ptrace/generated_span.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 // Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT.
5 // To regenerate this file run "make genpdata".
6
7 package ptrace
8
9 import (
10 "go.opentelemetry.io/collector/pdata/internal"
11 "go.opentelemetry.io/collector/pdata/pcommon"
12 )
13
14 // Span represents a single operation within a trace.
15 // See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto
16 //
17 // This is a reference type, if passed by value and callee modifies it the
18 // caller will see the modification.
19 //
20 // Must use NewSpan function to create new instances.
21 // Important: zero-initialized instance is not valid for use.
22 type Span struct {
23 orig *internal.Span
24 state *internal.State
25 }
26
27 func newSpan(orig *internal.Span, state *internal.State) Span {
28 return Span{orig: orig, state: state}
29 }
30
31 // NewSpan creates a new empty Span.
32 //
33 // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice,
34 // OR directly access the member if this is embedded in another struct.
35 func NewSpan() Span {
36 return newSpan(internal.NewSpan(), internal.NewState())
37 }
38
39 // MoveTo moves all properties from the current struct overriding the destination and
40 // resetting the current instance to its zero value
41 func (ms Span) MoveTo(dest Span) {
42 ms.state.AssertMutable()
43 dest.state.AssertMutable()
44 // If they point to the same data, they are the same, nothing to do.
45 if ms.orig == dest.orig {
46 return
47 }
48 internal.DeleteSpan(dest.orig, false)
49 *dest.orig, *ms.orig = *ms.orig, *dest.orig
50 }
51
52 // TraceID returns the traceid associated with this Span.
53 func (ms Span) TraceID() pcommon.TraceID {
54 return pcommon.TraceID(ms.orig.TraceId)
55 }
56
57 // SetTraceID replaces the traceid associated with this Span.
58 func (ms Span) SetTraceID(v pcommon.TraceID) {
59 ms.state.AssertMutable()
60 ms.orig.TraceId = internal.TraceID(v)
61 }
62
63 // SpanID returns the spanid associated with this Span.
64 func (ms Span) SpanID() pcommon.SpanID {
65 return pcommon.SpanID(ms.orig.SpanId)
66 }
67
68 // SetSpanID replaces the spanid associated with this Span.
69 func (ms Span) SetSpanID(v pcommon.SpanID) {
70 ms.state.AssertMutable()
71 ms.orig.SpanId = internal.SpanID(v)
72 }
73
74 // TraceState returns the tracestate associated with this Span.
75 func (ms Span) TraceState() pcommon.TraceState {
76 return pcommon.TraceState(internal.NewTraceStateWrapper(&ms.orig.TraceState, ms.state))
77 }
78
79 // ParentSpanID returns the parentspanid associated with this Span.
80 func (ms Span) ParentSpanID() pcommon.SpanID {
81 return pcommon.SpanID(ms.orig.ParentSpanId)
82 }
83
84 // SetParentSpanID replaces the parentspanid associated with this Span.
85 func (ms Span) SetParentSpanID(v pcommon.SpanID) {
86 ms.state.AssertMutable()
87 ms.orig.ParentSpanId = internal.SpanID(v)
88 }
89
90 // Flags returns the flags associated with this Span.
91 func (ms Span) Flags() uint32 {
92 return ms.orig.Flags
93 }
94
95 // SetFlags replaces the flags associated with this Span.
96 func (ms Span) SetFlags(v uint32) {
97 ms.state.AssertMutable()
98 ms.orig.Flags = v
99 }
100
101 // Name returns the name associated with this Span.
102 func (ms Span) Name() string {
103 return ms.orig.Name
104 }
105
106 // SetName replaces the name associated with this Span.
107 func (ms Span) SetName(v string) {
108 ms.state.AssertMutable()
109 ms.orig.Name = v
110 }
111
112 // Kind returns the kind associated with this Span.
113 func (ms Span) Kind() SpanKind {
114 return SpanKind(ms.orig.Kind)
115 }
116
117 // SetKind replaces the kind associated with this Span.
118 func (ms Span) SetKind(v SpanKind) {
119 ms.state.AssertMutable()
120 ms.orig.Kind = internal.SpanKind(v)
121 }
122
123 // StartTimestamp returns the starttimestamp associated with this Span.
124 func (ms Span) StartTimestamp() pcommon.Timestamp {
125 return pcommon.Timestamp(ms.orig.StartTimeUnixNano)
126 }
127
128 // SetStartTimestamp replaces the starttimestamp associated with this Span.
129 func (ms Span) SetStartTimestamp(v pcommon.Timestamp) {
130 ms.state.AssertMutable()
131 ms.orig.StartTimeUnixNano = uint64(v)
132 }
133
134 // EndTimestamp returns the endtimestamp associated with this Span.
135 func (ms Span) EndTimestamp() pcommon.Timestamp {
136 return pcommon.Timestamp(ms.orig.EndTimeUnixNano)
137 }
138
139 // SetEndTimestamp replaces the endtimestamp associated with this Span.
140 func (ms Span) SetEndTimestamp(v pcommon.Timestamp) {
141 ms.state.AssertMutable()
142 ms.orig.EndTimeUnixNano = uint64(v)
143 }
144
145 // Attributes returns the Attributes associated with this Span.
146 func (ms Span) Attributes() pcommon.Map {
147 return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state))
148 }
149
150 // DroppedAttributesCount returns the droppedattributescount associated with this Span.
151 func (ms Span) DroppedAttributesCount() uint32 {
152 return ms.orig.DroppedAttributesCount
153 }
154
155 // SetDroppedAttributesCount replaces the droppedattributescount associated with this Span.
156 func (ms Span) SetDroppedAttributesCount(v uint32) {
157 ms.state.AssertMutable()
158 ms.orig.DroppedAttributesCount = v
159 }
160
161 // Events returns the Events associated with this Span.
162 func (ms Span) Events() SpanEventSlice {
163 return newSpanEventSlice(&ms.orig.Events, ms.state)
164 }
165
166 // DroppedEventsCount returns the droppedeventscount associated with this Span.
167 func (ms Span) DroppedEventsCount() uint32 {
168 return ms.orig.DroppedEventsCount
169 }
170
171 // SetDroppedEventsCount replaces the droppedeventscount associated with this Span.
172 func (ms Span) SetDroppedEventsCount(v uint32) {
173 ms.state.AssertMutable()
174 ms.orig.DroppedEventsCount = v
175 }
176
177 // Links returns the Links associated with this Span.
178 func (ms Span) Links() SpanLinkSlice {
179 return newSpanLinkSlice(&ms.orig.Links, ms.state)
180 }
181
182 // DroppedLinksCount returns the droppedlinkscount associated with this Span.
183 func (ms Span) DroppedLinksCount() uint32 {
184 return ms.orig.DroppedLinksCount
185 }
186
187 // SetDroppedLinksCount replaces the droppedlinkscount associated with this Span.
188 func (ms Span) SetDroppedLinksCount(v uint32) {
189 ms.state.AssertMutable()
190 ms.orig.DroppedLinksCount = v
191 }
192
193 // Status returns the status associated with this Span.
194 func (ms Span) Status() Status {
195 return newStatus(&ms.orig.Status, ms.state)
196 }
197
198 // CopyTo copies all properties from the current struct overriding the destination.
199 func (ms Span) CopyTo(dest Span) {
200 dest.state.AssertMutable()
201 internal.CopySpan(dest.orig, ms.orig)
202 }