public static boolean sendSegment(Segment segment) { return globalRecorder.sendSegment(segment); }
public static boolean sendSegment(Segment segment) { return globalRecorder.sendSegment(segment); }
/** * Ends a segment. * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment is currently in progress */ public void endSegment() { SegmentContext context = getSegmentContext(); if (null != context) { context.endSegment(this); } Entity current; if ((current = getTraceEntity()) != null) { Segment segment = current.getParentSegment(); logger.debug("Ending segment named '" + segment.getName() + "'."); if(segment.end()) { sendSegment(segment); } else { logger.debug("Not emitting segment named '" + segment.getName() + "' as it parents in-progress subsegments."); } clearTraceEntity(); } else { getContextMissingStrategy().contextMissing("Failed to end segment: segment cannot be found.", SegmentNotFoundException.class); } }
/** * Ends a segment. * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment is currently in progress */ public void endSegment() { SegmentContext context = getSegmentContext(); if (null != context) { context.endSegment(this); } Entity current; if ((current = getTraceEntity()) != null) { Segment segment = current.getParentSegment(); logger.debug("Ending segment named '" + segment.getName() + "'."); if(segment.end()) { sendSegment(segment); } else { logger.debug("Not emitting segment named '" + segment.getName() + "' as it parents in-progress subsegments."); } clearTraceEntity(); } else { getContextMissingStrategy().contextMissing("Failed to end segment: segment cannot be found.", SegmentNotFoundException.class); } }
@Override public void endSubsegment(AWSXRayRecorder recorder) { Entity current = getTraceEntity(); if (current instanceof Subsegment) { if (logger.isDebugEnabled()) { logger.debug("Ending subsegment named: " + current.getName()); } Subsegment currentSubsegment = (Subsegment) current; if (currentSubsegment.end()) { recorder.sendSegment(currentSubsegment.getParentSegment()); } else { if (recorder.getStreamingStrategy().requiresStreaming(currentSubsegment.getParentSegment())) { recorder.getStreamingStrategy().streamSome(currentSubsegment.getParentSegment(), recorder.getEmitter()); } setTraceEntity(current.getParent()); } } else { recorder.getContextMissingStrategy().contextMissing("Failed to end subsegment: subsegment cannot be found.", SubsegmentNotFoundException.class); } } }
@Override public void endSubsegment(AWSXRayRecorder recorder) { Entity current = getTraceEntity(); if (current instanceof Subsegment) { if (logger.isDebugEnabled()) { logger.debug("Ending subsegment named: " + current.getName()); } Subsegment currentSubsegment = (Subsegment) current; if (currentSubsegment.end()) { recorder.sendSegment(currentSubsegment.getParentSegment()); } else { if (recorder.getStreamingStrategy().requiresStreaming(currentSubsegment.getParentSegment())) { recorder.getStreamingStrategy().streamSome(currentSubsegment.getParentSegment(), recorder.getEmitter()); } setTraceEntity(current.getParent()); } } else { recorder.getContextMissingStrategy().contextMissing("Failed to end subsegment: subsegment cannot be found.", SubsegmentNotFoundException.class); } } }
/** * Ends the provided subsegment. This method doesn't touch context storage. * * @param subsegment * the subsegment to close. */ public void endSubsegment(Subsegment subsegment) { if(subsegment == null) { logger.debug("No input subsegment to end. No-op."); return; } boolean rootReady = subsegment.end(); // First handling the special case where its direct parent is a facade segment if(subsegment.getParent() instanceof FacadeSegment) { if(((FacadeSegment) subsegment.getParent()).isSampled()) { getEmitter().sendSubsegment(subsegment); } return; } // Otherwise we check the happy case where the entire segment is ready if (rootReady && !(subsegment.getParentSegment() instanceof FacadeSegment)) { sendSegment(subsegment.getParentSegment()); return; } // If not we try to stream closed subsegments regardless the root segment is facade or real if (this.getStreamingStrategy().requiresStreaming(subsegment.getParentSegment())) { this.getStreamingStrategy().streamSome(subsegment.getParentSegment(), this.getEmitter()); } }
/** * Ends the provided subsegment. This method doesn't touch context storage. * * @param subsegment * the subsegment to close. */ public void endSubsegment(Subsegment subsegment) { if(subsegment == null) { logger.debug("No input subsegment to end. No-op."); return; } boolean rootReady = subsegment.end(); // First handling the special case where its direct parent is a facade segment if(subsegment.getParent() instanceof FacadeSegment) { if(((FacadeSegment) subsegment.getParent()).isSampled()) { getEmitter().sendSubsegment(subsegment); } return; } // Otherwise we check the happy case where the entire segment is ready if (rootReady && !(subsegment.getParentSegment() instanceof FacadeSegment)) { sendSegment(subsegment.getParentSegment()); return; } // If not we try to stream closed subsegments regardless the root segment is facade or real if (this.getStreamingStrategy().requiresStreaming(subsegment.getParentSegment())) { this.getStreamingStrategy().streamSome(subsegment.getParentSegment(), this.getEmitter()); } }