/** * Track and Trace given {@link TrackingEvent} instance correlated with current activity * * @param event * tracking instance to be tracked */ public void tnt(TrackingEvent event) { if (isStopped()) { throw new IllegalStateException( "Activity already stopped: name=" + getName() + ", id=" + this.getTrackingId()); } add(event); lastEventNanos = System.nanoTime(); tracker.tnt(event); }
/** * Push an instance of {@link TrackingActivity} on top of the stack. Invoke this when activity starts. The stack is * maintained per thread in thread local. * * @param item * activity to be pushed on the current stack * @return current tracker instance */ protected Tracker push(TrackingActivity item) { if (!keepContext) { return this; } LightStack<TrackingActivity> stack = ACTIVITY_STACK.get(); if (stack == null) { stack = new LightStack<>(); ACTIVITY_STACK.set(stack); } // associate with the parent activity if there is any TrackingActivity parent = stack.peek(null); if (parent != null) { parent.add(item); } stack.push(item); pushCount.incrementAndGet(); return this; }
/** * Track and Trace given {@link com.jkoolcloud.tnt4j.core.Snapshot} instance correlated with current activity * * @param snapshot * snapshot instance to be tracked */ public void tnt(Snapshot snapshot) { if (isStopped()) { throw new IllegalStateException( "Activity already stopped: name=" + getName() + ", id=" + this.getTrackingId()); } add(snapshot); tracker.tnt(snapshot); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String localName, String name) throws SAXException { if (name.equals(SIM_XML_MSG)) { recordMsgData(); curMsg = null; } else if (name.equals(SIM_XML_SNAPSHOT)) { if (curEvent != null) { curEvent.getOperation().addSnapshot(curSnapshot); } else { curActivity.add(curSnapshot); } curSnapshot = null; } else if (name.equals(SIM_XML_ACTIVITY)) { stopActivity(); } else if (name.equals(SIM_XML_EVENT)) { if (curActivity != null) { curActivity.tnt(curEvent); } else { Tracker tracker = trackers.get(curEvent.getSource().getFQName()); if (tracker != null) { tracker.tnt(curEvent); } } curEvent = null; } curElement = activeElements.pop(); }
parentActivity.add(curActivity);