Useful Links


Event Types

There are two basic types of events in MonDemand - log events and stats events. Log events are text messages that represent something that has happened, stats events represent the numerical state of an thread of control. Most applications provide a logging framework such as log4j that can be re-used for log events, however stats events are usually created from within the application.

There is a third type of event that can be used to track workflow that is under development.

Java Example

import org.mondemand.Client;
import org.mondemand.Transport;

public class MyApp {
  private static Client client = null;
  public static void main(String[] args) {
    // or could be implemented as singleton if desired
    client = new Client("MyApp");
    // setup the transport.  this also only needs to be done once, not per request
    try {
      Transport transport = new LWESTransport(InetAddress.getByName(""),
                                              9191, null);
    } catch(Exception e) {}
    // set some optional persistent contexts
    client.addContext("clusterID", "101");
    client.addContext("partitionID", "202");
    /* typically everything below this line would be done in the main event loop */
    // log some messages
    // log some stats
    client.setKey("responseTime", 101);
    // flush the messages to the network

C Example

#include "mondemand.h"

  struct mondemand_client *client = NULL;
  struct mondemand_transport *transport = NULL;

  // create the client
  client = mondemand_client_create("my_application");
  // create a transport to send data
  transport = mondemand_transport_lwes_create("", 9191, NULL, 0, 60);

  // attach the transport to the client
  mondemand_add_transport(client, transport);

  // add some contextual information to the client
  mondemand_set_context(client, "cluster_id", "123");

  // log some messages
  mondemand_info(client, MONDEMAND_NULL_TRACE_ID, "Hello! I am %s", "123");
  // log some stats
  mondemand_set_key_by_val(client, "stat_1", 1234);
  mondemand_increment_key(client, "stat_2");

  // send it to the network

  return 0;