Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Strongly-typed monitoring interfaces and events
  • Event-based monitoring
  • Robust log capture via SLF4J
  • Dynamic event level adjustment

...

The monitoring interface is used for sending monitoring events. The interface defines expected events and monitoring levels using methods on the interface:

Code Block
java
java

import org.fabric3.api.annotation.monitor.Severe;
import org.fabric3.api.annotation.monitor.Debug;

public inteface ComponentMonitor

   @Severe
   void error(String message, Throwable t);

   @Debug ("Received request {0}")
   void receivedRequest(String id);

}

...

A monitor is injected in a component using the org.fabric3.api.annotation.monitor.Monitor annotation:

Code Block
java
java

import org.fabric3.api.annotation.monitor.Monitor;

public void TheComponent {

   @Monitor
   protected ComponentMonitor monitor;

   public void call(Message message) {
      monitor.receivedRequest(message.getId);
      try{
         validate(message));
      } catch (ValidationException e) {
         // bad message
         monitor.error("Invalid message", e)
      }

      // ...

   }

...

Fabric3 uses JDK proxies to implement monitor interfaces. For most code paths in an application, this should not introduce significant performance impact as there are optimizations to avoid object creation when events are discarded. However, for performance intensive code paths, JDK proxies may introduce too much overhead. As an alternative, Fabric3 provides the org.fabric3.api.MonitorChannel interface. A monitor can be typed with this interface, which bypasses JDK proxies and instead uses static method calls:

Code Block
java
java

import org.fabric3.api.annotation.monitor.Monitor;

public void TheComponent {

   @Monitor
   protected MonitorChannel monitor;

   public void call(Message message) {
      monitor.debug("Received request", message.getId);
      try{
         validate(message));
      } catch (ValidationException e) {
         // bad message
         monitor.severe("Invalid message", e)
      }

      // ...

   }

Event-Based Monitoring

...