private MetricName makeMetricName(final String gaugeName) { return new MetricName(ValidationMetrics.class, gaugeName); }
public NettyServerMetrics(MetricsRegistry registry, String group) { _requestsReceived = MetricsHelper.newCounter(registry, new MetricName(group, "", REQUESTS_RECEIVED)); _bytesSent = MetricsHelper.newCounter(registry, new MetricName(group, "", BYTES_SENT)); _bytesReceived = MetricsHelper.newCounter(registry, new MetricName(group, "", BYTES_RECEIVED)); _errors = MetricsHelper.newCounter(registry, new MetricName(group, "", ERRORS)); _sendResponseMsHistogram = MetricsHelper.newHistogram(registry, new MetricName(group, "", SEND_RESPONSE_MS), false); _processingLatencyMsHistogram = MetricsHelper.newHistogram(registry, new MetricName(group, "", PROCESSING_LATENCY_MS), false); }
public AggregatedTransportServerMetrics(AggregatedMetricsRegistry registry, String group) { _requestsReceived = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", REQUESTS_RECEIVED)); _bytesSent = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", BYTES_SENT)); _bytesReceived = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", BYTES_RECEIVED)); _errors = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", ERRORS)); _sendResponseMsHistogram = MetricsHelper.newAggregatedHistogram(registry, new MetricName(group, "", SEND_RESPONSE_MS)); _processingLatencyMsHistogram = MetricsHelper.newAggregatedHistogram(registry, new MetricName(group, "", PROCESSING_LATENCY_MS)); }
public AggregatedTransportClientMetrics(AggregatedMetricsRegistry registry, String group) { _requestsSent = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", REQUESTS_SENT)); _bytesSent = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", BYTES_SENT)); _bytesReceived = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", BYTES_RECEIVED)); _errors = MetricsHelper.newAggregatedCounter(registry, new MetricName(group, "", ERRORS)); _sendRequestMsHistogram = MetricsHelper.newAggregatedHistogram(registry, new MetricName(group, "", SEND_REQUEST_MS)); _responseLatencyMsHistogram = MetricsHelper.newAggregatedHistogram(registry, new MetricName(group, "", RESPONSE_LATENCY_MS)); _connectMsGauge = MetricsHelper.newAggregatedLongGauge(registry, new MetricName(group, "", CONNECT_TIME)); }
@Override public MetricName createMetricName(String metricName) { String groupName = ThreadPoolMetrics.class.getPackage().getName(); StringBuilder mbeanName = new StringBuilder(); mbeanName.append(groupName).append(":"); mbeanName.append("type=").append(type); mbeanName.append(",path=").append(path); mbeanName.append(",scope=").append(poolName); mbeanName.append(",name=").append(metricName); return new MetricName(groupName, type, metricName, path + "." + poolName, mbeanName.toString()); } }
public NettyClientMetrics(MetricsRegistry registry, String group) { _requestsSent = MetricsHelper.newCounter(registry, new MetricName(group, "", REQUESTS_SENT)); _bytesSent = MetricsHelper.newCounter(registry, new MetricName(group, "", BYTES_SENT)); _bytesReceived = MetricsHelper.newCounter(registry, new MetricName(group, "", BYTES_RECEIVED)); _errors = MetricsHelper.newCounter(registry, new MetricName(group, "", ERRORS)); _sendRequestMsHistogram = MetricsHelper.newHistogram(registry, new MetricName(group, "", SEND_REQUEST_MS), false); _responseLatencyMsHistogram = MetricsHelper.newHistogram(registry, new MetricName(group, "", RESPONSE_LATENCY_MS), false); _connectMsGauge = MetricsHelper.newGauge(registry, new MetricName(group, "", CONNECT_TIME), new ConnectMsGauge()); }
public static MetricName createMetricName(String type, String metricName, String scope) { return new MetricName(GROUP_NAME, type, metricName, scope, createDefaultMBeanName(type, metricName, scope)); }
/** * Adds a new gauge whose values are retrieved from a callback function. * * @param metricName The name of the metric * @param valueCallback The callback function used to retrieve the value of the gauge */ public void addCallbackGauge(final String metricName, final Callable<Long> valueCallback) { MetricsHelper.newGauge(_metricsRegistry, new MetricName(_clazz, _metricPrefix + metricName), new com.yammer.metrics.core.Gauge<Long>() { @Override public Long value() { try { return valueCallback.call(); } catch (Exception e) { LOGGER.error("Caught exception", e); Utils.rethrowException(e); throw new AssertionError("Should not reach this"); } } }); }
public AsyncPoolResourceManagerAdapter(ServerInstance key, PooledResourceManager<T> resourceManager, ExecutorService executorService, MetricsRegistry registry) { _resourceManager = resourceManager; _executor = executorService; _key = key; _histogram = MetricsHelper .newHistogram(registry, new MetricName(AsyncPoolResourceManagerAdapter.class, key.toString()), false); }
_strategy = strategy; _minSize = minSize; _waitTime = MetricsHelper.newHistogram(registry, new MetricName(AsyncPoolImpl.class, name), false);
_strategy = Strategy.MRU; _minSize = 0; _waitTime = MetricsHelper.newHistogram(registry, new MetricName(AsyncPoolImpl.class, name), false);
/** * 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); com.yammer.metrics.core.Timer timer = MetricsHelper.newTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS); MetricsHelper.newTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS) .update(duration, timeUnit); }
public com.yammer.metrics.core.Meter getMeteredTableValue(final String tableName, final M meter) { final String fullMeterName; String meterName = meter.getMeterName(); fullMeterName = _metricPrefix + getTableName(tableName) + "." + meterName; final MetricName metricName = new MetricName(_clazz, fullMeterName); return MetricsHelper.newMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS); }
metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int32", "FlowFiles Received Last 5 mins"), new Gauge<Integer>() { @Override public Integer value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Received Last 5 mins"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int32", "FlowFiles Sent Last 5 mins"), new Gauge<Integer>() { @Override public Integer value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Sent Last 5 mins"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int32", "FlowFiles Queued"), new Gauge<Integer>() { @Override public Integer value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Queued"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Read (5 mins)"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Written (5 mins)"), new Gauge<Long>() {
/** * 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); }
@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); } }
/** * Logs a value to a meter. * * @param meter The meter to use * @param unitCount The number of units to add to the meter * @param reusedMeter The meter to reuse */ public com.yammer.metrics.core.Meter addMeteredGlobalValue(final M meter, final long unitCount, com.yammer.metrics.core.Meter reusedMeter) { if (reusedMeter != null) { reusedMeter.mark(unitCount); return reusedMeter; } else { final String fullMeterName; String meterName = meter.getMeterName(); fullMeterName = _metricPrefix + meterName; final MetricName metricName = new MetricName(_clazz, fullMeterName); final com.yammer.metrics.core.Meter newMeter = MetricsHelper.newMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS); newMeter.mark(unitCount); return newMeter; } }
/** * Logs a value to a table-level meter. * @param tableName The table name * @param meter The meter to use * @param unitCount The number of units to add to the meter * @param reusedMeter The meter to reuse */ public com.yammer.metrics.core.Meter addMeteredTableValue(final String tableName, final M meter, final long unitCount, com.yammer.metrics.core.Meter reusedMeter) { if (reusedMeter != null) { reusedMeter.mark(unitCount); return reusedMeter; } else { final String fullMeterName; String meterName = meter.getMeterName(); fullMeterName = _metricPrefix + getTableName(tableName) + "." + meterName; final MetricName metricName = new MetricName(_clazz, fullMeterName); final com.yammer.metrics.core.Meter newMeter = MetricsHelper.newMeter(_metricsRegistry, metricName, meter.getUnit(), TimeUnit.SECONDS); newMeter.mark(unitCount); return newMeter; } }
@Override public Object start(final String tagName) { final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName), durationUnit, rateUnit); return timer.time(); }
/** * Override to customize how {@link MetricName}s are created. * * @param klass the class which owns the metric * @param name the name of the metric * @param scope the metric's scope * @return the metric's full name */ protected MetricName createName(Class<?> klass, String name, String scope) { return new MetricName(klass, name, scope); }