@@ -24,10 +24,11 @@ this software and associated documentation files (the "Software"), to deal in
2424
2525package su .interference .metrics ;
2626
27+ import org .slf4j .Logger ;
28+ import org .slf4j .LoggerFactory ;
2729import javax .management .MBeanServer ;
2830import javax .management .ObjectName ;
2931import java .lang .management .ManagementFactory ;
30- import java .util .HashMap ;
3132import java .util .concurrent .ConcurrentHashMap ;
3233
3334/**
@@ -40,15 +41,26 @@ public class Metrics {
4041 public static final int COUNTER = 1 ;
4142 public static final int HISTOGRAM = 2 ;
4243 public static final int TIMER = 3 ;
44+ public static final int CALL = 4 ;
4345 public static final int METER = 10 ;
4446 private static final ConcurrentHashMap <String , Meter > metrics = new ConcurrentHashMap <String , Meter >();
4547 private static final MBeanServer mbs = ManagementFactory .getPlatformMBeanServer ();
48+ private final static Logger logger = LoggerFactory .getLogger (Metrics .class );
49+
50+ static {
51+ try {
52+ register (CALL , "systemCalls" );
53+ } catch (Exception e ) {
54+ logger .error ("Exception in metrics static intializer" , e );
55+ }
56+ }
4657
4758 public static void register (int type , String name ) throws Exception {
4859 if (type == COUNTER ) { metrics .put (name , new Counter (name )); }
4960 if (type == HISTOGRAM ) { metrics .put (name , new Histogram (name )); }
5061 if (type == TIMER ) { metrics .put (name , new Timer (name )); }
5162 if (type == METER ) { metrics .put (name , new Meter (name )); }
63+ if (type == CALL ) { metrics .put (name , new Call (name )); }
5264
5365 ObjectName obj = new ObjectName ("su.interference:type=" +name +metrics .get (name ).getClass ().getSimpleName ());
5466 mbs .registerMBean (metrics .get (name ), obj );
0 commit comments