From e6c6cf932d5dd111b3f12719896a101b09f06014 Mon Sep 17 00:00:00 2001 From: Igor Baliuk Date: Wed, 6 Dec 2023 16:25:06 +0300 Subject: [PATCH] Set error span status Update the span status if it has the `error` attribute. --- generatorreceiver/internal/generator/trace_generator.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/generatorreceiver/internal/generator/trace_generator.go b/generatorreceiver/internal/generator/trace_generator.go index 7c0f713..8229350 100644 --- a/generatorreceiver/internal/generator/trace_generator.go +++ b/generatorreceiver/internal/generator/trace_generator.go @@ -119,6 +119,14 @@ func (g *TraceGenerator) createSpanForServiceRouteCall(traces *ptrace.Traces, se endTime = Max(endTime, int64(childSpan.EndTimestamp())) } + // For some platforms the `error` attribute is not enough to mark a span as an error. + // They only look at the span status. + _, exists := span.Attributes().Get("error") + if exists { + span.Status().SetCode(ptrace.StatusCodeError) + span.Status().SetMessage("Error") + } + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, startTimeNanos))) span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, endTime))) g.sequenceNumber += 1