Interface TransactionStore
-
- All Known Implementing Classes:
InMemoryTransactionStore
public interface TransactionStoreTransaction store for managing service transactions.
-
-
Field Summary
Fields Modifier and Type Field Description static StringSPAN_IDstatic StringTRACE_CONTEXT_MAP_KEYstatic StringTRACE_IDstatic StringTRACE_PREV_CONTEXT_MAP_KEYstatic StringTRACE_TRANSACTION_ID
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddProcessorSpan(String containerName, TraceComponent traceComponent, io.opentelemetry.api.trace.SpanBuilder spanBuilder)Add a new processor span under an existing transaction.voidaddTransactionTags(String transactionId, String tagPrefix, Map<String,String> tags)Add custom tags to an existing transaction.default voidendProcessorSpan(String transactionId, String location)End an existing span under an existing transaction.default SpanMetaendProcessorSpan(String transactionId, String location, Consumer<io.opentelemetry.api.trace.Span> spanUpdater)End an existing span under an existing transaction.SpanMetaendProcessorSpan(String transactionId, String location, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)This overloading allows to end a span at given time.default voidendTransaction(String transactionId, String rootFlowName)End a transaction represented by provided transaction id and rootFlowName, if exists.default voidendTransaction(String transactionId, String rootFlowName, Consumer<io.opentelemetry.api.trace.Span> spanUpdater)End a transaction represented by provided transaction id and rootFlowName, if exists.TransactionMetaendTransaction(String transactionId, String rootFlowName, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)End a transaction at given end time.StringgetTraceIdForTransaction(String transactionId)Get the Trace Id associated the transactionTransactionContextgetTransactionContext(String transactionId, org.mule.runtime.api.component.location.ComponentLocation componentLocation)Get theContextof the initiating flow span.voidstartTransaction(TraceComponent traceComponent, String rootFlowName, io.opentelemetry.api.trace.SpanBuilder rootFlowSpan)Start a new transaction.default StringtransactionIdFor(org.mule.runtime.api.event.Event muleEvent)A default implementation to get a mule correlation id as a local transaction id.
-
-
-
Field Detail
-
TRACE_TRANSACTION_ID
static final String TRACE_TRANSACTION_ID
- See Also:
- Constant Field Values
-
TRACE_CONTEXT_MAP_KEY
static final String TRACE_CONTEXT_MAP_KEY
- See Also:
- Constant Field Values
-
TRACE_PREV_CONTEXT_MAP_KEY
static final String TRACE_PREV_CONTEXT_MAP_KEY
- See Also:
- Constant Field Values
-
TRACE_ID
static final String TRACE_ID
- See Also:
- Constant Field Values
-
SPAN_ID
static final String SPAN_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
transactionIdFor
default String transactionIdFor(org.mule.runtime.api.event.Event muleEvent)
A default implementation to get a mule correlation id as a local transaction id.- Parameters:
muleEvent-Event- Returns:
Stringtransaction id
-
startTransaction
void startTransaction(TraceComponent traceComponent, String rootFlowName, io.opentelemetry.api.trace.SpanBuilder rootFlowSpan)
Start a new transaction. This usually happens when a new source flow starts. If the transaction with `transactionId` already exists but for different rootFlowName, then it is possible that new rootFlowSpan is a child flow invocation. In that case, span may be added to an existing transaction as a span.- Parameters:
traceComponent-TraceComponentwith tracing informationrootFlowName- Name of the flow requesting to start transaction.rootFlowSpan-SpanBuilderfor building the root span.
-
addTransactionTags
void addTransactionTags(String transactionId, String tagPrefix, Map<String,String> tags)
Add custom tags to an existing transaction.
-
getTransactionContext
TransactionContext getTransactionContext(String transactionId, org.mule.runtime.api.component.location.ComponentLocation componentLocation)
Get theContextof the initiating flow span. This may be required to propagate context for a given transaction.- Parameters:
transactionId- A unique transaction id within the context of an application. Eg. Correlation id.componentLocation-ComponentLocation- Returns:
Context
-
getTraceIdForTransaction
String getTraceIdForTransaction(String transactionId)
Get the Trace Id associated the transaction- Parameters:
transactionId- A unique transaction id within the context of an application. Eg. Correlation id.- Returns:
- traceId
-
endTransaction
default void endTransaction(String transactionId, String rootFlowName)
End a transaction represented by provided transaction id and rootFlowName, if exists.- Parameters:
transactionId- A unique transaction id within the context of an application. Eg. Correlation id.rootFlowName- Name of the flow requesting to start transaction.
-
endTransaction
default void endTransaction(String transactionId, String rootFlowName, Consumer<io.opentelemetry.api.trace.Span> spanUpdater)
End a transaction represented by provided transaction id and rootFlowName, if exists.Consumerparameter allows updating the Span before ending. This is useful in scenarios like setting processing status code to error.Here is an example of setting Error when processor execution fails.
transactionStore.endTransaction(traceComponent.getTransactionId(), traceComponent.getName(), rootSpan -> { if(notification.getException() != null) { rootSpan.setStatus(StatusCode.ERROR, notification.getException().getMessage()); rootSpan.recordException(notification.getException()); } });- Parameters:
transactionId- A unique transaction id within the context of an application. Eg. Correlation id.rootFlowName- Name of the flow requesting to start transaction.spanUpdater-Consumerto allow updating Span before ending.
-
endTransaction
TransactionMeta endTransaction(String transactionId, String rootFlowName, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)
End a transaction at given end time. SeeendTransaction(String, String, Consumer)
-
addProcessorSpan
void addProcessorSpan(String containerName, TraceComponent traceComponent, io.opentelemetry.api.trace.SpanBuilder spanBuilder)
Add a new processor span under an existing transaction.- Parameters:
containerName-Stringsuch as Flow name that contains requested locationtraceComponent-TraceComponentfor spanspanBuilder-SpanBuilder
-
endProcessorSpan
default void endProcessorSpan(String transactionId, String location)
End an existing span under an existing transaction.
-
endProcessorSpan
default SpanMeta endProcessorSpan(String transactionId, String location, Consumer<io.opentelemetry.api.trace.Span> spanUpdater)
End an existing span under an existing transaction.Consumerparameter allows updating the Span before ending. This is useful in scenarios like setting processing status code to error.Here is an example of setting Error when processor execution fails.
transactionStore.endProcessorSpan(traceComponent.getTransactionId(), traceComponent.getLocation(), s -> { if(notification.getEvent().getError().isPresent()) { Error error = notification.getEvent().getError().get(); s.setStatus(StatusCode.ERROR, error.getDescription()); s.recordException(error.getCause()); } });
-
-