/** * Get a snapshot of metric if changed * @param builder the metrics record builder */ public void snapshot(MetricsRecordBuilder builder) { snapshot(builder, false); }
MutableMetric newTag(Class<?> resType) { if (resType == String.class) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported tag type: "+ resType.getName()); }
@Override public void snapshot(MetricsRecordBuilder builder, boolean all) { impl.snapshot(builder, all); }
MutableMetric newCounter(final Class<?> type) { if (isInt(type) || isLong(type)) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[])null); if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue()); else rb.addCounter(info, ((Long) ret).longValue()); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported counter type: "+ type.getName()); }
/** * Sample all the mutable metrics and put the snapshot in the builder * @param builder to contain the metrics snapshot * @param all get all the metrics even if the values are not changed. */ public void snapshot(MetricsRecordBuilder builder, boolean all) { for (MetricsTag tag : tags()) { builder.add(tag); } for (MutableMetric metric : metrics()) { metric.snapshot(builder, all); } }
MutableMetric newGauge(final Class<?> t) { if (isInt(t) || isLong(t) || isFloat(t) || isDouble(t)) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); if (isInt(t)) rb.addGauge(info, ((Integer) ret).intValue()); else if (isLong(t)) rb.addGauge(info, ((Long) ret).longValue()); else if (isFloat(t)) rb.addGauge(info, ((Float) ret).floatValue()); else rb.addGauge(info, ((Double) ret).doubleValue()); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported gauge type: "+ t.getName()); }
@Override public void getMetrics(MetricsCollector collector, boolean all) { // We could also have one metricssource for all the pools and add all the pools to the collector // in its getMetrics call (as separate records). Not clear if that's supported. // Also, we'd have to initialize the metrics ourselves instead of using @Metric annotation. MetricsRecordBuilder rb = collector.addRecord("WmPoolMetrics." + poolName) .setContext("HS2").tag(MsInfo.SessionId, poolName); if (allMetrics == null) { initAfterRegister(); // This happens if register calls getMetrics. } for (MutableMetric metric : allMetrics.values()) { metric.snapshot(rb, all); } }
MutableMetric newTag(Class<?> resType) { if (resType == String.class) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported tag type: "+ resType.getName()); }
/** * Sample all the mutable metrics and put the snapshot in the builder * @param builder to contain the metrics snapshot * @param all get all the metrics even if the values are not changed. */ public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) { for (MetricsTag tag : tags()) { builder.add(tag); } for (MutableMetric metric : metrics()) { metric.snapshot(builder, all); } }
MutableMetric newTag(Class<?> resType) { if (resType == String.class) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported tag type: "+ resType.getName()); }
/** * Get a snapshot of metric if changed * @param builder the metrics record builder */ public void snapshot(MetricsRecordBuilder builder) { snapshot(builder, false); }
MutableMetric newTag(Class<?> resType) { if (resType == String.class) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported tag type: "+ resType.getName()); }
/** * Get a snapshot of metric if changed * @param builder the metrics record builder */ public void snapshot(MetricsRecordBuilder builder) { snapshot(builder, false); }
MutableMetric newTag(Class<?> resType) { if (resType == String.class) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported tag type: "+ resType.getName()); }
/** * Get a snapshot of metric if changed * @param builder the metrics record builder */ public void snapshot(MetricsRecordBuilder builder) { snapshot(builder, false); }
MutableMetric newCounter(final Class<?> type) { if (isInt(type) || isLong(type)) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[])null); if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue()); else rb.addCounter(info, ((Long) ret).longValue()); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported counter type: "+ type.getName()); }
/** * Get a snapshot of metric if changed * @param builder the metrics record builder */ public void snapshot(MetricsRecordBuilder builder) { snapshot(builder, false); }
MutableMetric newCounter(final Class<?> type) { if (isInt(type) || isLong(type)) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[])null); if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue()); else rb.addCounter(info, ((Long) ret).longValue()); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported counter type: "+ type.getName()); }
@Override public void snapshot(MetricsRecordBuilder builder, boolean all) { impl.snapshot(builder, all); }
MutableMetric newCounter(final Class<?> type) { if (isInt(type) || isLong(type)) { return new MutableMetric() { @Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[])null); if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue()); else rb.addCounter(info, ((Long) ret).longValue()); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } }; } throw new MetricsException("Unsupported counter type: "+ type.getName()); }