Package com.amazonaws.xray.entities
Class EntityImpl
java.lang.Object
com.amazonaws.xray.entities.EntityImpl
- All Implemented Interfaces:
Entity
,AutoCloseable
- Direct Known Subclasses:
FacadeSegment
,SegmentImpl
,SubsegmentImpl
The base class from which
Segment
and Subsegment
extend.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
EntityImpl
(AWSXRayRecorder creator, String name) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addException
(Throwable exception) Adds an exception to the entity's cause and sets fault to true.void
addSubsegment
(Subsegment subsegment) Adds a subsegment.protected void
Checks if the entity has already been emitted to the X-Ray daemon.boolean
compareAndSetEmitted
(boolean current, boolean next) Checks whether thisEntity
currently has emitted state ofcurrent
and if so, set emitted state tonext
.boolean
Decrements the subsegment-reference counter.getAws()
getCause()
double
getHttp()
getId()
getName()
@Nullable String
@Nullable String
abstract Segment
int
Returns the reference count of the segment.getSql()
double
Returns a copy of the currently added subsegments.void
Increments the subsegment-reference counter.boolean
boolean
isError()
boolean
isFault()
boolean
boolean
void
Puts AWS information.void
putAllHttp
(Map<String, Object> all) Puts HTTP information.void
Puts SQL information.void
putAnnotation
(String key, Boolean value) Puts a Boolean annotation.void
putAnnotation
(String key, Number value) Puts a Number annotation.void
putAnnotation
(String key, String value) Puts a String annotation.void
Puts AWS information.void
Puts HTTP information.void
putMetadata
(String key, Object object) Puts metadata under the namespace 'default'.void
putMetadata
(String namespace, String key, Object object) Puts metadata.void
Puts SQL information.void
removeSubsegment
(Subsegment subsegment) Removes a subsegment from the subsegment list.void
setAnnotations
(Map<String, Object> annotations) void
void
setCreator
(AWSXRayRecorder creator) void
setEmitted
(boolean emitted) Sets emitted on the entity.void
setEndTime
(double endTime) void
setError
(boolean error) Sets the error value of the entity.void
setFault
(boolean fault) void
void
void
setInProgress
(boolean inProgress) void
void
setNamespace
(String namespace) void
void
setParentId
(@Nullable String parentId) void
void
setStartTime
(double startTime) void
setSubsegmentsLock
(ReentrantLock subsegmentsLock) void
setThrottle
(boolean throttle) Sets the throttle value.void
setTraceId
(TraceID traceId) static void
validateNotNull
(Object object) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.AutoCloseable
close
-
Field Details
-
mapper
Deprecated.For internal use only. -
referenceCount
-
totalSize
-
-
Constructor Details
-
EntityImpl
protected EntityImpl() -
EntityImpl
-
-
Method Details
-
checkAlreadyEmitted
protected void checkAlreadyEmitted()Checks if the entity has already been emitted to the X-Ray daemon.- Throws:
AlreadyEmittedException
- if the entity has already been emitted to the X-Ray daemon and the ContextMissingStrategy of the AWSXRayRecorder used to create this entity is configured to throw exceptions
-
getName
-
getId
-
setId
-
getStartTime
public double getStartTime()- Specified by:
getStartTime
in interfaceEntity
- Returns:
- the startTime
-
setStartTime
public void setStartTime(double startTime) - Specified by:
setStartTime
in interfaceEntity
- Parameters:
startTime
- the startTime to set
-
getEndTime
public double getEndTime()- Specified by:
getEndTime
in interfaceEntity
- Returns:
- the endTime
-
setEndTime
public void setEndTime(double endTime) - Specified by:
setEndTime
in interfaceEntity
- Parameters:
endTime
- the endTime to set
-
isFault
public boolean isFault() -
setFault
public void setFault(boolean fault) -
isError
public boolean isError() -
setError
public void setError(boolean error) Description copied from interface:Entity
Sets the error value of the entity. -
getNamespace
- Specified by:
getNamespace
in interfaceEntity
- Returns:
- the namespace
-
setNamespace
- Specified by:
setNamespace
in interfaceEntity
- Parameters:
namespace
- the namespace to set
-
getSubsegmentsLock
- Specified by:
getSubsegmentsLock
in interfaceEntity
- Returns:
- the subsegmentsLock
-
setSubsegmentsLock
- Specified by:
setSubsegmentsLock
in interfaceEntity
- Parameters:
subsegmentsLock
- the subsegmentsLock to set
-
getCause
-
getHttp
-
setHttp
-
getAws
-
setAws
-
getSql
-
setSql
-
getMetadata
- Specified by:
getMetadata
in interfaceEntity
- Returns:
- the metadata
-
setMetadata
- Specified by:
setMetadata
in interfaceEntity
- Parameters:
metadata
- the metadata to set
-
getAnnotations
- Specified by:
getAnnotations
in interfaceEntity
- Returns:
- the annotations
-
setAnnotations
- Specified by:
setAnnotations
in interfaceEntity
- Parameters:
annotations
- the annotations to set
-
getParent
-
setParent
-
getCreator
- Specified by:
getCreator
in interfaceEntity
- Returns:
- the creator
-
setCreator
- Specified by:
setCreator
in interfaceEntity
- Parameters:
creator
- the creator to set
-
isThrottle
public boolean isThrottle()- Specified by:
isThrottle
in interfaceEntity
- Returns:
- the throttle
-
setThrottle
public void setThrottle(boolean throttle) Description copied from interface:Entity
Sets the throttle value. When setting to true, error is also set to true and fault set to false.- Specified by:
setThrottle
in interfaceEntity
- Parameters:
throttle
- the throttle to set
-
isInProgress
public boolean isInProgress()- Specified by:
isInProgress
in interfaceEntity
- Returns:
- the inProgress
-
setInProgress
public void setInProgress(boolean inProgress) - Specified by:
setInProgress
in interfaceEntity
- Parameters:
inProgress
- the inProgress to set
-
getTraceId
- Specified by:
getTraceId
in interfaceEntity
- Returns:
- the traceId
-
setTraceId
- Specified by:
setTraceId
in interfaceEntity
- Parameters:
traceId
- the traceId to set
-
getParentId
- Specified by:
getParentId
in interfaceEntity
- Returns:
- the parentId
-
setParentId
- Specified by:
setParentId
in interfaceEntity
- Parameters:
parentId
- the parentId to set
-
getParentSegment
- Specified by:
getParentSegment
in interfaceEntity
-
getSubsegments
- Specified by:
getSubsegments
in interfaceEntity
- Returns:
- the subsegments
-
getSubsegmentsCopy
Description copied from interface:Entity
Returns a copy of the currently added subsegments. Updates to the returnedList
will not be reflected in theEntity
.- Specified by:
getSubsegmentsCopy
in interfaceEntity
-
addSubsegment
Description copied from interface:Entity
Adds a subsegment.- Specified by:
addSubsegment
in interfaceEntity
- Parameters:
subsegment
- the subsegment to add
-
addException
Description copied from interface:Entity
Adds an exception to the entity's cause and sets fault to true.- Specified by:
addException
in interfaceEntity
- Parameters:
exception
- the exception to add
-
putHttp
Description copied from interface:Entity
Puts HTTP information. -
putAllHttp
Description copied from interface:Entity
Puts HTTP information.- Specified by:
putAllHttp
in interfaceEntity
- Parameters:
all
- the HTTP information to put
-
putAws
Description copied from interface:Entity
Puts AWS information. -
putAllAws
Description copied from interface:Entity
Puts AWS information. -
putSql
Description copied from interface:Entity
Puts SQL information. -
putAllSql
Description copied from interface:Entity
Puts SQL information. -
putAnnotation
Description copied from interface:Entity
Puts a String annotation.- Specified by:
putAnnotation
in interfaceEntity
- Parameters:
key
- the key under which the annotation is storedvalue
- the String annotation
-
putAnnotation
Description copied from interface:Entity
Puts a Number annotation.- Specified by:
putAnnotation
in interfaceEntity
- Parameters:
key
- the key under which the annotation is storedvalue
- the Number annotation
-
putAnnotation
Description copied from interface:Entity
Puts a Boolean annotation.- Specified by:
putAnnotation
in interfaceEntity
- Parameters:
key
- the key under which the annotation is storedvalue
- the Boolean annotation
-
putMetadata
Description copied from interface:Entity
Puts metadata under the namespace 'default'.- Specified by:
putMetadata
in interfaceEntity
- Parameters:
key
- the key under which the metadata is storedobject
- the metadata
-
putMetadata
Description copied from interface:Entity
Puts metadata.- Specified by:
putMetadata
in interfaceEntity
- Parameters:
namespace
- the namespace under which the metadata is storedkey
- the key under which the metadata is storedobject
- the metadata
-
incrementReferenceCount
public void incrementReferenceCount()Description copied from interface:Entity
Increments the subsegment-reference counter.- Specified by:
incrementReferenceCount
in interfaceEntity
-
decrementReferenceCount
public boolean decrementReferenceCount()Description copied from interface:Entity
Decrements the subsegment-reference counter.- Specified by:
decrementReferenceCount
in interfaceEntity
- Returns:
- true if the segment is no longer in progress and the reference count is less than or equal to zero.
-
getReferenceCount
public int getReferenceCount()Returns the reference count of the segment. This number represents how many open subsegments are children of this segment. The segment is emitted when its reference count reaches 0.- Specified by:
getReferenceCount
in interfaceEntity
- Returns:
- the reference count
-
getTotalSize
- Specified by:
getTotalSize
in interfaceEntity
- Returns:
- the totalSize
-
isEmitted
public boolean isEmitted() -
setEmitted
public void setEmitted(boolean emitted) Description copied from interface:Entity
Sets emitted on the entity.- Specified by:
setEmitted
in interfaceEntity
- Parameters:
emitted
- the emitted to set
-
compareAndSetEmitted
public boolean compareAndSetEmitted(boolean current, boolean next) Description copied from interface:Entity
Checks whether thisEntity
currently has emitted state ofcurrent
and if so, set emitted state tonext
. Returnstrue
if the state was updated, orfalse
otherwise.- Specified by:
compareAndSetEmitted
in interfaceEntity
-
serialize
-
prettySerialize
- Specified by:
prettySerialize
in interfaceEntity
-
removeSubsegment
Description copied from interface:Entity
Removes a subsegment from the subsegment list. Decrements the total size of the parentSegment. Marks the removed subsegment as emitted future modification on this subsegment may raise an AlreadyEmittedException.- Specified by:
removeSubsegment
in interfaceEntity
- Parameters:
subsegment
- the subsegment to remove
-
validateNotNull
-