Package 

Interface TracingApi


  • 
    public interface TracingApi
    
                        

    The public API used to add traces to your application. Note that recordCompletedSpan can be used before the SDK is initialized. The actual trace won't be recorded until the SDK is started, but it's safe to use this prior to SDK initialization.

    • Method Detail

      • createSpan

         abstract EmbraceSpan createSpan(String name, EmbraceSpan parent, AutoTerminationMode autoTerminationMode)

        Create an EmbraceSpan with the given name and parent. Passing in a parent that is null result in a new trace with this EmbraceSpan as its root. Returns null if the EmbraceSpan cannot be created, e.g if the parent has not been started, the name is invalid, or some other factor due to the current conditions of the SDK.

        • Note: the EmbraceSpan created will not be started. For a method that creates and starts the span, use startSpan

      • recordSpan

         <T extends Any> T recordSpan(String name, AutoTerminationMode autoTerminationMode, Function0<T> code)

        Execute the given block of code and record a new trace around it. If the span cannot be created, the block of code will still run and return correctly. If an exception or error is thrown inside the block, the span will end at the point of the throw and the Throwable will be rethrown.

      • recordSpan

         <T extends Any> T recordSpan(String name, EmbraceSpan parent, AutoTerminationMode autoTerminationMode, Function0<T> code)

        Execute the given block of code and record a new span around it with the given parent. Passing in a parent that is null will result in a new trace with the new span as its root. If the span cannot be created, the block of code will still run and return correctly. If an exception or error is thrown inside the block, the span will end at the point of the throw and the Throwable will be rethrown.

      • recordSpan

         <T extends Any> T recordSpan(String name, Map<String, String> attributes, List<EmbraceSpanEvent> events, AutoTerminationMode autoTerminationMode, Function0<T> code)

        Execute the given block of code and record a new trace around it with optional attributes and list of EmbraceSpanEvent. If the span cannot be created, the block of code will still run and return correctly. If an exception or error is thrown inside the block, the span will end at the point of the throw and the Throwable will be rethrown.

      • recordSpan

         abstract <T extends Any> T recordSpan(String name, EmbraceSpan parent, Map<String, String> attributes, List<EmbraceSpanEvent> events, AutoTerminationMode autoTerminationMode, Function0<T> code)

        Execute the given block of code and record a new span around it with the given parent with optional attributes and list of EmbraceSpanEvent. Passing in a parent that is null will result in a new trace with the new span as its root. If the span cannot be created, the block of code will still run and return correctly. If an exception or error is thrown inside the block, the span will end at the point of the throw and the Throwable will be rethrown.

      • recordCompletedSpan

         Boolean recordCompletedSpan(String name, Long startTimeMs, Long endTimeMs)

        Record a span with the given name, start time, and end time (epoch time in milliseconds). The created span will be the root span of a new trace.

      • recordCompletedSpan

         Boolean recordCompletedSpan(String name, Long startTimeMs, Long endTimeMs, ErrorCode errorCode)

        Record a span with the given name, error code, start time, and end time (epoch time in milliseconds). The created span will be the root span of a new trace. A non-null ErrorCode can be passed in to denote the operation the span represents was ended unsuccessfully under the stated circumstances.

      • recordCompletedSpan

         Boolean recordCompletedSpan(String name, Long startTimeMs, Long endTimeMs, EmbraceSpan parent)

        Record a span with the given name, parent, start time, and end time (epoch time in milliseconds). Passing in a parent that is null will result in a new trace with the new span as its root.

      • recordCompletedSpan

         Boolean recordCompletedSpan(String name, Long startTimeMs, Long endTimeMs, ErrorCode errorCode, EmbraceSpan parent)

        Record a span with the given name, parent, error code, start time, and end time (epoch time in milliseconds). Passing in a parent that is null will result in a new trace with the new span as its root. A non-null ErrorCode can be passed in to denote the operation the span represents was ended unsuccessfully under the stated circumstances.

      • recordCompletedSpan

         abstract Boolean recordCompletedSpan(String name, Long startTimeMs, Long endTimeMs, ErrorCode errorCode, EmbraceSpan parent, Map<String, String> attributes, List<EmbraceSpanEvent> events)

        Record a span with the given name, error code, parent, start time, and end time (epoch time in milliseconds). Passing in a parent that is null will result in a new trace with the new span as its root. A non-null ErrorCode can be passed in to denote the operation the span represents was ended unsuccessfully under the stated circumstances. You can also pass in a Map with String keys and values to be used as the attributes of the recorded span, or a List of EmbraceSpanEvent to be used as the events of the recorded span.

      • getSpan

         abstract EmbraceSpan getSpan(String spanId)

        Return the EmbraceSpan corresponding to the given spanId if it is active or it has completed in the current session. Returns null if a span corresponding to the given spanId cannot be found, which can happen if this span never existed or if was completed in a prior session.