public void setInheritable(final CompositeMonitor compositeMonitor, final String key, final AttributeHolder original) { if (isEnabled() && running) { inheritableStrategy.setInheritable(compositeMonitor, key, original); } }
/** * Returns the current inheritable attributes for this thread. * * @return the inheritable attributes that would be applied to a monitor if it were made right * now, or an empty Map if there are none */ public Map getInheritableAttributes() { return inheritableStrategy.getInheritableAttributes(); }
@Override protected void processWithProcessor(final MonitorProcessor processor) { processor.monitorCreated(_monitor); } });
private String getAttributeAsStringWithDefault(Monitor monitor, String attributeKey, String defaultValue) { if (!monitor.hasAttribute(attributeKey)) { return defaultValue; } else { return monitor.getAsString(attributeKey); } }
public boolean apply(final MonitorProcessor processor) { MonitoringLevel processorLevel = findMonitoringEngine().getProcessorLevel( processor.getName()); if (processorLevel != null) { return monitorLevel.hasHigherOrEqualPriorityThan(processorLevel); } else { return monitorLevel.hasHigherOrEqualPriorityThan(_monitoringLevel); } } });
public final MonitoringLevel getLevel() { final MonitoringLevel overrideLevel = MonitoringEngine.getInstance() .getOverrideLevelForMonitor(this); return (overrideLevel != null ? overrideLevel : monitoringLevel); }
/** * 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); }
/** * Create a new composite monitor with the provided name, monitoring level and inherited * attributes. * * @param name the name of the monitor * @param monitoringLevel the monitoring level * @param inheritedAttributes the collection of inherited attributes */ public AbstractCompositeMonitor(final String name, final MonitoringLevel monitoringLevel, final Map<String, Object> inheritedAttributes) { super(name, monitoringLevel, inheritedAttributes); MonitoringEngine.getInstance().compositeMonitorStarted(this); }
/** * 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); }
@Override protected void processWithProcessor(final MonitorProcessor processor) { processor.process(_monitor); } });
@Override protected void processWithProcessor(final MonitorProcessor processor) { processor.monitorStarted(_monitor); } });
/** * This is a method that a monitor can use to notify the processor that it * is completed and should be processed. All monitors must call this method * in order to have themselves processed. * * @param monitor the Monitor that is ready to be processed */ public void process(Monitor monitor) { aggregator.aggregate(monitor); }
/** * This is a lifecycle method that a processor can use to initialize itself * when the MonitorProcessorFactory starts up. The processor factory passes * itself to the MonitorProcessor in case the processor needs to use some * service provided by the factory. */ public void startup() { aggregator.startup(); }
/** * This is a lifecycle method that a processor can use to close any * resources it created before the monitoring system shuts down. */ public void shutdown() { aggregator.shutdown(); }
/** * Obtains the first CompositeMonitor found on the per thread stack that has its name attribute * equal to the supplied name. This method should be used in situations where stateless code is * unable to hold a reference to the CompositeMonitor that was originally created. Supplying the * name value is needed to ensure that instrumentation errors in code called by users of this * method does not interfere with the ability to correctly obtain the original CompositeMonitor. * * @param name the value of name that our Monitor was created with. * @return the first CompositeMonitor with the supplied name, or null if not found * @throws IllegalArgumentException if name is null */ public CompositeMonitor getCompositeMonitorNamed(final String name) throws IllegalArgumentException { return inheritableStrategy.getCompositeMonitorNamed(name); }
/** * A lifecycle method that initializes the Monitor. All monitor implementations must call this * methods before setting any attributes on themselves. * <p> * * After this method returns, the monitor will have had any implicitly inherited and global * attributes applied. * * @param monitor the monitor to initialize. */ public void initMonitor(final Monitor monitor) { initMonitor(monitor, true); }
public MonitoringLevel getLevel() { MonitoringLevel overrideLevel = MonitoringEngine.getInstance().getOverrideLevelForMonitor(this); return (overrideLevel != null ? overrideLevel : _monitoringLevel); } }
public void processWithProcessor(final Monitor monitor, final MonitorProcessor processor) { processor.monitorCreated(monitor); } };
/** * 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); }
public void processWithProcessor(final Monitor monitor, final MonitorProcessor processor) { processor.process(monitor); } };