Package com.amazonaws.xray.emitters
Class DelegatingEmitter
java.lang.Object
com.amazonaws.xray.emitters.Emitter
com.amazonaws.xray.emitters.DelegatingEmitter
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;
}
}
-
Field Summary
Fields inherited from class com.amazonaws.xray.emitters.Emitter
DAEMON_BUF_RECEIVE_SIZE, PRIORITY_PROTOCOL_HEADER, PROTOCOL_DELIMITER, PROTOCOL_HEADER
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DelegatingEmitter
(Emitter delegate) Constructs a newDelegatingEmitter
that delegates all calls to the providedEmitter
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
sendSegment
(Segment segment) Sends a segment to the X-Ray daemon.boolean
sendSubsegment
(Subsegment subsegment) Sends a subsegment to the X-Ray daemon.
-
Constructor Details
-
DelegatingEmitter
Constructs a newDelegatingEmitter
that delegates all calls to the providedEmitter
.
-
-
Method Details
-
sendSegment
Description copied from class:Emitter
Sends a segment to the X-Ray daemon.- Specified by:
sendSegment
in classEmitter
- Parameters:
segment
- the segment to send- Returns:
- true if the send operation was successful
-
sendSubsegment
Description copied from class:Emitter
Sends a subsegment to the X-Ray daemon.- Specified by:
sendSubsegment
in classEmitter
- Parameters:
subsegment
- the subsegment to send- Returns:
- true if the send operation was successful
-