/** * Clears the current trace entity value using the implementation provided by the SegmentContext resolved from the segmentContextResolverChain. * */ public void clearTraceEntity() { SegmentContext context = getSegmentContext(); if (null == context) { return; } context.clearTraceEntity(); }
/** * Sets the trace entity value using the implementation provided by the SegmentContext resolved from the segmentContextResolverChain. * * @param entity * the trace entity to set */ public void setTraceEntity(Entity entity) { SegmentContext context = getSegmentContext(); if (null == context) { return; } context.setTraceEntity(entity); }
/** * Gets the current trace entity value using the implementation provided by the SegmentContext resolved from the segmentContextResolverChain. * * @return the current trace entity */ public Entity getTraceEntity() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } return context.getTraceEntity(); }
/** * Gets the current trace entity value using the implementation provided by the SegmentContext resolved from the segmentContextResolverChain. * * @return the current trace entity */ public Entity getTraceEntity() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } return context.getTraceEntity(); }
/** * Clears the current trace entity value using the implementation provided by the SegmentContext resolved from the segmentContextResolverChain. * */ public void clearTraceEntity() { SegmentContext context = getSegmentContext(); if (null == context) { return; } context.clearTraceEntity(); }
/** * Sets the trace entity value using the implementation provided by the SegmentContext resolved from the segmentContextResolverChain. * * @param entity * the trace entity to set */ public void setTraceEntity(Entity entity) { SegmentContext context = getSegmentContext(); if (null == context) { return; } context.setTraceEntity(entity); }
/** * Ends a subsegment. * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment is currently in progress * @throws SubsegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no subsegment is currently in progress */ public void endSubsegment() { SegmentContext context = getSegmentContext(); if (null != context) { segmentContextResolverChain.resolve().endSubsegment(this); } }
/** * Ends a subsegment. * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment is currently in progress * @throws SubsegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no subsegment is currently in progress */ public void endSubsegment() { SegmentContext context = getSegmentContext(); if (null != context) { segmentContextResolverChain.resolve().endSubsegment(this); } }
/** * Begins a subsegment. * * @param name * the name to use for the created subsegment * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment is currently in progress * @return the newly created subsegment, or {@code null} if {@code contextMissingStrategy} suppresses and no segment is currently in progress */ public Subsegment beginSubsegment(String name) { SegmentContext context = getSegmentContext(); if (null != context) { return segmentContextResolverChain.resolve().beginSubsegment(this, name); } return null; }
/** * Begins a subsegment. * * @param name * the name to use for the created subsegment * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment is currently in progress * @return the newly created subsegment, or {@code null} if {@code contextMissingStrategy} suppresses and no segment is currently in progress */ public Subsegment beginSubsegment(String name) { SegmentContext context = getSegmentContext(); if (null != context) { return segmentContextResolverChain.resolve().beginSubsegment(this, name); } return null; }
/** * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and the segment context cannot be found * @throws SubsegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and the current segment has no subsegments in progress * @return the current subsegment, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and the segment context cannot be found or the segment has no subsegments in progress */ public Subsegment getCurrentSubsegment() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null == current) { contextMissingStrategy.contextMissing("No segment in progress.", SegmentNotFoundException.class); } else if (current instanceof Subsegment) { return (Subsegment) current; } else { contextMissingStrategy.contextMissing("No subsegment in progress.", SubsegmentNotFoundException.class); } return null; }
/** * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment or subsegment is currently in progress * @return the ID of the {@code Segment} or {@code Subsegment} currently in progress, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and no segment or subsegment is currently in progress */ public String currentEntityId() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null != current) { return current.getId(); } else { contextMissingStrategy.contextMissing("Failed to get current entity ID: segment or subsegment cannot be found.", SegmentNotFoundException.class); return null; } }
/** * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment or subsegment is currently in progress * @return the ID of the {@code Segment} or {@code Subsegment} currently in progress, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and no segment or subsegment is currently in progress */ public String currentEntityId() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null != current) { return current.getId(); } else { contextMissingStrategy.contextMissing("Failed to get current entity ID: segment or subsegment cannot be found.", SegmentNotFoundException.class); return null; } }
/** * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and the segment context cannot be found * @throws SubsegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and the current segment has no subsegments in progress * @return the current subsegment, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and the segment context cannot be found or the segment has no subsegments in progress */ public Subsegment getCurrentSubsegment() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null == current) { contextMissingStrategy.contextMissing("No segment in progress.", SegmentNotFoundException.class); } else if (current instanceof Subsegment) { return (Subsegment) current; } else { contextMissingStrategy.contextMissing("No subsegment in progress.", SubsegmentNotFoundException.class); } return null; }
/** * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment or subsegment is currently in progress * @return the trace ID of the {@code Segment} currently in progress, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and no segment or subsegment is currently in progress */ public TraceID currentTraceId() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null != current) { return current.getParentSegment().getTraceId(); } else { contextMissingStrategy.contextMissing("Failed to get current trace ID: segment cannot be found.", SegmentNotFoundException.class); return null; } }
/** * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment or subsegment is currently in progress * @return the trace ID of the {@code Segment} currently in progress, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and no segment or subsegment is currently in progress */ public TraceID currentTraceId() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null != current) { return current.getParentSegment().getTraceId(); } else { contextMissingStrategy.contextMissing("Failed to get current trace ID: segment cannot be found.", SegmentNotFoundException.class); return null; } }
/** * 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); } }
private Segment beginSegment(Segment segment) { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current; if ((current = getTraceEntity()) != null) { logger.error("Beginning new segment while another segment exists in the segment context. Overwriting current segment named '" + current.getName() + "' to start new segment named '" + segment.getName() + "'."); } segment.setAws(getAwsRuntimeContext()); if (null != getOrigin()){ segment.setOrigin(getOrigin()); } segment.putAllService(getServiceRuntimeContext()); setTraceEntity(segment); return context.beginSegment(this, segment); }
private Segment beginSegment(Segment segment) { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current; if ((current = getTraceEntity()) != null) { logger.error("Beginning new segment while another segment exists in the segment context. Overwriting current segment named '" + current.getName() + "' to start new segment named '" + segment.getName() + "'."); } segment.setAws(getAwsRuntimeContext()); if (null != getOrigin()){ segment.setOrigin(getOrigin()); } segment.putAllService(getServiceRuntimeContext()); setTraceEntity(segment); return context.beginSegment(this, segment); }