use of com.yammer.metrics.core.MetricName in project Dempsy by Dempsy.
the class TestStatsCollectorCoda method testEnvPrefixFromSystemProperty.
@Test
public void testEnvPrefixFromSystemProperty() throws Throwable {
tearDown();
System.setProperty(StatsCollectorFactoryCoda.environmentPrefixSystemPropertyName, "Hello.");
setUp();
StatsCollectorFactoryCoda.MetricNamingStrategy strategy = statsCollectorFactory.getNamingStrategy();
ClusterId clusterId = new ClusterId("app", "cluster");
MetricName name = strategy.createName(clusterId, "metric");
assertEquals("metric", name.getName());
assertEquals("app-cluster", name.getGroup());
assertTrue(strategy.buildPrefix(clusterId, new Destination() {
@Override
public String toString() {
return "destination";
}
}).startsWith("Hello."));
// make sure setting the environment prefix doesn't effect the -D option
statsCollectorFactory.setEnvironmentPrefix("otherEnvPrefix");
assertTrue(strategy.buildPrefix(clusterId, new Destination() {
@Override
public String toString() {
return "destination";
}
}).startsWith("Hello."));
// make sure that without the system property the setEnvironmentPrefix value works
System.getProperties().remove(StatsCollectorFactoryCoda.environmentPrefixSystemPropertyName);
assertTrue(strategy.buildPrefix(clusterId, new Destination() {
@Override
public String toString() {
return "destination";
}
}).startsWith("otherEnvPrefix"));
// make sure that delting the environmentPrefix doesn't create an issue.
statsCollectorFactory.setEnvironmentPrefix(null);
strategy.buildPrefix(clusterId, new Destination() {
@Override
public String toString() {
return "destination";
}
}).startsWith("otherEnvPrefix");
}
use of com.yammer.metrics.core.MetricName in project pinot by linkedin.
the class MetricsHelperTest method testMetricsHelperRegistration.
@Test
public void testMetricsHelperRegistration() {
listenerOneOkay = false;
listenerTwoOkay = false;
Map<String, String> configKeys = new HashMap<String, String>();
configKeys.put("pinot.broker.metrics.metricsRegistryRegistrationListeners", ListenerOne.class.getName() + "," + ListenerTwo.class.getName());
Configuration configuration = new MapConfiguration(configKeys);
MetricsRegistry registry = new MetricsRegistry();
// Initialize the MetricsHelper and create a new timer
MetricsHelper.initializeMetrics(configuration.subset("pinot.broker.metrics"));
MetricsHelper.registerMetricsRegistry(registry);
MetricsHelper.newTimer(registry, new MetricName(MetricsHelperTest.class, "dummy"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);
// Check that the two listeners fired
assertTrue(listenerOneOkay);
assertTrue(listenerTwoOkay);
}
use of com.yammer.metrics.core.MetricName in project pinot by linkedin.
the class AbstractMetrics method addMeteredGlobalValue.
/**
* Logs a value to a meter.
*
* @param meter The meter to use
* @param unitCount The number of units to add to the meter
*/
public void addMeteredGlobalValue(final M meter, final long unitCount) {
final String fullMeterName;
String meterName = meter.getMeterName();
fullMeterName = _metricPrefix + meterName;
final MetricName metricName = new MetricName(_clazz, fullMeterName);
MetricsHelper.newMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS).mark(unitCount);
}
use of com.yammer.metrics.core.MetricName in project pinot by linkedin.
the class AbstractMetrics method addMeteredQueryValue.
/**
* Logs a value to a meter for a specific query.
*
* @param request The broker request associated with this query
* @param meter The meter to use
* @param unitCount The number of units to add to the meter
*/
public void addMeteredQueryValue(final BrokerRequest request, final M meter, final long unitCount) {
final String fullMeterName;
String meterName = meter.getMeterName();
if (request != null) {
fullMeterName = buildMetricName(request, meterName);
} else {
fullMeterName = _metricPrefix + meterName;
}
final MetricName metricName = new MetricName(_clazz, fullMeterName);
MetricsHelper.newMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS).mark(unitCount);
}
use of com.yammer.metrics.core.MetricName in project pinot by linkedin.
the class AbstractMetrics method addValueToTimer.
/**
* Logs the timing for a metric
*
* @param fullTimerName The full name of timer
* @param duration The log time duration time value
* @param timeUnit The log time duration time unit
*/
private void addValueToTimer(String fullTimerName, final long duration, final TimeUnit timeUnit) {
final MetricName metricName = new MetricName(_clazz, fullTimerName);
MetricsHelper.newTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS).update(duration, timeUnit);
}
Aggregations