Versions Compared

Key

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

...

To use the monitoring framework in application code, do the following: defining a monitor interface and injecting the monitor in a component.

Define a

...

Monitoring Interface.

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.Monitor;

public void TheComponent {

   @Monitor
   protected ComponentMonitor;

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

      // ...
     

   } 

When an @Monitor annotation is encountered, the Fabric3 runtime will generate a monitor proxy and inject it based on the monitor interface. Depending on the current monitor level, events may be logged or ignored. In the above example, if the monitor level is set to severe, the receivedRequest() event will be dropped.

Event-Based Monitoring

Fabric3 monitoring is built on SCA pub/sub eventing (c.f. PubSub Eventing). Monitor events are sent to an underlying channel where consumers can observe them. By default, monitor events emitted from application components are set to the ApplicationMonitorChannel, which is a channel provided by the Fabric3 runtime.