类com.codahale.metrics.SlidingTimeWindowArrayReservoir源码实例Demo

下面列出了怎么用com.codahale.metrics.SlidingTimeWindowArrayReservoir的API类实例代码及写法,或者点击链接到github查看源代码。

@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);
}
 
@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);
}
 
源代码3 项目: helix   文件: RoutingTableProviderMonitor.java
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)));
  }
}
 
源代码4 项目: helix   文件: HelixCallbackMonitor.java
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);
}
 
源代码5 项目: helix   文件: StateTransitionStatMonitor.java
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)));
}
 
源代码6 项目: brooklin   文件: DynamicMetricsManager.java
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);
  }
}
 
源代码7 项目: helix   文件: RebalanceLatencyGauge.java
/**
 * 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);
}
 
源代码8 项目: helix   文件: JobMonitor.java
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)));
}
 
源代码9 项目: helix   文件: MessageLatencyMonitor.java
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);
}
 
源代码10 项目: helix   文件: ClusterEventMonitor.java
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);
}
 
源代码11 项目: helix   文件: ClusterEventMonitor.java
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);
}
 
源代码12 项目: riposte   文件: SignalFxEndpointMetricsHandler.java
@Override
public Timer newMetric() {
    return new Timer(new SlidingTimeWindowArrayReservoir(amount, timeUnit));
}
 
源代码13 项目: riposte   文件: SignalFxEndpointMetricsHandler.java
@Override
public Histogram newMetric() {
    return new Histogram(new SlidingTimeWindowArrayReservoir(amount, timeUnit));
}
 
源代码14 项目: micro-server   文件: MetricsCatcher.java
private Timer timer (String name) {
    return registry.timer(name, () -> new Timer(new SlidingTimeWindowArrayReservoir(configuration.getTimerIntervalSeconds(), TimeUnit.SECONDS)));
}
 
源代码15 项目: heroic   文件: SemanticStatisticsModule.java
@Provides
@SemanticStatisticsScope
public SemanticMetricRegistry registry() {
    return new SemanticMetricRegistry(
        () -> new SlidingTimeWindowArrayReservoir(60, TimeUnit.SECONDS));
}
 
源代码16 项目: helix   文件: ResourceMonitor.java
@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());
}
 
源代码17 项目: helix   文件: ZkClientPathMonitor.java
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)));
}
 
源代码18 项目: feign   文件: MetricSuppliers.java
public MetricRegistry.MetricSupplier<Timer> timers() {
  // only keep timer data for 1 minute
  return () -> new Timer(new SlidingTimeWindowArrayReservoir(1, TimeUnit.MINUTES));
}
 
源代码19 项目: feign   文件: MetricSuppliers.java
public MetricRegistry.MetricSupplier<Histogram> histograms() {
  // only keep timer data for 1 minute
  return () -> new Histogram(new SlidingTimeWindowArrayReservoir(1, TimeUnit.MINUTES));
}
 
 类所在包
 同包方法