Number requestCounts = timingInfo.getCounter(RequestCount.name()); Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name()); Number throttleExceptions = timingInfo.getCounter(ThrottleException.name()); TimingInfo requestTime = timingInfo.getSubMeasurement(HttpRequestTime.name()); TimingInfo clientExecuteTime = timingInfo.getSubMeasurement(ClientExecuteTime.name());
Number counter = ti.getCounter(Field.RequestCount.name()); if (counter == null) {
protected List<MetricDatum> metricOfCount( Field metricType, Request<?> req, Object resp) { AWSRequestMetrics m = req.getAWSRequestMetrics(); TimingInfo ti = m.getTimingInfo(); Number counter = ti.getCounter(metricType.name()); if (counter == null) { return Collections.emptyList(); } final double count = counter.doubleValue(); if (count < 1) { return Collections.emptyList(); } else { return Collections.singletonList(new MetricDatum() .withMetricName(req.getServiceName()) .withDimensions(new Dimension() .withName(Dimensions.MetricType.name()) .withValue(metricType.name())) .withUnit(StandardUnit.Count) .withValue(Double.valueOf(count)) .withTimestamp(endTimestamp(ti))) ; } }
TimingInfo ti = m.getTimingInfo(); final String metricName = type.name(); Number counter = ti.getCounter(metricName); if (counter == null) { return Collections.emptyList();
requestCount = timingInfo.getCounter(AWSRequestMetrics.Field.RequestCount.name()) == null ? 0 : timingInfo.getCounter(AWSRequestMetrics.Field.RequestCount.name()).intValue();
/** * Verifies the request is actually retried for the expected times. */ private static void testActualRetries(int expectedRetryAttempts) { // The ExecutionContext should collect the expected RequestCount ExecutionContext context = new ExecutionContext(true); try { testedClient.execute(getSampleRequestWithRepeatableContent(originalRequest), null, errorResponseHandler, context); Assert.fail("AmazonServiceException is expected."); } catch (AmazonServiceException ase) { } // Check the RequestCount metric equals the expected value. Assert.assertEquals( expectedRetryAttempts + 1, // request count = retries + 1 context.getAwsRequestMetrics() .getTimingInfo() .getCounter(AWSRequestMetrics.Field.RequestCount.toString()).intValue()); } }
context.getAwsRequestMetrics() .getTimingInfo() .getCounter(AWSRequestMetrics.Field.RequestCount.toString()).intValue());
context.getAwsRequestMetrics() .getTimingInfo() .getCounter(AWSRequestMetrics.Field.RequestCount.toString()).intValue());
context.getAwsRequestMetrics() .getTimingInfo() .getCounter(AWSRequestMetrics.Field.RequestCount.toString()).intValue());
context.getAwsRequestMetrics() .getTimingInfo() .getCounter(AWSRequestMetrics.Field.RequestCount.toString()).intValue());
context.getAwsRequestMetrics() .getTimingInfo() .getCounter(AWSRequestMetrics.Field.RequestCount.toString()).intValue());
requestCount = timingInfo.getCounter(AWSRequestMetrics.Field.RequestCount.name()) == null ? 0 : timingInfo.getCounter(AWSRequestMetrics.Field.RequestCount.name()).intValue();
@Override public void collectMetrics(Request<?> request, Response<?> response) { final AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (metrics.isEnabled()) { final Map<String, String> allTags = getAllTags(request); final TimingInfo timing = metrics.getTimingInfo(); for (Field counter : COUNTERS) { Optional.ofNullable(timing.getCounter(counter.name())) .filter(v -> v.longValue() > 0) .ifPresent(v -> registry.counter(metricId(counter, allTags)).increment(v.longValue())); } for (Field timer : TIMERS) { Optional.ofNullable(timing.getLastSubMeasurement(timer.name())) .filter(TimingInfo::isEndTimeKnown) .ifPresent(t -> registry.timer(metricId(timer, allTags)) .record(t.getEndTimeNano() - t.getStartTimeNano(), TimeUnit.NANOSECONDS)); } notEmpty(metrics.getProperty(Field.ThrottleException)).ifPresent(throttleExceptions -> { final Id throttling = metricId("throttling", allTags); throttleExceptions.forEach(ex -> registry.counter(throttling.withTag(TAG_THROTTLE_EXCEPTION, ex.getClass().getSimpleName())).increment()); }); } }
@Override public void collectMetrics(Request<?> request, Response<?> response) { final AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (metrics.isEnabled()) { final Map<String, String> allTags = getAllTags(request); final TimingInfo timing = metrics.getTimingInfo(); for (Field counter : COUNTERS) { Optional.ofNullable(timing.getCounter(counter.name())) .filter(v -> v.longValue() > 0) .ifPresent(v -> registry.counter(metricId(counter, allTags)).increment(v.longValue())); } for (Field timer : TIMERS) { Optional.ofNullable(timing.getLastSubMeasurement(timer.name())) .filter(TimingInfo::isEndTimeKnown) .ifPresent(t -> registry.timer(metricId(timer, allTags)) .record(t.getEndTimeNano() - t.getStartTimeNano(), TimeUnit.NANOSECONDS)); } notEmpty(metrics.getProperty(Field.ThrottleException)).ifPresent(throttleExceptions -> { final Id throttling = metricId("throttling", allTags); throttleExceptions.forEach(ex -> registry.counter(throttling.withTag(TAG_THROTTLE_EXCEPTION, ex.getClass().getSimpleName())).increment()); }); } }
Number counter = ti.getCounter(Field.RequestCount.name()); if (counter == null) {
Number requestCounts = timingInfo.getCounter(RequestCount.name()); Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name()); Number throttleExceptions = timingInfo.getCounter(ThrottleException.name()); TimingInfo requestTime = timingInfo.getSubMeasurement(HttpRequestTime.name()); TimingInfo clientExecuteTime = timingInfo.getSubMeasurement(ClientExecuteTime.name());
Number requestCounts = timingInfo.getCounter(RequestCount.name()); Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name()); Number throttleExceptions = timingInfo.getCounter(ThrottleException.name()); TimingInfo requestTime = timingInfo.getSubMeasurement(HttpRequestTime.name()); TimingInfo clientExecuteTime = timingInfo.getSubMeasurement(ClientExecuteTime.name());
protected List<MetricDatum> metricOfCount( Field metricType, Request<?> req, Object resp) { AWSRequestMetrics m = req.getAWSRequestMetrics(); TimingInfo ti = m.getTimingInfo(); Number counter = ti.getCounter(metricType.name()); if (counter == null) { return Collections.emptyList(); } final double count = counter.doubleValue(); if (count < 1) { return Collections.emptyList(); } else { return Collections.singletonList(new MetricDatum() .withMetricName(req.getServiceName()) .withDimensions(new Dimension() .withName(Dimensions.MetricType.name()) .withValue(metricType.name())) .withUnit(StandardUnit.Count) .withValue(Double.valueOf(count)) .withTimestamp(endTimestamp(ti))) ; } }
TimingInfo ti = m.getTimingInfo(); final String metricName = type.name(); Number counter = ti.getCounter(metricName); if (counter == null) { return Collections.emptyList();