Interface SegmentListener

All Known Implementing Classes:
Log4JSegmentListener, MetricsSegmentListener, SLF4JSegmentListener

public interface SegmentListener
An interface to intercept lifecycle events, namely the beginning and ending, of segments produced by the AWSXRayRecorder. Implementations should only contain cheap operations, since they'll be run very frequently.
  • Method Summary

    Modifier and Type Method Description
    default void afterEndSegment​(Segment segment)
    afterEndSegment is invoked after a segment is ended by the recorder and emitted to the daemon.
    default void afterEndSubsegment​(Subsegment subsegment)
    afterEndSubsegment is invoked after a subsegment is ended by the recorder and emitted to the daemon.
    default void beforeEndSegment​(Segment segment)
    beforeEndSegment is invoked just before a segment is ended by the recorder.
    default void beforeEndSubsegment​(Subsegment subsegment)
    beforeEndSubsegment is invoked just before a subsegment is ended by the recorder.
    default void onBeginSegment​(Segment segment)
    onBeginSegment is invoked immediately after a segment is created by the recorder.
    default void onBeginSubsegment​(Subsegment subsegment)
    onBeginSubsegment is invoked immediately after a subsegment is created by the recorder.
    default void onClearEntity​(Entity previousEntity)
    onClearEntity is invoked just before the SegmentContext is cleared.
    default void onSetEntity​(@Nullable Entity previousEntity, Entity newEntity)
    onSetEntity is invoked immediately before the SegmentContext is updated with a new entity.
  • Method Details

    • onBeginSegment

      default void onBeginSegment​(Segment segment)
      onBeginSegment is invoked immediately after a segment is created by the recorder. The segment can be manipulated, e.g. with putAnnotation.
      Parameters:
      segment - The segment that has just begun
    • onBeginSubsegment

      default void onBeginSubsegment​(Subsegment subsegment)
      onBeginSubsegment is invoked immediately after a subsegment is created by the recorder. The subsegment can be manipulated, e.g. with putAnnotation.
      Parameters:
      subsegment - The subsegment that has just begun
    • beforeEndSegment

      default void beforeEndSegment​(Segment segment)
      beforeEndSegment is invoked just before a segment is ended by the recorder. The segment can be manipulated, e.g. with putAnnotation.
      Parameters:
      segment - The segment that has just ended
    • afterEndSegment

      default void afterEndSegment​(Segment segment)
      afterEndSegment is invoked after a segment is ended by the recorder and emitted to the daemon. The segment must not be modified since it has already been sent to X-Ray's backend. Attempts to do so will raise an AlreadyEmittedException.
      Parameters:
      segment - The segment that has just ended
    • beforeEndSubsegment

      default void beforeEndSubsegment​(Subsegment subsegment)
      beforeEndSubsegment is invoked just before a subsegment is ended by the recorder. The subsegment can be manipulated, e.g. with putAnnotation.
      Parameters:
      subsegment - The subsegment that has just ended
    • afterEndSubsegment

      default void afterEndSubsegment​(Subsegment subsegment)
      afterEndSubsegment is invoked after a subsegment is ended by the recorder and emitted to the daemon. The subsegment must not be modified since it has already been sent to X-Ray's backend. Attempts to do so will raise an AlreadyEmittedException.
      Parameters:
      subsegment - The subsegment that has just ended
    • onSetEntity

      default void onSetEntity​(@Nullable Entity previousEntity, Entity newEntity)
      onSetEntity is invoked immediately before the SegmentContext is updated with a new entity. Both the new entity and the previous entity (or null if unset) are passed.
      Parameters:
      previousEntity -
      newEntity -
    • onClearEntity

      default void onClearEntity​(Entity previousEntity)
      onClearEntity is invoked just before the SegmentContext is cleared.
      Parameters:
      previousEntity -