Class DefaultThrowableSerializationStrategy

java.lang.Object
com.amazonaws.xray.strategy.DefaultThrowableSerializationStrategy
All Implemented Interfaces:
ThrowableSerializationStrategy

public class DefaultThrowableSerializationStrategy
extends java.lang.Object
implements ThrowableSerializationStrategy
Default implementation of ThrowableSerializationStrategy. This class auto-registers the AmazonServiceException class as a remote exception class if no set of remote exception classes is provided in the constructor.
  • Constructor Summary

    Constructors
    Constructor Description
    DefaultThrowableSerializationStrategy()  
    DefaultThrowableSerializationStrategy​(int maxStackTraceLength)
    Constructs a new instance of DefaultThrowableSerializationStrategy, overriding the max stack trace length default value of 50.
    DefaultThrowableSerializationStrategy​(int maxStackTraceLength, java.util.Set<java.lang.Class<? extends java.lang.Throwable>> remoteExceptionClasses)
    Constructs a new instance of DefaultThrowableSerializationStrategy, overriding the max stack trace length default value of 50, and overriding the Throwable classes considered 'remote'.
  • Method Summary

    Modifier and Type Method Description
    java.util.List<ThrowableDescription> describeInContext​(@Nullable Entity entity, java.lang.Throwable throwable, java.util.List<Subsegment> subsegments)
    Serializes a Throwable into a ThrowableDescription.
    java.util.List<ThrowableDescription> describeInContext​(java.lang.Throwable throwable, java.util.List<Subsegment> subsegments)
    Serializes a Throwable into a ThrowableDescription.
    int getMaxStackTraceLength()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultThrowableSerializationStrategy

      public DefaultThrowableSerializationStrategy()
    • DefaultThrowableSerializationStrategy

      public DefaultThrowableSerializationStrategy​(int maxStackTraceLength)
      Constructs a new instance of DefaultThrowableSerializationStrategy, overriding the max stack trace length default value of 50. Use this constructor to include more or less stack trace information in (sub)segments.
      Parameters:
      maxStackTraceLength - the maximum number of stack trace elements to include in a single (sub)segment.
    • DefaultThrowableSerializationStrategy

      public DefaultThrowableSerializationStrategy​(int maxStackTraceLength, java.util.Set<java.lang.Class<? extends java.lang.Throwable>> remoteExceptionClasses)
      Constructs a new instance of DefaultThrowableSerializationStrategy, overriding the max stack trace length default value of 50, and overriding the Throwable classes considered 'remote'. Use this constructor to include more or less stack trace information in (sub)segments.
      Parameters:
      maxStackTraceLength - the maximum number of stack trace elements to include in a single (sub)segment.
      remoteExceptionClasses - the superclasses which extend Throwable for which exceptions should be considered remote.
  • Method Details

    • describeInContext

      public java.util.List<ThrowableDescription> describeInContext​(java.lang.Throwable throwable, java.util.List<Subsegment> subsegments)
      Description copied from interface: ThrowableSerializationStrategy
      Serializes a Throwable into a ThrowableDescription. Uses the provided subsegments to chain exceptions where possible.
      Specified by:
      describeInContext in interface ThrowableSerializationStrategy
      Parameters:
      throwable - the Throwable to serialize
      subsegments - the list of subsegment children in which to look for the same Throwable object, for chaining
      Returns:
      a list of ThrowableDescriptions which represent the provided Throwable
    • describeInContext

      public java.util.List<ThrowableDescription> describeInContext​(@Nullable Entity entity, java.lang.Throwable throwable, java.util.List<Subsegment> subsegments)
      Description copied from interface: ThrowableSerializationStrategy
      Serializes a Throwable into a ThrowableDescription. Uses the provided subsegments to chain exceptions where possible.
      Specified by:
      describeInContext in interface ThrowableSerializationStrategy
      Parameters:
      entity - the current entity. May be null.
      throwable - the Throwable to serialize
      subsegments - the list of subsegment children in which to look for the same Throwable object, for chaining
      Returns:
      a list of ThrowableDescriptions which represent the provided Throwable
    • getMaxStackTraceLength

      public int getMaxStackTraceLength()
      Returns:
      the maxStackTraceLength