public void setInheritable(final CompositeMonitor compositeMonitor, final String key, final AttributeHolder original) { if (isEnabled() && running) { inheritableStrategy.setInheritable(compositeMonitor, key, original); } }
/** * A lifecylce method that notifies observing MonitorProcessors that a monitor has been started. * All monitor implementations that have a start-stop concept should call this monitor at start. * * @param monitor the monitor that has started */ public void monitorStarted(final Monitor monitor) { if (!isEnabled()) { return; } handleMonitor(monitor, MONITOR_STARTED_CLOSURE); }
/** * A lifecycle method that notifies observing MonitorProcessors that a new monitor has been * created. All monitor implementations should call this method after setting attributes known at * creation on themselves. * * @param monitor the monitor that has been created */ public void monitorCreated(final Monitor monitor) { if (!isEnabled()) { return; } handleMonitor(monitor, MONITOR_CREATED_CLOSURE); }
/** * Pops this monitor off the top of the stack. If this monitor is not on the top of the stack nor * found anywhere within the stack, the monitor is ignored, as this is an error in * instrumentation. If the monitor is found within the stack, the top of the stack is repeatedly * popped and processed until this monitor is on the the top. * <p> * * This method should be called by all CompositeMonitor implementations before they call * process(). * * @param monitor the monitor that is completed */ public void compositeMonitorCompleted(final CompositeMonitor monitor) { if (!isEnabled()) { return; } inheritableStrategy.compositeMonitorCompleted(monitor); }
/** * Takes the supplied attributes and returns an equivalent set that are ready to be serialized. * Will only return those attributes that are marked as serializable. * * @param attributeHolders the attributes to prepare for serialization * @return an equivalent set of attributes that can be serialized */ public Map<String, Serializable> makeAttributeHoldersSerializable( final Map<String, ? extends AttributeHolder> attributeHolders) { if (!isEnabled()) { return new HashMap<String, Serializable>(); } final Map<String, Serializable> renderedAttributes = new HashMap<String, Serializable>( attributeHolders.size()); for (final Entry<String, ? extends AttributeHolder> entry : attributeHolders.entrySet()) { final AttributeHolder holder = entry.getValue(); if (holder.isSerializable()) { renderedAttributes.put(entry.getKey(), decomposer.decompose(holder)); } } return renderedAttributes; }
/** * A lifecycle method that notifies observing MonitorProcessors that a monitor is ready to be * processed. All monitor implementations should call as the last call of their lifecycle. * * @param monitor the monitor that should be processed */ public void process(final Monitor monitor) { if (!isEnabled()) { return; } inheritableStrategy.processMonitorForCompositeMonitor(monitor); handleMonitor(monitor, PROCESS_CLOSURE); }
public void initMonitor(final Monitor monitor, final boolean includeInheritables) { if (!isEnabled()) { return; } monitor.set(Attribute.CREATED_AT, new Date()).serializable().lock(); final String threadId = Integer.toHexString(Thread.currentThread().hashCode()); monitor.set(Attribute.THREAD_ID, threadId).serializable().lock(); inheritGlobals(monitor); if (includeInheritables) { inheritAttributesFromAncestors(monitor); } }
/** * Adds the supplied CompositeMonitor to the stack for this thread. If this is the first * CompositeMonitor on this thread, a new LinkedList is created and added to a map holding all * stacks by Thread. * <p> * * This method should be called by all CompositeMonitor implementations before they call * monitorStarted(). * * @param compositeMonitor the monitor to add to the stack */ public void compositeMonitorStarted(final CompositeMonitor compositeMonitor) { if (!isEnabled()) { return; } // this null check can probably go away if we replace the Monitor interface // with AbstractMonitor if (compositeMonitor.getLevel() == null) { if (log.isDebugEnabled()) { log.debug("skipping composite monitor with name " + compositeMonitor.get(Attribute.NAME) + ", it has no defined level"); } return; } inheritableStrategy.compositeMonitorStarted(compositeMonitor); }