com.codahale.metrics.SlidingTimeWindowArrayReservoir Java Examples

The following examples show how to use com.codahale.metrics.SlidingTimeWindowArrayReservoir. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignalFxEndpointMetricsHandlerTest.java    From riposte with Apache License 2.0 6 votes vote down vote up
@DataProvider(value = {
    "42     |   DAYS",
    "123    |   SECONDS",
    "999    |   MILLISECONDS",
    "3      |   HOURS"
}, splitBy = "\\|")
@Test
public void RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowArrayReservoir_with_expected_values(
    long amount, TimeUnit timeUnit
) {
    // given
    RollingWindowTimerBuilder rwtb = new RollingWindowTimerBuilder(amount, timeUnit);

    // when
    Timer timer = rwtb.newMetric();

    // then
    Histogram histogram = (Histogram) getInternalState(timer, "histogram");
    Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
    assertThat(reservoir).isInstanceOf(SlidingTimeWindowArrayReservoir.class);
    // The expected value here comes from logic in the SlidingTimeWindowArrayReservoir constructor.
    assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
 
Example #2
Source File: SignalFxEndpointMetricsHandlerTest.java    From riposte with Apache License 2.0 6 votes vote down vote up
@DataProvider(value = {
    "42     |   DAYS",
    "123    |   SECONDS",
    "999    |   MILLISECONDS",
    "3      |   HOURS"
}, splitBy = "\\|")
@Test
public void RollingWindowHistogramBuilder_newMetric_creates_new_histogram_with_SlidingTimeWindowArrayReservoir_with_expected_values(
    long amount, TimeUnit timeUnit
) {
    // given
    RollingWindowHistogramBuilder rwhb = new RollingWindowHistogramBuilder(amount, timeUnit);

    // when
    Histogram histogram = rwhb.newMetric();

    // then
    Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
    assertThat(reservoir).isInstanceOf(SlidingTimeWindowArrayReservoir.class);
    // The expected value here comes from logic in the SlidingTimeWindowArrayReservoir constructor.
    assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
 
Example #3
Source File: RoutingTableProviderMonitor.java    From helix with Apache License 2.0 6 votes vote down vote up
public RoutingTableProviderMonitor(final PropertyType propertyType, String clusterName) {
  _propertyType = propertyType;
  _clusterName = clusterName == null ? DEFAULT : clusterName;

  // Don't put instanceName into sensor name. This detail information is in the MBean name already.
  _sensorName = String
      .format("%s.%s.%s", MonitorDomainNames.RoutingTableProvider.name(), _clusterName,
          _propertyType.name());

  _dataRefreshLatencyGauge = new HistogramDynamicMetric("DataRefreshLatencyGauge", new Histogram(
      new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _callbackCounter = new SimpleDynamicMetric("CallbackCounter", 0l);
  _eventQueueSizeGauge = new SimpleDynamicMetric("EventQueueSizeGauge", 0l);
  _dataRefreshCounter = new SimpleDynamicMetric("DataRefreshCounter", 0l);
  if (propertyType.equals(PropertyType.CURRENTSTATES)) {
    _statePropLatencyGauge = new HistogramDynamicMetric("StatePropagationLatencyGauge",
        new Histogram(
            new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  }
}
 
Example #4
Source File: HelixCallbackMonitor.java    From helix with Apache License 2.0 6 votes vote down vote up
public HelixCallbackMonitor(InstanceType type, String clusterName, String instanceName,
    HelixConstants.ChangeType changeType) throws JMException {
  _changeType = changeType;
  _type = type;
  _clusterName = clusterName;
  _instanceName = instanceName;

  // Don't put instanceName into sensor name. This detail information is in the MBean name already.
  _sensorName = String
      .format("%s.%s.%s.%s", MonitorDomainNames.HelixCallback.name(), type.name(), clusterName,
          changeType.name());

  _latencyGauge = new HistogramDynamicMetric("LatencyGauge", new Histogram(
      new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _totalLatencyCounter = new SimpleDynamicMetric("LatencyCounter", 0l);
  _unbatchedCounter = new SimpleDynamicMetric("UnbatchedCounter", 0l);
  _counter = new SimpleDynamicMetric("Counter", 0l);
}
 
Example #5
Source File: StateTransitionStatMonitor.java    From helix with Apache License 2.0 6 votes vote down vote up
public StateTransitionStatMonitor(StateTransitionContext context, ObjectName objectName) {
  _context = context;
  _initObjectName = objectName;
  _attributeList = new ArrayList<>();
  _totalStateTransitionCounter = new SimpleDynamicMetric<>("TotalStateTransitionCounter", 0L);
  _totalFailedTransitionCounter = new SimpleDynamicMetric<>("TotalFailedTransitionCounter", 0L);
  _totalSuccessTransitionCounter = new SimpleDynamicMetric<>("TotalSuccessTransitionCounter", 0L);

  _transitionLatencyGauge = new HistogramDynamicMetric("TransitionLatencyGauge", new Histogram(
      new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _transitionExecutionLatencyGauge = new HistogramDynamicMetric("TransitionExecutionLatencyGauge",
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _transitionMessageLatency = new HistogramDynamicMetric("TransitionMessageLatencyGauge",
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
}
 
Example #6
Source File: DynamicMetricsManager.java    From brooklin with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private synchronized Histogram registerAndGetSlidingWindowHistogram(String fullMetricName, long windowTimeMs) {
  Histogram histogram = new Histogram(new SlidingTimeWindowArrayReservoir(windowTimeMs, TimeUnit.MILLISECONDS));
  try {
    return _metricRegistry.register(fullMetricName, histogram);
  } catch (IllegalArgumentException e) {
    // This could happen when multiple threads call createOrUpdateSlidingWindowHistogram simultaneously
    // In that case the line below will just return the one that got registered first.
    return _metricRegistry.histogram(fullMetricName);
  }
}
 
Example #7
Source File: RebalanceLatencyGauge.java    From helix with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new Histogram dynamic metric.
 * @param metricName the metric name
 */
public RebalanceLatencyGauge(String metricName, long slidingTimeWindow) {
  super(metricName, new Histogram(
      new SlidingTimeWindowArrayReservoir(slidingTimeWindow, TimeUnit.MILLISECONDS)));
  _metricName = metricName;
  _startTime = ThreadLocal.withInitial(() -> VALUE_NOT_SET);
}
 
Example #8
Source File: JobMonitor.java    From helix with Apache License 2.0 5 votes vote down vote up
public JobMonitor(String clusterName, String jobType, ObjectName objectName) {
  _clusterName = clusterName;
  _jobType = jobType;
  _initObjectName = objectName;
  _lastResetTime = System.currentTimeMillis();

  // Instantiate simple dynamic metrics
  _successfulJobCount = new SimpleDynamicMetric("SuccessfulJobCount", 0L);
  _failedJobCount = new SimpleDynamicMetric("FailedJobCount", 0L);
  _abortedJobCount = new SimpleDynamicMetric("AbortedJobCount", 0L);
  _existingJobGauge = new SimpleDynamicMetric("ExistingJobGauge", 0L);
  _queuedJobGauge = new SimpleDynamicMetric("QueuedJobGauge", 0L);
  _runningJobGauge = new SimpleDynamicMetric("RunningJobGauge", 0L);
  _maximumJobLatencyGauge = new SimpleDynamicMetric("MaximumJobLatencyGauge", 0L);
  _jobLatencyCount = new SimpleDynamicMetric("JobLatencyCount", 0L);

  // Instantiate histogram dynamic metrics
  _jobLatencyGauge = new HistogramDynamicMetric("JobLatencyGauge", new Histogram(
      new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _submissionToProcessDelayGauge = new HistogramDynamicMetric("SubmissionToProcessDelayGauge",
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _submissionToScheduleDelayGauge = new HistogramDynamicMetric("SubmissionToScheduleDelayGauge",
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _controllerInducedDelayGauge = new HistogramDynamicMetric("ControllerInducedDelayGauge",
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
}
 
Example #9
Source File: MessageLatencyMonitor.java    From helix with Apache License 2.0 5 votes vote down vote up
public MessageLatencyMonitor(String domainName, String participantName) throws JMException {
  _domainName = domainName;
  _participantName = participantName;
  _sensorName = String.format("%s.%s", ParticipantMessageMonitor.PARTICIPANT_STATUS_KEY,
      "MessageLatency");

  _messageLatencyGauge = new HistogramDynamicMetric("MessagelatencyGauge", new Histogram(
      new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _totalMessageLatency = new SimpleDynamicMetric("TotalMessageLatency", 0l);
  _totalMessageCount = new SimpleDynamicMetric("TotalMessageCount", 0l);
}
 
Example #10
Source File: ClusterEventMonitor.java    From helix with Apache License 2.0 5 votes vote down vote up
public ClusterEventMonitor(ClusterStatusMonitor clusterStatusMonitor, String phaseName) {
  _phaseName = phaseName;
  _clusterStatusMonitor = clusterStatusMonitor;

  _duration = new HistogramDynamicMetric("DurationGauge", new Histogram(
      new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _count = new SimpleDynamicMetric("EventCounter", 0l);
  _maxDuration = new SimpleDynamicMetric("MaxSingleDurationGauge", 0l);
  _totalDuration = new SimpleDynamicMetric("TotalDurationCounter", 0l);
}
 
Example #11
Source File: ClusterEventMonitor.java    From helix with Apache License 2.0 5 votes vote down vote up
public ClusterEventMonitor(ClusterStatusMonitor clusterStatusMonitor, String phaseName,
    int histogramTimeWindowMs) {
  _phaseName = phaseName;
  _clusterStatusMonitor = clusterStatusMonitor;

  _duration = new HistogramDynamicMetric("DurationGauge", new Histogram(
      new SlidingTimeWindowArrayReservoir(histogramTimeWindowMs, TimeUnit.MILLISECONDS)));
  _count = new SimpleDynamicMetric("EventCounter", 0l);
  _maxDuration = new SimpleDynamicMetric("MaxSingleDurationGauge", 0l);
  _totalDuration = new SimpleDynamicMetric("TotalDurationCounter", 0l);
}
 
Example #12
Source File: MetricSuppliers.java    From feign with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Histogram> histograms() {
  // only keep timer data for 1 minute
  return () -> new Histogram(new SlidingTimeWindowArrayReservoir(1, TimeUnit.MINUTES));
}
 
Example #13
Source File: SignalFxEndpointMetricsHandler.java    From riposte with Apache License 2.0 4 votes vote down vote up
@Override
public Timer newMetric() {
    return new Timer(new SlidingTimeWindowArrayReservoir(amount, timeUnit));
}
 
Example #14
Source File: MetricSuppliers.java    From feign with Apache License 2.0 4 votes vote down vote up
public MetricRegistry.MetricSupplier<Timer> timers() {
  // only keep timer data for 1 minute
  return () -> new Timer(new SlidingTimeWindowArrayReservoir(1, TimeUnit.MINUTES));
}
 
Example #15
Source File: ZkClientPathMonitor.java    From helix with Apache License 2.0 4 votes vote down vote up
public ZkClientPathMonitor(PredefinedPath path, String monitorType, String monitorKey,
    String monitorInstanceName) {
  _type = monitorType;
  _key = monitorKey;
  _instanceName = monitorInstanceName;
  _path = path;
  _sensorName = String
      .format("%s.%s.%s.%s", MonitorDomainNames.HelixZkClient.name(), monitorType, monitorKey,
          path.name());

  _writeTotalLatencyCounter =
      new SimpleDynamicMetric(PredefinedMetricDomains.WriteTotalLatencyCounter.name(), 0l);
  _readTotalLatencyCounter =
      new SimpleDynamicMetric(PredefinedMetricDomains.ReadTotalLatencyCounter.name(), 0l);
  _writeFailureCounter =
      new SimpleDynamicMetric(PredefinedMetricDomains.WriteFailureCounter.name(), 0l);
  _readFailureCounter =
      new SimpleDynamicMetric(PredefinedMetricDomains.ReadFailureCounter.name(), 0l);
  _writeBytesCounter =
      new SimpleDynamicMetric(PredefinedMetricDomains.WriteBytesCounter.name(), 0l);
  _readBytesCounter =
      new SimpleDynamicMetric(PredefinedMetricDomains.ReadBytesCounter.name(), 0l);
  _writeCounter = new SimpleDynamicMetric(PredefinedMetricDomains.WriteCounter.name(), 0l);
  _readCounter = new SimpleDynamicMetric(PredefinedMetricDomains.ReadCounter.name(), 0l);

  _readLatencyGauge = new HistogramDynamicMetric(PredefinedMetricDomains.ReadLatencyGauge.name(),
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _writeLatencyGauge =
      new HistogramDynamicMetric(PredefinedMetricDomains.WriteLatencyGauge.name(), new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _readBytesGauge = new HistogramDynamicMetric(PredefinedMetricDomains.ReadBytesGauge.name(),
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _writeBytesGauge = new HistogramDynamicMetric(PredefinedMetricDomains.WriteBytesGauge.name(),
      new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _dataPropagationLatencyGauge =
      new HistogramDynamicMetric(PredefinedMetricDomains.DataPropagationLatencyGauge.name(),
          new Histogram(new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(),
              TimeUnit.MILLISECONDS)));

  // This is deprecated and keep it for backward-compatibility purpose.
  _dataPropagationLatencyGuage =
      new HistogramDynamicMetric(PredefinedMetricDomains.DataPropagationLatencyGuage.name(),
          new Histogram(new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(),
              TimeUnit.MILLISECONDS)));
}
 
Example #16
Source File: ResourceMonitor.java    From helix with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public ResourceMonitor(String clusterName, String resourceName, ObjectName objectName)
    throws JMException {
  _clusterName = clusterName;
  _resourceName = resourceName;
  _initObjectName = objectName;
  _dynamicCapacityMetricsMap = new ConcurrentHashMap<>();

  _externalViewIdealStateDiff = new SimpleDynamicMetric("DifferenceWithIdealStateGauge", 0L);
  _numLoadRebalanceThrottledPartitions =
      new SimpleDynamicMetric("LoadRebalanceThrottledPartitionGauge", 0L);
  _numRecoveryRebalanceThrottledPartitions =
      new SimpleDynamicMetric("RecoveryRebalanceThrottledPartitionGauge", 0L);
  _numPendingLoadRebalancePartitions =
      new SimpleDynamicMetric("PendingLoadRebalancePartitionGauge", 0L);
  _numPendingRecoveryRebalancePartitions =
      new SimpleDynamicMetric("PendingRecoveryRebalancePartitionGauge", 0L);
  _numLessReplicaPartitions = new SimpleDynamicMetric("MissingReplicaPartitionGauge", 0L);
  _numLessMinActiveReplicaPartitions =
      new SimpleDynamicMetric("MissingMinActiveReplicaPartitionGauge", 0L);
  _numNonTopStatePartitions = new SimpleDynamicMetric("MissingTopStatePartitionGauge", 0L);
  _numOfErrorPartitions = new SimpleDynamicMetric("ErrorPartitionGauge", 0L);
  _numOfPartitionsInExternalView = new SimpleDynamicMetric("ExternalViewPartitionGauge", 0L);
  _numOfPartitions = new SimpleDynamicMetric("PartitionGauge", 0L);
  _numPendingStateTransitions = new SimpleDynamicMetric("PendingStateTransitionGauge", 0L);

  _partitionTopStateHandoffDurationGauge =
      new HistogramDynamicMetric("PartitionTopStateHandoffDurationGauge", new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));

  _partitionTopStateHandoffHelixLatencyGauge =
      new HistogramDynamicMetric("PartitionTopStateHandoffHelixLatencyGauge", new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));
  _partitionTopStateNonGracefulHandoffDurationGauge =
      new HistogramDynamicMetric("PartitionTopStateNonGracefulHandoffGauge", new Histogram(
          new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS)));

  _totalMessageReceived = new SimpleDynamicMetric("TotalMessageReceived", 0L);
  _maxSinglePartitionTopStateHandoffDuration =
      new SimpleDynamicMetric("MaxSinglePartitionTopStateHandoffDurationGauge", 0L);
  _failedTopStateHandoffCounter = new SimpleDynamicMetric("FailedTopStateHandoffCounter", 0L);
  _successTopStateHandoffCounter = new SimpleDynamicMetric("SucceededTopStateHandoffCounter", 0L);
  _successfulTopStateHandoffDurationCounter =
      new SimpleDynamicMetric("SuccessfulTopStateHandoffDurationCounter", 0L);

  _rebalanceState = new SimpleDynamicMetric<>("RebalanceStatus", RebalanceStatus.UNKNOWN.name());
}
 
Example #17
Source File: SemanticStatisticsModule.java    From heroic with Apache License 2.0 4 votes vote down vote up
@Provides
@SemanticStatisticsScope
public SemanticMetricRegistry registry() {
    return new SemanticMetricRegistry(
        () -> new SlidingTimeWindowArrayReservoir(60, TimeUnit.SECONDS));
}
 
Example #18
Source File: MetricsCatcher.java    From micro-server with Apache License 2.0 4 votes vote down vote up
private Timer timer (String name) {
    return registry.timer(name, () -> new Timer(new SlidingTimeWindowArrayReservoir(configuration.getTimerIntervalSeconds(), TimeUnit.SECONDS)));
}
 
Example #19
Source File: SignalFxEndpointMetricsHandler.java    From riposte with Apache License 2.0 4 votes vote down vote up
@Override
public Histogram newMetric() {
    return new Histogram(new SlidingTimeWindowArrayReservoir(amount, timeUnit));
}