Interface SpanBuilder


public interface SpanBuilder
Represents a builder for span objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    default <R> R
    run(Function<Span,R> action)
    Start the span, run an action and then close the span.
    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.
    Returns this [[com.mendix.tracing.SpanBuilder]] with the added String attribute.
  • Method Details

    • withAttribute

      SpanBuilder withAttribute(String key, String value)
      Returns this [[com.mendix.tracing.SpanBuilder]] with the added String attribute.
      Parameters:
      key - The attribute key
      value - the attribute value
      Returns:
      The builder with the added attribute
    • withAttribute

      SpanBuilder withAttribute(String key, boolean value)
      Returns this [[com.mendix.tracing.SpanBuilder]] with the added boolean attribute.
      Parameters:
      key - The attribute key
      value - the attribute value
      Returns:
      The builder with the added attribute
    • withAttribute

      SpanBuilder withAttribute(String key, long value)
      Returns this [[com.mendix.tracing.SpanBuilder]] with the added long attribute.
      Parameters:
      key - The attribute key
      value - the attribute value
      Returns:
      The builder with the added attribute
    • withAttribute

      SpanBuilder withAttribute(String key, double value)
      Returns this [[com.mendix.tracing.SpanBuilder]] with the added double attribute.
      Parameters:
      key - The attribute key
      value - 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

      default <R> R run(Function<Span,R> action)
      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