Skip to content

Commit

Permalink
Convert status to not be a pointer in the Span (#2242)
Browse files Browse the repository at this point in the history
* Convert status to not be a pointer in the Span

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

* Fix lint errors

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Dec 3, 2020
1 parent d3387a8 commit 38c7aa3
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 228 deletions.
4 changes: 2 additions & 2 deletions cmd/pdatagen/internal/trace_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var span = &messageValueStruct{
defaultVal: "uint32(0)",
testVal: "uint32(17)",
},
&messagePtrField{
&messageValueField{
fieldName: "Status",
originFieldName: "Status",
returnMessage: spanStatus,
Expand Down Expand Up @@ -178,7 +178,7 @@ var spanLink = &messageValueStruct{
},
}

var spanStatus = &messagePtrStruct{
var spanStatus = &messageValueStruct{
structName: "SpanStatus",
description: "// SpanStatus is an optional final status for this span. Semantically when Status wasn't set\n" +
"// it is means span ended without errors and assume Status.Ok (code = 0).",
Expand Down
35 changes: 7 additions & 28 deletions consumer/pdata/generated_trace.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions consumer/pdata/generated_trace_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions consumer/pdata/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ const (
func (sc StatusCode) String() string { return otlptrace.Status_StatusCode(sc).String() }

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

// According to OTLP spec we also need to set the deprecated_code field.
// See https://github.com/open-telemetry/opentelemetry-proto/blob/59c488bfb8fb6d0458ad6425758b70259ff4a2bd/opentelemetry/proto/trace/v1/trace.proto#L231
Expand Down
7 changes: 3 additions & 4 deletions exporter/loggingexporter/logging_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,9 @@ func (s *loggingExporter) pushTraceData(
buf.logAttr("Kind", span.Kind().String())
buf.logAttr("Start time", span.StartTime().String())
buf.logAttr("End time", span.EndTime().String())
if !span.Status().IsNil() {
buf.logAttr("Status code", span.Status().Code().String())
buf.logAttr("Status message", span.Status().Message())
}

buf.logAttr("Status code", span.Status().Code().String())
buf.logAttr("Status message", span.Status().Message())

buf.logAttributeMap("Attributes", span.Attributes())
buf.logEvents("Events", span.Events())
Expand Down
Loading

0 comments on commit 38c7aa3

Please sign in to comment.