use of org.onlab.metrics.MetricsComponent in project onos by opennetworkinglab.
the class MetricsHelper method createTimer.
/**
* Creates a Timer instance with given name.
*
* @param component component name
* @param feature feature name
* @param name timer name
* @return Timer instance
*/
default Timer createTimer(String component, String feature, String name) {
final MetricsService metricsService = metricsService();
if (metricsService != null) {
MetricsComponent c = metricsService.registerComponent(component);
MetricsFeature f = c.registerFeature(feature);
return metricsService.createTimer(c, f, name);
}
return null;
}
use of org.onlab.metrics.MetricsComponent in project onos by opennetworkinglab.
the class SystemMetricsAggregator method addMetrics.
/**
* Adds a set of new monitoring metric types.
*
* @param optResourceName optional resource name, null denotes system metric
* @param resType resource type
*/
public void addMetrics(Optional<String> optResourceName, String resType) {
Set<ControlMetricType> metricTypeSet = Sets.newHashSet();
String resourceName = optResourceName.isPresent() ? optResourceName.get() : DEFAULT_RESOURCE_NAME;
MetricsComponent metricsComponent = metricsService.registerComponent(resourceName);
if (optResourceName.isPresent()) {
if (!diskMap.containsKey(resourceName) && DISK_RESOURCE_TYPE.equals(resType)) {
metricTypeSet.addAll(ControlResource.DISK_METRICS);
diskMap.putIfAbsent(resourceName, getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
} else if (!networkMap.containsKey(resourceName) && NETWORK_RESOURCE_TYPE.equals(resType)) {
metricTypeSet.addAll(ControlResource.NETWORK_METRICS);
networkMap.putIfAbsent(resourceName, getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
} else {
return;
}
} else {
if (systemMap.isEmpty()) {
metricTypeSet.addAll(ControlResource.MEMORY_METRICS);
metricTypeSet.addAll(ControlResource.CPU_METRICS);
systemMap.putAll(getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
}
}
}
Aggregations