Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Dec 2, 2020
1 parent 73712aa commit 268e576
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 21 deletions.
2 changes: 1 addition & 1 deletion consumer/pdata/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (sc StatusCode) String() string { return otlptrace.Status_StatusCode(sc).St
//
// 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
1 change: 0 additions & 1 deletion internal/testdata/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ func fillSpanOne(span pdata.Span) {
ev1.SetDroppedAttributesCount(2)
span.SetDroppedEventsCount(1)
status := span.Status()
status.InitEmpty()
status.SetCode(pdata.StatusCodeError)
status.SetMessage("status-cancelled")
}
Expand Down
2 changes: 0 additions & 2 deletions receiver/jaegerreceiver/trace_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ func expectedTraceData(t1, t2, t3 time.Time) pdata.Traces {
span0.SetName("DBSearch")
span0.SetStartTime(pdata.TimestampUnixNano(uint64(t1.UnixNano())))
span0.SetEndTime(pdata.TimestampUnixNano(uint64(t2.UnixNano())))
span0.Status().InitEmpty()
span0.Status().SetCode(pdata.StatusCodeError)
span0.Status().SetMessage("Stale indices")

Expand All @@ -321,7 +320,6 @@ func expectedTraceData(t1, t2, t3 time.Time) pdata.Traces {
span1.SetName("ProxyFetch")
span1.SetStartTime(pdata.TimestampUnixNano(uint64(t2.UnixNano())))
span1.SetEndTime(pdata.TimestampUnixNano(uint64(t3.UnixNano())))
span1.Status().InitEmpty()
span1.Status().SetCode(pdata.StatusCodeError)
span1.Status().SetMessage("Frontend crash")

Expand Down
8 changes: 1 addition & 7 deletions translator/internaldata/oc_to_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,13 @@ func ocStatusToInternal(ocStatus *octrace.Status, ocAttrs *octrace.Span_Attribut
if ocStatus == nil {
return
}
dest.InitEmpty()

var code pdata.StatusCode
switch ocStatus.Code {
case trace.StatusCodeOK:
code = pdata.StatusCodeUnset

case trace.StatusCodeUnknown:
// It is an error.
fallthrough

default:
// all other OC status codes are also errors.
// all other OC status codes are errors.
code = pdata.StatusCodeError
}

Expand Down
1 change: 0 additions & 1 deletion translator/trace/jaeger/jaegerproto_to_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ func setInternalSpanStatus(attrs pdata.AttributeMap, dest pdata.SpanStatus) {
}

if statusExists {
dest.InitEmpty()
dest.SetCode(statusCode)
dest.SetMessage(statusMessage)
}
Expand Down
10 changes: 2 additions & 8 deletions translator/trace/jaeger/jaegerproto_to_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,23 +325,19 @@ func TestProtoBatchToInternalTracesWithTwoLibraries(t *testing.T) {

func TestSetInternalSpanStatus(t *testing.T) {

nilStatus := pdata.NewSpanStatus()
emptyStatus := pdata.NewSpanStatus()

okStatus := pdata.NewSpanStatus()
okStatus.InitEmpty()
okStatus.SetCode(pdata.StatusCodeOk)

errorStatus := pdata.NewSpanStatus()
errorStatus.InitEmpty()
errorStatus.SetCode(pdata.StatusCodeError)

errorStatusWithMessage := pdata.NewSpanStatus()
errorStatusWithMessage.InitEmpty()
errorStatusWithMessage.SetCode(pdata.StatusCodeError)
errorStatusWithMessage.SetMessage("Error: Invalid argument")

errorStatusWith404Message := pdata.NewSpanStatus()
errorStatusWith404Message.InitEmpty()
errorStatusWith404Message.SetCode(pdata.StatusCodeError)
errorStatusWith404Message.SetMessage("HTTP 404: Not Found")

Expand All @@ -354,7 +350,7 @@ func TestSetInternalSpanStatus(t *testing.T) {
{
name: "No tags set -> OK status",
attrs: pdata.NewAttributeMap().InitFromMap(map[string]pdata.AttributeValue{}),
status: nilStatus,
status: emptyStatus,
attrsModifiedLen: 0,
},
{
Expand Down Expand Up @@ -723,7 +719,6 @@ func generateTraceDataTwoSpansChildParent() pdata.Traces {
span.SetTraceID(spans.At(0).TraceID())
span.SetStartTime(spans.At(0).StartTime())
span.SetEndTime(spans.At(0).EndTime())
span.Status().InitEmpty()
span.Status().SetCode(pdata.StatusCodeError)
span.Attributes().InitFromMap(map[string]pdata.AttributeValue{
tracetranslator.TagHTTPStatusCode: pdata.NewAttributeValueInt(404),
Expand Down Expand Up @@ -777,7 +772,6 @@ func generateTraceDataTwoSpansWithFollower() pdata.Traces {
span.SetStartTime(spans.At(0).EndTime())
span.SetEndTime(spans.At(0).EndTime() + 1000000)
span.SetKind(pdata.SpanKindCONSUMER)
span.Status().InitEmpty()
span.Status().SetCode(pdata.StatusCodeOk)
span.Status().SetMessage("status-ok")
span.Links().Resize(1)
Expand Down
1 change: 0 additions & 1 deletion translator/trace/zipkin/zipkinv2_to_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func zSpanToInternal(zspan *zipkinmodel.SpanModel, tags map[string]string, dest

func populateSpanStatus(tags map[string]string, status pdata.SpanStatus) {
if value, ok := tags[tracetranslator.TagStatusCode]; ok {
status.InitEmpty()
status.SetCode(pdata.StatusCode(otlptrace.Status_StatusCode_value[value]))
delete(tags, tracetranslator.TagStatusCode)
if value, ok := tags[tracetranslator.TagStatusMsg]; ok {
Expand Down

0 comments on commit 268e576

Please sign in to comment.