Interface TraceEvent


  • public interface TraceEvent
    Interface for trace event which is the building block of traces. Each TraceEvent has its own type such as "entry", "exit", "info" and "error", which is determined when the event was created by methods in Trace. To add additional information key/value
    See Also:
    Java Agent - Instrumentation SDK
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addBackTrace()
      To report the back traces of the certain time frame of the application.
      void addEdge​(java.lang.String xTraceID)
      Adds an additional edge to this event
      void addInfo​(java.lang.Object... info)
      Add all key/value pairs to event.
      void addInfo​(java.lang.String key, java.lang.Object value)
      Adds a key/value pair to an event
      void addInfo​(java.util.Map<java.lang.String,​java.lang.Object> infoMap)
      Adds key/value pairs to the event
      void report()
      Reports the event to the collector.
      void setAsync()
      Marks this event as asynchronous.
    • Method Detail

      • addInfo

        void addInfo​(java.lang.String key,
                     java.lang.Object value)
        Adds a key/value pair to an event
        Parameters:
        key - key
        value - value
      • addInfo

        void addInfo​(java.util.Map<java.lang.String,​java.lang.Object> infoMap)
        Adds key/value pairs to the event
        Parameters:
        infoMap - map of key/value pairs
      • addInfo

        void addInfo​(java.lang.Object... info)
        Add all key/value pairs to event. This assumes that info contains alternating key/value pairs (String, Object).
        Parameters:
        info -
      • setAsync

        void setAsync()
        Marks this event as asynchronous. While instrumenting your code, you may want to report events from background / child threads and associate them with the parent thread that spawned them. (This assumes that a trace was already started in the parent thread.) You must mark these events as "async" by calling this method on the entry event associated with that background thread.

        You should then call Trace.endTrace() when that thread is done processing.

         
         TraceEvent event = Trace.createEntryEvent(spanName);
         event.setAsync();
         event.report();
         // Your processing ...
         Trace.endTrace();
         
         
      • addEdge

        void addEdge​(java.lang.String xTraceID)
        Adds an additional edge to this event
      • report

        void report()
        Reports the event to the collector.
      • addBackTrace

        void addBackTrace()
        To report the back traces of the certain time frame of the application. This adds the back trace of the current thread to the event.
         
         TraceEvent event = Trace.createInfoEvent("some_other_layer");
         event.addBackTrace();
         event.report();