Class InMemoryTransactionStore
- java.lang.Object
-
- com.avioconsulting.mule.opentelemetry.internal.store.InMemoryTransactionStore
-
- All Implemented Interfaces:
TransactionStore
public class InMemoryTransactionStore extends Object implements TransactionStore
In-memoryTransactionStore. This implementation uses in-memoryMapto store transactions and related processor spans. Transactions are kept in memory until they end.
-
-
Field Summary
-
Fields inherited from interface com.avioconsulting.mule.opentelemetry.api.store.TransactionStore
SPAN_ID, TRACE_CONTEXT_MAP_KEY, TRACE_ID, TRACE_PREV_CONTEXT_MAP_KEY, TRACE_TRANSACTION_ID
-
-
Constructor Summary
Constructors Constructor Description InMemoryTransactionStore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete 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.SpanMetaendProcessorSpan(String transactionId, String location, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)This overloading allows to end a span at given time.TransactionMetaendTransaction(String transactionId, String flowName, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)End a transaction at given end time.static TransactionStoregetInstance()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 rootFlowSpanBuilder)Start a new transaction.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.avioconsulting.mule.opentelemetry.api.store.TransactionStore
endProcessorSpan, endProcessorSpan, endTransaction, endTransaction, transactionIdFor
-
-
-
-
Method Detail
-
getInstance
public static TransactionStore getInstance()
-
startTransaction
public void startTransaction(TraceComponent traceComponent, String rootFlowName, io.opentelemetry.api.trace.SpanBuilder rootFlowSpanBuilder)
Description copied from interface:TransactionStoreStart 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.- Specified by:
startTransactionin interfaceTransactionStore- Parameters:
traceComponent-TraceComponentwith tracing informationrootFlowName- Name of the flow requesting to start transaction.rootFlowSpanBuilder-SpanBuilderfor building the root span.
-
addTransactionTags
public void addTransactionTags(String transactionId, String tagPrefix, Map<String,String> tags)
Description copied from interface:TransactionStoreAdd custom tags to an existing transaction.- Specified by:
addTransactionTagsin interfaceTransactionStore- Parameters:
transactionId- A unique transaction id within the context of an application. Eg. Correlation id.tagPrefix- Stringtags-MapofStringKeys andStringValues containing the tags.
-
getTransactionContext
public TransactionContext getTransactionContext(String transactionId, org.mule.runtime.api.component.location.ComponentLocation componentLocation)
Description copied from interface:TransactionStoreGet theContextof the initiating flow span. This may be required to propagate context for a given transaction.- Specified by:
getTransactionContextin interfaceTransactionStore- Parameters:
transactionId- A unique transaction id within the context of an application. Eg. Correlation id.componentLocation-ComponentLocation- Returns:
Context
-
getTraceIdForTransaction
public String getTraceIdForTransaction(String transactionId)
Description copied from interface:TransactionStoreGet the Trace Id associated the transaction- Specified by:
getTraceIdForTransactionin interfaceTransactionStore- Parameters:
transactionId- A unique transaction id within the context of an application. Eg. Correlation id.- Returns:
- traceId
-
endTransaction
public TransactionMeta endTransaction(String transactionId, String flowName, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)
Description copied from interface:TransactionStoreEnd a transaction at given end time. SeeTransactionStore.endTransaction(String, String, Consumer)- Specified by:
endTransactionin interfaceTransactionStore- Parameters:
transactionId-StringflowName-Stringassociated with transactionspanUpdater-Consumerto allow updating transaction span before ending.endTime-Instant
-
addProcessorSpan
public void addProcessorSpan(String containerName, TraceComponent traceComponent, io.opentelemetry.api.trace.SpanBuilder spanBuilder)
Description copied from interface:TransactionStoreAdd a new processor span under an existing transaction.- Specified by:
addProcessorSpanin interfaceTransactionStore- Parameters:
containerName-Stringsuch as Flow name that contains requested locationtraceComponent-TraceComponentfor spanspanBuilder-SpanBuilder
-
endProcessorSpan
public SpanMeta endProcessorSpan(String transactionId, String location, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)
Description copied from interface:TransactionStoreThis overloading allows to end a span at given time. SeeTransactionStore.endProcessorSpan(String, String, Consumer).- Specified by:
endProcessorSpanin interfaceTransactionStore- Parameters:
transactionId-Stringlocation-Stringof the spanspanUpdater-Consumerto allow updating Span before ending.endTime-Instantof span end- Returns:
- SpanMeta
-
-