GoogleCloudPlatform / opentelemetry-operations-java

Apache License 2.0
73 stars 38 forks source link

Error spans are not marked red in Cloud Trace #214

Closed vadeg closed 1 year ago

vadeg commented 1 year ago

I am trying to integrate my application with Cloud Trace to observe application traces. According to this Cloud Trace doc

Traces with error codes are colored red. When you select an error-code trace, the trace remains red in the scatterplot.

When I integrate my application using this tutorial with Cloud Trace via OpenTelemetry and send error spans to Cloud Trace I see that my error spans are marked with a blue do like normal spans:

error-span

As you can see on the picture there are red dots which mean error spans. They come from GCP infrastructure and I don't have information how tracing is implemented there.

The details of the span:

error-span-details

As you can see this span is the error span (Status Code = 2) what according to this line of code in TraceTranslator (which sets status code to 2 when there is an error span) means that the span is indeed the error span.

If I export the same span in Jaeger it marks span as an error span:

jaeger-error-span

That means that from Opentelemetry and exporters PoV span metadata is correct.

My question is how to publish an error span using google exporter to enforce Cloud Trace to show it with a red dot in the scatterplot?

punya commented 1 year ago

Thanks for the error report @vadeg.

This is a bug in the way that the Cloud Trace UI handles integer-valued (as opposed to string-valued) span attributes. The bug is limited to the scatterplot -- you'll notice that the Gantt chart view in the lower half of the screen correctly shows a red "error" icon on the relevant span.

We're working on a fix but I can't give you a timeline for how long it'll take.

As a workaround, you can use the OTel SDK to change the http.status_code attribute to a string "500". Then the Cloud Trace exporter will set /http/status_code to the same value and you should see a red dot in the scatterplot.

punya commented 1 year ago

Hi @vadeg, this should now be fixed - please try again and let us know if the problem persists.

vadeg commented 1 year ago

@punya I've tested it and it works now. Thank you for your quick reply and support!