org.e2etrace.trace
Class DefaultTraceStep

java.lang.Object
  extended by org.e2etrace.trace.AbstractTraceStep
      extended by org.e2etrace.trace.DefaultTraceStep
All Implemented Interfaces:
Serializable, ITraceStep

public class DefaultTraceStep
extends AbstractTraceStep

Default ITraceStep implementation.

Trace steps may be serialized to remote clients. Please note that after serializiation enter() and leave() should be called anymore (the methods will handle this case gracefully and print a warning message).

To enable logging of the trace-calls just set the log level for this class to DEBUG. For example, in a log4j configuration file the following entry activates log output for every call to enter() and leave():

 log4j.category.e2etrace.trace.DefaultTraceStep = DEBUG
 

Author:
Gunther Popp
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.e2etrace.trace.AbstractTraceStep
children
 
Method Summary
 void enter()
          Enter the trace step and start time measuring.
 long getDuration()
          Returns the duration of this TraceStep and all children.
 long getIsolatedDuration()
          Returns the isolated duration of this TraceStep.
 boolean isActive()
          Checks, if the current trace step is active.
 void leave()
          Leave the trace step and calculate the elapsed time since enter has been called.
 String toString()
          Override toString.
 
Methods inherited from class org.e2etrace.trace.AbstractTraceStep
addChild, equals, getChildren, getId, getParent, hashCode, leaveAllChildren, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

enter

public void enter()
Enter the trace step and start time measuring.

This method should only be called once for a trace step. All subsequent calls will be ignored.

Specified by:
enter in interface ITraceStep
Specified by:
enter in class AbstractTraceStep

leave

public void leave()
Leave the trace step and calculate the elapsed time since enter has been called. The elapsed time is returned by getDuration().

Leaving a step implies that all children are left, too.

This method should only be called once for a trace step. All subsequent calls will be ignored.

Specified by:
leave in interface ITraceStep
Specified by:
leave in class AbstractTraceStep

isActive

public boolean isActive()
Checks, if the current trace step is active.

A step is active between the calls to enter and leave.

Specified by:
isActive in interface ITraceStep
Specified by:
isActive in class AbstractTraceStep
Returns:
true: The trace step is active.

getDuration

public long getDuration()
Returns the duration of this TraceStep and all children.

This value reflects the overall execution time of a trace step between the calls to enter and leave inclusive the durations of all children.

Specified by:
getDuration in interface ITraceStep
Specified by:
getDuration in class AbstractTraceStep
Returns:
accumulated duration in ms

getIsolatedDuration

public long getIsolatedDuration()
Returns the isolated duration of this TraceStep.

The duration is the time elapsed between the calls to enter and leave minus the durations of all children.

Please note that the returned value only reflects the real execution time, if all children of this trace step really have been executed. That is, if trace steps are added manually, getIsolatedDuration() will return meaningless values. An example for this scenario are traces that are collected from parallel execution threads and manually added to the trace step of the method that spawned the threads.

Specified by:
getIsolatedDuration in interface ITraceStep
Specified by:
getIsolatedDuration in class AbstractTraceStep
Returns:
duration of this TraceStep in ms (-1: no valid duration exists for this trace step)

toString

public String toString()
Override toString.

Overrides:
toString in class Object
Returns:
the Objects String representation.


Copyright © 2013 Gunther Popp. All Rights Reserved.