Class TraceTiming

java.lang.Object
org.pipservices3.components.trace.TraceTiming

public class TraceTiming extends Object
Timing object returned by ITracer.beginTrace(java.lang.String, java.lang.String, java.lang.String) to end timing of execution block and record the associated trace. ### Example ### TraceTiming timing = tracer.beginTrace("mymethod.exec_time"); try { ... timing.endTrace(); } catch (Exception err) { timing.endFailure(err); }
  • Constructor Details

    • TraceTiming

      public TraceTiming(String correlationId, String component, String operation)
    • TraceTiming

      public TraceTiming(String correlationId, String component, String operation, ITracer tracer)
      Creates a new instance of the timing callback object.
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      component - an associated component name
      operation - an associated operation name
      tracer - a callback that shall be called when endTiming is called.
  • Method Details

    • endTrace

      public void endTrace()
      Ends timing of an execution block, calculates elapsed time and records the associated trace.
    • endFailure

      public void endFailure(Exception error)
      Ends timing of a failed block, calculates elapsed time and records the associated trace.
      Parameters:
      error - an error object associated with this trace.