use of ddf.metrics.collector.rrd4j.RrdJmxCollector in project ddf by codice.
the class SourceMetricsImpl method createMetricsCollector.
/**
* Creates the JMX Collector for an associated metric's JMX MBean.
*
* @param sourceId
* @param collectorName
* @param mbeanAttributeName
* usually "Count" or "Mean"
* @param dataSourceType
* only "DERIVE", "COUNTER" or "GAUGE" are supported
* @return the ddf.metrics.collector.JmxCollector created
*/
private RrdJmxCollector createMetricsCollector(String sourceId, String collectorName, String mbeanAttributeName, String dataSourceType) {
LOGGER.trace("ENTERING: createMetricsCollector - sourceId = {}, collectorName = {}, mbeanAttributeName = {}, dataSourceType = {}", sourceId, collectorName, mbeanAttributeName, dataSourceType);
String rrdPath = getRrdFilename(sourceId, collectorName);
RrdJmxCollector collector = new RrdJmxCollector(MBEAN_PACKAGE_NAME + ":name=" + sourceId + "." + collectorName, mbeanAttributeName, rrdPath, dataSourceType);
collector.init();
LOGGER.trace("EXITING: createMetricsCollector - sourceId = {}", sourceId);
return collector;
}
use of ddf.metrics.collector.rrd4j.RrdJmxCollector in project ddf by codice.
the class SourceMetricsImpl method createMetric.
private void createMetric(String sourceId, String mbeanName, MetricType type) {
// Create source-specific metrics for this source
// (Must be done prior to creating metrics collector so that
// JMX MBean exists for collector to detect).
String key = sourceId + "." + mbeanName;
// as the local catalog provider).
if (!metrics.containsKey(key)) {
if (type == MetricType.HISTOGRAM) {
Histogram histogram = metricsRegistry.histogram(MetricRegistry.name(sourceId, mbeanName));
RrdJmxCollector collector = createGaugeMetricsCollector(sourceId, mbeanName);
metrics.put(key, new SourceMetric(histogram, collector, true));
} else if (type == MetricType.METER) {
Meter meter = metricsRegistry.meter(MetricRegistry.name(sourceId, mbeanName));
RrdJmxCollector collector = createCounterMetricsCollector(sourceId, mbeanName);
metrics.put(key, new SourceMetric(meter, collector));
} else {
LOGGER.debug("Metric {} not created because unknown metric type {} specified.", key, type);
}
} else {
LOGGER.debug("Metric {} already exists - not creating again", key);
}
}
Aggregations