Official Content

There is a basic option to set Span status, and the option to fully record the Exception itself to the Span.

The most basic option is to set Span status to Error to indicate that an Exception has occurred.

In the following example, the Tracer Object is used to create the Span.
Then the SetStatus method of Span, which is overloaded, is used. One method receives the Error description and the other only receives the SpanStatusCode.

&span = Tracer.CreateSpan("TestStatusCode procedure")
//Do something
if &Error
    &spanStatusCode = SpanStatusCode.Error
    &span.SetStatus(&spanStatusCode,"There was an error executing the program.")
endif
&span.End()

The previous example showed the most basic reporting of an Exception by leveraging Span status. This approach does not record the Exception itself to do a richer debugging. 
Span.RecordException() allows the exception to be stored in the Span as an Event.

&span = Tracer.CreateSpan("TestStatusCode procedure")

//Do something
if &Error

        &spanStatusCode = SpanStatusCode.Error
        &span.SetStatus(&spanStatusCode,"There was an error!!! This is a program message")
        &span.RecordException("Exception Message")
Endif
&span.End()

This is a view of Grafana showing the span associated with an Exception.

image_202431918449_1_png

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant