Class DelegatingEmitter

java.lang.Object
com.amazonaws.xray.emitters.Emitter
com.amazonaws.xray.emitters.DelegatingEmitter

public class DelegatingEmitter
extends Emitter
An Emitter which delegates all calls to another Emitter. Extend from this class to customize when segments and subsegments are sent.

 class CircuitBreakingEmitter extends DelegatingEmitter {

     private final CircuitBreaker circuitBreaker;

     CircuitBreakingEmitter() {
         super(Emitter.create());
         circuitBreaker = CircuitBreaker.create();
     }

     {@literal @}Override
     public boolean sendSegment(Segment segment) {
         if (circuitBreaker.isOpen()) {
             return super.sendSegment(segment);
         }
         return false;
     }
 }
 
  • Constructor Details

  • Method Details

    • sendSegment

      public boolean sendSegment​(Segment segment)
      Description copied from class: Emitter
      Sends a segment to the X-Ray daemon.
      Specified by:
      sendSegment in class Emitter
      Parameters:
      segment - the segment to send
      Returns:
      true if the send operation was successful
    • sendSubsegment

      public boolean sendSubsegment​(Subsegment subsegment)
      Description copied from class: Emitter
      Sends a subsegment to the X-Ray daemon.
      Specified by:
      sendSubsegment in class Emitter
      Parameters:
      subsegment - the subsegment to send
      Returns:
      true if the send operation was successful