public class InMemoryTransactionStore extends Object implements TransactionStore
TransactionStore. This implementation uses
in-memory Map to
store transactions and related processor spans. Transactions are kept in
memory until they end.OTEL_FLOW_CONTEXT_ID, OTEL_FLOW_PREV_CONTEXT_ID, SPAN_ID, TRACE_CONTEXT_MAP_KEY, TRACE_ID, TRACE_PREV_CONTEXT_MAP_KEY, TRACE_TRANSACTION_ID| Constructor and Description |
|---|
InMemoryTransactionStore() |
| Modifier and Type | Method and Description |
|---|---|
SpanMeta |
addProcessorSpan(String containerName,
TraceComponent traceComponent,
io.opentelemetry.api.trace.SpanBuilder spanBuilder)
Add a new processor span under an existing transaction.
|
void |
addTransactionTags(String transactionId,
String tagPrefix,
Map<String,String> tags)
Add custom tags to an existing transaction.
|
SpanMeta |
endProcessorSpan(String transactionId,
TraceComponent traceComponent,
Consumer<io.opentelemetry.api.trace.Span> spanUpdater,
Instant endTime)
This overloading allows to end a span at given time.
|
TransactionMeta |
endTransaction(TraceComponent traceComponent,
Consumer<io.opentelemetry.api.trace.Span> spanUpdater)
End a transaction represented by provided transaction id and rootFlowName, if
exists.
|
static TransactionStore |
getInstance() |
String |
getTraceIdForTransaction(String transactionId) |
TransactionContext |
getTransactionContext(String transactionId,
String componentLocation)
Get the
Context of the initiating flow span. |
void |
startTransaction(TraceComponent traceComponent,
String rootFlowName,
io.opentelemetry.api.trace.SpanBuilder rootFlowSpanBuilder)
Start a new transaction.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitendProcessorSpan, transactionIdForpublic static TransactionStore getInstance()
public void startTransaction(TraceComponent traceComponent, String rootFlowName, io.opentelemetry.api.trace.SpanBuilder rootFlowSpanBuilder)
TransactionStorestartTransaction in interface TransactionStoretraceComponent - TraceComponent with tracing informationrootFlowName - Name of the flow requesting to start transaction.rootFlowSpanBuilder - SpanBuilder for building the root span.public void addTransactionTags(String transactionId, String tagPrefix, Map<String,String> tags)
TransactionStoreaddTransactionTags in interface TransactionStoretransactionId - A unique transaction id within the context of an application. Eg.
Correlation id.tagPrefix - Stringtags - Map of String Keys and String Values
containing the tags.public TransactionContext getTransactionContext(String transactionId, String componentLocation)
TransactionStoreContext of the initiating flow span. This may be required to
propagate
context for a given transaction.getTransactionContext in interface TransactionStoretransactionId - A unique transaction id within the context of an application. Eg.
Correlation id.componentLocation - ComponentLocationContextpublic TransactionMeta endTransaction(TraceComponent traceComponent, Consumer<io.opentelemetry.api.trace.Span> spanUpdater)
TransactionStoreConsumer parameter 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());
}
});
endTransaction in interface TransactionStoretraceComponent - StringspanUpdater - Consumer to allow updating transaction span before ending.public SpanMeta addProcessorSpan(String containerName, TraceComponent traceComponent, io.opentelemetry.api.trace.SpanBuilder spanBuilder)
TransactionStoreaddProcessorSpan in interface TransactionStorecontainerName - String such as Flow name that contains requested locationtraceComponent - TraceComponent for spanspanBuilder - SpanBuilderpublic SpanMeta endProcessorSpan(String transactionId, TraceComponent traceComponent, Consumer<io.opentelemetry.api.trace.Span> spanUpdater, Instant endTime)
TransactionStoreendProcessorSpan in interface TransactionStoretransactionId - StringtraceComponent - TraceComponentspanUpdater - Consumer to allow updating Span before ending.endTime - Instant of span endCopyright © 2024 AVIO Consulting. All rights reserved.