Class ForwardingStorageComponent

java.lang.Object
zipkin2.Component
zipkin2.storage.StorageComponent
zipkin2.storage.ForwardingStorageComponent
All Implemented Interfaces:
Closeable, AutoCloseable

public abstract class ForwardingStorageComponent extends StorageComponent
We provide a forwarding variant of the storage component for use cases such as trace decoration, or throttling.

Extending this is better than extending StorageComponent directly because it reduces risk of accidentally masking new methods. For example, if you extended storage component and later a new feature for cache control was added, that feature would be blocked until the wrapper was re-compiled. Such would be worse in most cases than not having decoration on new methods.

Since:
2.16
  • Constructor Details

    • ForwardingStorageComponent

      protected ForwardingStorageComponent()
      Constructor for use by subclasses.
  • Method Details

    • delegate

      protected abstract StorageComponent delegate()
      The delegate is a method as opposed to a field, to allow for flexibility. For example, this allows you to choose to make a final or lazy field, or no field at all.
    • spanConsumer

      public SpanConsumer spanConsumer()
      Specified by:
      spanConsumer in class StorageComponent
    • traces

      public Traces traces()
      Overrides:
      traces in class StorageComponent
    • spanStore

      public SpanStore spanStore()
      Specified by:
      spanStore in class StorageComponent
    • autocompleteTags

      public AutocompleteTags autocompleteTags()
      Overrides:
      autocompleteTags in class StorageComponent
    • serviceAndSpanNames

      public ServiceAndSpanNames serviceAndSpanNames()
      Overrides:
      serviceAndSpanNames in class StorageComponent
    • check

      public CheckResult check()
      Description copied from class: Component
      Answers the question: Are operations on this component likely to succeed?

      Implementations should initialize the component if necessary. It should test a remote connection, or consult a trusted source to derive the result. They should use least resources possible to establish a meaningful result, and be safe to call many times, even concurrently.

      Overrides:
      check in class Component
      See Also:
    • isOverCapacity

      public boolean isOverCapacity(Throwable e)
      Description copied from class: StorageComponent
      A storage request failed and was dropped due to a limit, resource unavailability, or a timeout. Implementations of throttling can use this signal to differentiate between failures, for example to reduce traffic.

      Callers of this method will submit an exception raised by Call.execute() or on the error callback of Call.enqueue(Callback).

      By default, this returns true if the input is a RejectedExecutionException. When originating exceptions, use this type to indicate a load related failure.

      It is generally preferred to specialize this method to handle relevant exceptions for the particular storage rather than wrapping them in RejectedExecutionException at call sites. Extra wrapping can make errors harder to read, for example, by making it harder to "google" a solution for a well known error message for the storage client, instead thinking the error is in Zipkin code itself.

      See also

      While implementation is flexible, one known use is Netflix concurrency limits

      Overrides:
      isOverCapacity in class StorageComponent
    • close

      public void close() throws IOException
      Description copied from class: Component
      Closes any network resources created implicitly by the component.

      For example, if this created a connection, it would close it. If it was provided one, this would close any sessions, but leave the connection open.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class Component
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object