recordSpan

open fun <T> recordSpan(name: String, code: () -> T): T

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.


open fun <T> recordSpan(name: String, parent: EmbraceSpan?, code: () -> T): T

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.


open fun <T> recordSpan(name: String, attributes: Map<String, String>?, events: List<EmbraceSpanEvent>?, code: () -> T): T

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.


abstract fun <T> recordSpan(name: String, parent: EmbraceSpan?, attributes: Map<String, String>?, events: List<EmbraceSpanEvent>?, code: () -> T): T

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.