Package com.amazonaws.xray.entities
Class EntityImpl
- java.lang.Object
-
- com.amazonaws.xray.entities.EntityImpl
-
- All Implemented Interfaces:
Entity,java.lang.AutoCloseable
- Direct Known Subclasses:
FacadeSegment,SegmentImpl,SubsegmentImpl
public abstract class EntityImpl extends java.lang.Object implements Entity
The base class from whichSegmentandSubsegmentextend.
-
-
Field Summary
Fields Modifier and Type Field Description protected static com.fasterxml.jackson.databind.ObjectMappermapperDeprecated.For internal use only.protected java.util.concurrent.atomic.LongAdderreferenceCountprotected java.util.concurrent.atomic.LongAddertotalSize
-
Constructor Summary
Constructors Modifier Constructor Description protectedEntityImpl()protectedEntityImpl(AWSXRayRecorder creator, java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddException(java.lang.Throwable exception)Adds an exception to the entity's cause and sets fault to true.voidaddSubsegment(Subsegment subsegment)Adds a subsegment.protected voidcheckAlreadyEmitted()Checks if the entity has already been emitted to the X-Ray daemon.booleancompareAndSetEmitted(boolean current, boolean next)Checks whether thisEntitycurrently has emitted state ofcurrentand if so, set emitted state tonext.booleandecrementReferenceCount()Decrements the subsegment-reference counter.java.util.Map<java.lang.String,java.lang.Object>getAnnotations()java.util.Map<java.lang.String,java.lang.Object>getAws()CausegetCause()AWSXRayRecordergetCreator()doublegetEndTime()java.util.Map<java.lang.String,java.lang.Object>getHttp()java.lang.StringgetId()java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>getMetadata()java.lang.StringgetName()@Nullable java.lang.StringgetNamespace()EntitygetParent()@Nullable java.lang.StringgetParentId()abstract SegmentgetParentSegment()intgetReferenceCount()Returns the reference count of the segment.java.util.Map<java.lang.String,java.lang.Object>getSql()doublegetStartTime()java.util.List<Subsegment>getSubsegments()java.util.List<Subsegment>getSubsegmentsCopy()Returns a copy of the currently added subsegments.java.util.concurrent.locks.ReentrantLockgetSubsegmentsLock()java.util.concurrent.atomic.LongAddergetTotalSize()TraceIDgetTraceId()voidincrementReferenceCount()Increments the subsegment-reference counter.booleanisEmitted()booleanisError()booleanisFault()booleanisInProgress()booleanisThrottle()java.lang.StringprettySerialize()voidputAllAws(java.util.Map<java.lang.String,java.lang.Object> all)Puts AWS information.voidputAllHttp(java.util.Map<java.lang.String,java.lang.Object> all)Puts HTTP information.voidputAllSql(java.util.Map<java.lang.String,java.lang.Object> all)Puts SQL information.voidputAnnotation(java.lang.String key, java.lang.Boolean value)Puts a Boolean annotation.voidputAnnotation(java.lang.String key, java.lang.Number value)Puts a Number annotation.voidputAnnotation(java.lang.String key, java.lang.String value)Puts a String annotation.voidputAws(java.lang.String key, java.lang.Object value)Puts AWS information.voidputHttp(java.lang.String key, java.lang.Object value)Puts HTTP information.voidputMetadata(java.lang.String key, java.lang.Object object)Puts metadata under the namespace 'default'.voidputMetadata(java.lang.String namespace, java.lang.String key, java.lang.Object object)Puts metadata.voidputSql(java.lang.String key, java.lang.Object value)Puts SQL information.voidremoveSubsegment(Subsegment subsegment)Removes a subsegment from the subsegment list.java.lang.Stringserialize()voidsetAnnotations(java.util.Map<java.lang.String,java.lang.Object> annotations)voidsetAws(java.util.Map<java.lang.String,java.lang.Object> aws)voidsetCreator(AWSXRayRecorder creator)voidsetEmitted(boolean emitted)Sets emitted on the entity.voidsetEndTime(double endTime)voidsetError(boolean error)Sets the error value of the entity.voidsetFault(boolean fault)voidsetHttp(java.util.Map<java.lang.String,java.lang.Object> http)voidsetId(java.lang.String id)voidsetInProgress(boolean inProgress)voidsetMetadata(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> metadata)voidsetNamespace(java.lang.String namespace)voidsetParent(Entity parent)voidsetParentId(@Nullable java.lang.String parentId)voidsetSql(java.util.Map<java.lang.String,java.lang.Object> sql)voidsetStartTime(double startTime)voidsetSubsegmentsLock(java.util.concurrent.locks.ReentrantLock subsegmentsLock)voidsetThrottle(boolean throttle)Sets the throttle value.voidsetTraceId(TraceID traceId)static voidvalidateNotNull(java.lang.Object object)
-
-
-
Constructor Detail
-
EntityImpl
protected EntityImpl()
-
EntityImpl
protected EntityImpl(AWSXRayRecorder creator, java.lang.String name)
-
-
Method Detail
-
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
-
setId
public void setId(java.lang.String id)
-
getStartTime
public double getStartTime()
- Specified by:
getStartTimein interfaceEntity- Returns:
- the startTime
-
setStartTime
public void setStartTime(double startTime)
- Specified by:
setStartTimein interfaceEntity- Parameters:
startTime- the startTime to set
-
getEndTime
public double getEndTime()
- Specified by:
getEndTimein interfaceEntity- Returns:
- the endTime
-
setEndTime
public void setEndTime(double endTime)
- Specified by:
setEndTimein interfaceEntity- Parameters:
endTime- the endTime to set
-
setFault
public void setFault(boolean fault)
-
setError
public void setError(boolean error)
Description copied from interface:EntitySets the error value of the entity.
-
getNamespace
public @Nullable java.lang.String getNamespace()
- Specified by:
getNamespacein interfaceEntity- Returns:
- the namespace
-
setNamespace
public void setNamespace(java.lang.String namespace)
- Specified by:
setNamespacein interfaceEntity- Parameters:
namespace- the namespace to set
-
getSubsegmentsLock
public java.util.concurrent.locks.ReentrantLock getSubsegmentsLock()
- Specified by:
getSubsegmentsLockin interfaceEntity- Returns:
- the subsegmentsLock
-
setSubsegmentsLock
public void setSubsegmentsLock(java.util.concurrent.locks.ReentrantLock subsegmentsLock)
- Specified by:
setSubsegmentsLockin interfaceEntity- Parameters:
subsegmentsLock- the subsegmentsLock to set
-
getHttp
public java.util.Map<java.lang.String,java.lang.Object> getHttp()
-
setHttp
public void setHttp(java.util.Map<java.lang.String,java.lang.Object> http)
-
getAws
public java.util.Map<java.lang.String,java.lang.Object> getAws()
-
setAws
public void setAws(java.util.Map<java.lang.String,java.lang.Object> aws)
-
getSql
public java.util.Map<java.lang.String,java.lang.Object> getSql()
-
setSql
public void setSql(java.util.Map<java.lang.String,java.lang.Object> sql)
-
getMetadata
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> getMetadata()
- Specified by:
getMetadatain interfaceEntity- Returns:
- the metadata
-
setMetadata
public void setMetadata(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> metadata)
- Specified by:
setMetadatain interfaceEntity- Parameters:
metadata- the metadata to set
-
getAnnotations
public java.util.Map<java.lang.String,java.lang.Object> getAnnotations()
- Specified by:
getAnnotationsin interfaceEntity- Returns:
- the annotations
-
setAnnotations
public void setAnnotations(java.util.Map<java.lang.String,java.lang.Object> annotations)
- Specified by:
setAnnotationsin interfaceEntity- Parameters:
annotations- the annotations to set
-
setParent
public void setParent(Entity parent)
-
getCreator
public AWSXRayRecorder getCreator()
- Specified by:
getCreatorin interfaceEntity- Returns:
- the creator
-
setCreator
public void setCreator(AWSXRayRecorder creator)
- Specified by:
setCreatorin interfaceEntity- Parameters:
creator- the creator to set
-
isThrottle
public boolean isThrottle()
- Specified by:
isThrottlein interfaceEntity- Returns:
- the throttle
-
setThrottle
public void setThrottle(boolean throttle)
Description copied from interface:EntitySets the throttle value. When setting to true, error is also set to true and fault set to false.- Specified by:
setThrottlein interfaceEntity- Parameters:
throttle- the throttle to set
-
isInProgress
public boolean isInProgress()
- Specified by:
isInProgressin interfaceEntity- Returns:
- the inProgress
-
setInProgress
public void setInProgress(boolean inProgress)
- Specified by:
setInProgressin interfaceEntity- Parameters:
inProgress- the inProgress to set
-
getTraceId
public TraceID getTraceId()
- Specified by:
getTraceIdin interfaceEntity- Returns:
- the traceId
-
setTraceId
@EnsuresNonNull("this.traceId") public void setTraceId(TraceID traceId)- Specified by:
setTraceIdin interfaceEntity- Parameters:
traceId- the traceId to set
-
getParentId
public @Nullable java.lang.String getParentId()
- Specified by:
getParentIdin interfaceEntity- Returns:
- the parentId
-
setParentId
public void setParentId(@Nullable java.lang.String parentId)
- Specified by:
setParentIdin interfaceEntity- Parameters:
parentId- the parentId to set
-
getParentSegment
public abstract Segment getParentSegment()
- Specified by:
getParentSegmentin interfaceEntity
-
getSubsegments
public java.util.List<Subsegment> getSubsegments()
- Specified by:
getSubsegmentsin interfaceEntity- Returns:
- the subsegments
-
getSubsegmentsCopy
public java.util.List<Subsegment> getSubsegmentsCopy()
Description copied from interface:EntityReturns a copy of the currently added subsegments. Updates to the returnedListwill not be reflected in theEntity.- Specified by:
getSubsegmentsCopyin interfaceEntity
-
addSubsegment
public void addSubsegment(Subsegment subsegment)
Description copied from interface:EntityAdds a subsegment.- Specified by:
addSubsegmentin interfaceEntity- Parameters:
subsegment- the subsegment to add
-
addException
public void addException(java.lang.Throwable exception)
Description copied from interface:EntityAdds an exception to the entity's cause and sets fault to true.- Specified by:
addExceptionin interfaceEntity- Parameters:
exception- the exception to add
-
putHttp
public void putHttp(java.lang.String key, java.lang.Object value)Description copied from interface:EntityPuts HTTP information.
-
putAllHttp
public void putAllHttp(java.util.Map<java.lang.String,java.lang.Object> all)
Description copied from interface:EntityPuts HTTP information.- Specified by:
putAllHttpin interfaceEntity- Parameters:
all- the HTTP information to put
-
putAws
public void putAws(java.lang.String key, java.lang.Object value)Description copied from interface:EntityPuts AWS information.
-
putAllAws
public void putAllAws(java.util.Map<java.lang.String,java.lang.Object> all)
Description copied from interface:EntityPuts AWS information.
-
putSql
public void putSql(java.lang.String key, java.lang.Object value)Description copied from interface:EntityPuts SQL information.
-
putAllSql
public void putAllSql(java.util.Map<java.lang.String,java.lang.Object> all)
Description copied from interface:EntityPuts SQL information.
-
putAnnotation
public void putAnnotation(java.lang.String key, java.lang.String value)Description copied from interface:EntityPuts a String annotation.- Specified by:
putAnnotationin interfaceEntity- Parameters:
key- the key under which the annotation is storedvalue- the String annotation
-
putAnnotation
public void putAnnotation(java.lang.String key, java.lang.Number value)Description copied from interface:EntityPuts a Number annotation.- Specified by:
putAnnotationin interfaceEntity- Parameters:
key- the key under which the annotation is storedvalue- the Number annotation
-
putAnnotation
public void putAnnotation(java.lang.String key, java.lang.Boolean value)Description copied from interface:EntityPuts a Boolean annotation.- Specified by:
putAnnotationin interfaceEntity- Parameters:
key- the key under which the annotation is storedvalue- the Boolean annotation
-
putMetadata
public void putMetadata(java.lang.String key, java.lang.Object object)Description copied from interface:EntityPuts metadata under the namespace 'default'.- Specified by:
putMetadatain interfaceEntity- Parameters:
key- the key under which the metadata is storedobject- the metadata
-
putMetadata
public void putMetadata(java.lang.String namespace, java.lang.String key, java.lang.Object object)Description copied from interface:EntityPuts metadata.- Specified by:
putMetadatain 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:EntityIncrements the subsegment-reference counter.- Specified by:
incrementReferenceCountin interfaceEntity
-
decrementReferenceCount
public boolean decrementReferenceCount()
Description copied from interface:EntityDecrements the subsegment-reference counter.- Specified by:
decrementReferenceCountin 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:
getReferenceCountin interfaceEntity- Returns:
- the reference count
-
getTotalSize
public java.util.concurrent.atomic.LongAdder getTotalSize()
- Specified by:
getTotalSizein interfaceEntity- Returns:
- the totalSize
-
isEmitted
public boolean isEmitted()
-
setEmitted
public void setEmitted(boolean emitted)
Description copied from interface:EntitySets emitted on the entity.- Specified by:
setEmittedin interfaceEntity- Parameters:
emitted- the emitted to set
-
compareAndSetEmitted
public boolean compareAndSetEmitted(boolean current, boolean next)Description copied from interface:EntityChecks whether thisEntitycurrently has emitted state ofcurrentand if so, set emitted state tonext. Returnstrueif the state was updated, orfalseotherwise.- Specified by:
compareAndSetEmittedin interfaceEntity
-
prettySerialize
public java.lang.String prettySerialize()
- Specified by:
prettySerializein interfaceEntity
-
removeSubsegment
public void removeSubsegment(Subsegment subsegment)
Description copied from interface:EntityRemoves 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:
removeSubsegmentin interfaceEntity- Parameters:
subsegment- the subsegment to remove
-
validateNotNull
public static void validateNotNull(java.lang.Object object)
-
-