Package com.mendix.tracing
Interface SpanBuilder
public interface SpanBuilder
Represents a builder for span objects.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R> RStart the span, run an action and then close the span.start()Start the span and return a [[com.mendix.tracing.Span]] object, which can be used to close the span.withAttribute(String key, boolean value) Returns this [[com.mendix.tracing.SpanBuilder]] with the added boolean attribute.withAttribute(String key, double value) Returns this [[com.mendix.tracing.SpanBuilder]] with the added double attribute.withAttribute(String key, long value) Returns this [[com.mendix.tracing.SpanBuilder]] with the added long attribute.withAttribute(String key, String value) Returns this [[com.mendix.tracing.SpanBuilder]] with the added String attribute.
-
Method Details
-
withAttribute
Returns this [[com.mendix.tracing.SpanBuilder]] with the added String attribute.- Parameters:
key- The attribute keyvalue- the attribute value- Returns:
- The builder with the added attribute
-
withAttribute
Returns this [[com.mendix.tracing.SpanBuilder]] with the added boolean attribute.- Parameters:
key- The attribute keyvalue- the attribute value- Returns:
- The builder with the added attribute
-
withAttribute
Returns this [[com.mendix.tracing.SpanBuilder]] with the added long attribute.- Parameters:
key- The attribute keyvalue- the attribute value- Returns:
- The builder with the added attribute
-
withAttribute
Returns this [[com.mendix.tracing.SpanBuilder]] with the added double attribute.- Parameters:
key- The attribute keyvalue- the attribute value- Returns:
- The builder with the added attribute
-
start
Span start()Start the span and return a [[com.mendix.tracing.Span]] object, which can be used to close the span. The created span must have its status set and must be closed.It is recommended to use this method in the following way:
var span = spanBuilder.start(); try { ... span.setStatus(Span.Status.OK); } catch (Throwable exc) { span.setError(exc); } finally { span.close(); }- Returns:
- the started span
-
run
Start the span, run an action and then close the span. This method will correctly set the status of the span. If an exception occurs during the execution of the action the status of the span will be set to ERROR, and the exception will be rethrown.- Type Parameters:
R- the type of the return value- Parameters:
action- the action to run- Returns:
- the return value
-