/** * A static factory method to create an instance of Delta Counter. * * @param registry The MetricRegistry to use * @param metricName The MetricName to use * @return An instance of DeltaCounter */ @VisibleForTesting public static synchronized DeltaCounter get(MetricsRegistry registry, MetricName metricName) { if (registry == null || metricName == null || metricName.getName().isEmpty()) { throw new IllegalArgumentException("Invalid arguments"); } DeltaCounter counter = new DeltaCounter(); MetricName newMetricName = getDeltaCounterMetricName(metricName); registry.getOrAdd(newMetricName, counter); return counter; }
/** * A static factory method to create an instance of Delta Counter. * * @param registry The MetricRegistry to use * @param metricName The MetricName to use * @return An instance of DeltaCounter */ @VisibleForTesting public static synchronized DeltaCounter get(MetricsRegistry registry, MetricName metricName) { if (registry == null || metricName == null || metricName.getName().isEmpty()) { throw new IllegalArgumentException("Invalid arguments"); } DeltaCounter counter = new DeltaCounter(); MetricName newMetricName = getDeltaCounterMetricName(metricName); registry.getOrAdd(newMetricName, counter); return counter; }