Search in sources :

Example 1 with MetricsComponent

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;
}
Also used : MetricsService(org.onlab.metrics.MetricsService) MetricsFeature(org.onlab.metrics.MetricsFeature) MetricsComponent(org.onlab.metrics.MetricsComponent)

Example 2 with MetricsComponent

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();
        }
    }
}
Also used : ControlMetricType(org.onosproject.cpman.ControlMetricType) MetricsComponent(org.onlab.metrics.MetricsComponent)

Aggregations

MetricsComponent (org.onlab.metrics.MetricsComponent)2 MetricsFeature (org.onlab.metrics.MetricsFeature)1 MetricsService (org.onlab.metrics.MetricsService)1 ControlMetricType (org.onosproject.cpman.ControlMetricType)1