Skip to content

Commit 38c7aa3

Browse files
authored
Convert status to not be a pointer in the Span (#2242)
* Convert status to not be a pointer in the Span Signed-off-by: Bogdan Drutu <[email protected]> * Fix lint errors Signed-off-by: Bogdan Drutu <[email protected]>
1 parent d3387a8 commit 38c7aa3

File tree

24 files changed

+155
-228
lines changed

24 files changed

+155
-228
lines changed

cmd/pdatagen/internal/trace_structs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ var span = &messageValueStruct{
133133
defaultVal: "uint32(0)",
134134
testVal: "uint32(17)",
135135
},
136-
&messagePtrField{
136+
&messageValueField{
137137
fieldName: "Status",
138138
originFieldName: "Status",
139139
returnMessage: spanStatus,
@@ -178,7 +178,7 @@ var spanLink = &messageValueStruct{
178178
},
179179
}
180180

181-
var spanStatus = &messagePtrStruct{
181+
var spanStatus = &messageValueStruct{
182182
structName: "SpanStatus",
183183
description: "// SpanStatus is an optional final status for this span. Semantically when Status wasn't set\n" +
184184
"// it is means span ended without errors and assume Status.Ok (code = 0).",

consumer/pdata/generated_trace.go

Lines changed: 7 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

consumer/pdata/generated_trace_test.go

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

consumer/pdata/trace.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ const (
165165
func (sc StatusCode) String() string { return otlptrace.Status_StatusCode(sc).String() }
166166

167167
// SetCode replaces the code associated with this SpanStatus.
168-
//
169-
// Important: This causes a runtime error if IsNil() returns "true".
170168
func (ms SpanStatus) SetCode(v StatusCode) {
171-
(*ms.orig).Code = otlptrace.Status_StatusCode(v)
169+
ms.orig.Code = otlptrace.Status_StatusCode(v)
172170

173171
// According to OTLP spec we also need to set the deprecated_code field.
174172
// See https://github.com/open-telemetry/opentelemetry-proto/blob/59c488bfb8fb6d0458ad6425758b70259ff4a2bd/opentelemetry/proto/trace/v1/trace.proto#L231

exporter/loggingexporter/logging_exporter.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,9 @@ func (s *loggingExporter) pushTraceData(
339339
buf.logAttr("Kind", span.Kind().String())
340340
buf.logAttr("Start time", span.StartTime().String())
341341
buf.logAttr("End time", span.EndTime().String())
342-
if !span.Status().IsNil() {
343-
buf.logAttr("Status code", span.Status().Code().String())
344-
buf.logAttr("Status message", span.Status().Message())
345-
}
342+
343+
buf.logAttr("Status code", span.Status().Code().String())
344+
buf.logAttr("Status message", span.Status().Message())
346345

347346
buf.logAttributeMap("Attributes", span.Attributes())
348347
buf.logEvents("Events", span.Events())

0 commit comments

Comments
 (0)