Skip to content

Commit

Permalink
exporter/trace: more readable to if else condition (#522)
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <[email protected]>
  • Loading branch information
zchee committed Nov 1, 2022
1 parent 628072d commit 8c6aae1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions exporter/trace/trace_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ func (e *traceExporter) protoFromReadOnlySpan(s sdktrace.ReadOnlySpan) (*tracepb
if s.Parent().SpanID() != s.SpanContext().SpanID() && s.Parent().SpanID().IsValid() {
sp.ParentSpanId = s.Parent().SpanID().String()
}
if s.Status().Code == codes.Ok {
switch s.Status().Code {
case codes.Ok:
sp.Status = &statuspb.Status{Code: int32(codepb.Code_OK)}
} else if s.Status().Code == codes.Unset {
case codes.Unset:
// Don't set status code.
} else if s.Status().Code == codes.Error {
case codes.Error:
sp.Status = &statuspb.Status{Code: int32(codepb.Code_UNKNOWN), Message: s.Status().Description}
} else {
default:
sp.Status = &statuspb.Status{Code: int32(codepb.Code_UNKNOWN)}
}

Expand Down

0 comments on commit 8c6aae1

Please sign in to comment.