Class TracingSnapshotStore

java.lang.Object
org.axonframework.eventsourcing.snapshot.store.tracing.TracingSnapshotStore
All Implemented Interfaces:
DescribableComponent, SnapshotStore

@Internal public final class TracingSnapshotStore extends Object implements SnapshotStore
Delegating SnapshotStore decorator that opens internal tracing spans around the snapshot store / load operations.

Each span carries the snapshot's qualified name as its trailing element ("SnapshotStore.store Booking") and an axoniq.entity.id attribute holding the identifier.

This decorator is registered by EventSourcingTracingConfigurationEnhancer; it is never instantiated directly by applications.

Since:
5.3.0
Author:
Mateusz Nowak
  • Constructor Details

    • TracingSnapshotStore

      public TracingSnapshotStore(SnapshotStore delegate, SpanFactory spanFactory)
      Initializes a tracing SnapshotStore wrapping the given delegate, obtaining spans from the given spanFactory.
      Parameters:
      delegate - the snapshot store to delegate to
      spanFactory - the factory producing the tracing spans
  • Method Details

    • store

      public CompletableFuture<Void> store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot, @Nullable ProcessingContext context)
      Description copied from interface: SnapshotStore
      Persists a snapshot under the given name and identifier. This replaces any previous snapshot(s) with the same name and identifier.

      This method is asynchronous and returns a CompletableFuture that completes when the snapshot has been durably stored.

      Specified by:
      store in interface SnapshotStore
      Parameters:
      qualifiedName - the name of the snapshot to persist, cannot be null
      identifier - the identifier of the snapshot to persist, cannot be null
      snapshot - the snapshot to persist, cannot be null
      context - the ProcessingContext active while storing, used by decorators (e.g. tracing) to correlate the operation with the surrounding unit of work; may be null
      Returns:
      a CompletableFuture that completes when the snapshot has been stored
    • load

      public CompletableFuture<@Nullable Snapshot> load(QualifiedName qualifiedName, Object identifier, @Nullable ProcessingContext context)
      Description copied from interface: SnapshotStore
      Loads the latest snapshot for a given name and identifier.

      The returned snapshot may have an older or newer version relative to what is expected. The caller is responsible for handling version compatibility or ignoring unusable snapshots.

      This method is asynchronous and returns a CompletableFuture that completes with the snapshot if one exists, or null if no snapshot is available.

      Specified by:
      load in interface SnapshotStore
      Parameters:
      qualifiedName - the name of the snapshot, cannot be null
      identifier - the identifier of the snapshot, cannot be null
      context - the ProcessingContext active while loading, used by decorators (e.g. tracing) to correlate the operation with the surrounding unit of work; may be null
      Returns:
      a CompletableFuture containing the snapshot, or containing null if no matching snapshot exists
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.