public void endSubsegment()

in aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/AWSXRayRecorder.java [577:599]


    public void endSubsegment(@Nullable 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());
        }
    }