private ApiCallMonitoringEvent generateApiCallMonitoringEvent(Request<?> request, Exception e) { ApiCallMonitoringEvent event = generateApiCallMonitoringEvent(request); AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (e instanceof ClientExecutionTimeoutException) { event.withApiCallTimeout(1); } if (metrics != null && !CollectionUtils.isNullOrEmpty(metrics.getProperty(MaxRetriesExceeded))) { boolean maxRetriesExceeded = (Boolean) metrics.getProperty(MaxRetriesExceeded).get(0); event.withMaxRetriesExceeded(maxRetriesExceeded ? 1 : 0); } return event; }
private ApiCallMonitoringEvent generateApiCallMonitoringEvent(Request<?> request, Exception e) { ApiCallMonitoringEvent event = generateApiCallMonitoringEvent(request); AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (e instanceof ClientExecutionTimeoutException) { event.withApiCallTimeout(1); } if (metrics != null && !CollectionUtils.isNullOrEmpty(metrics.getProperty(MaxRetriesExceeded))) { boolean maxRetriesExceeded = (Boolean) metrics.getProperty(MaxRetriesExceeded).get(0); event.withMaxRetriesExceeded(maxRetriesExceeded ? 1 : 0); } return event; }
Optional<String> getValue(AWSRequestMetrics metrics) { return firstValue(metrics.getProperty(field), tagExtractor); } }
Optional<String> getValue(AWSRequestMetrics metrics) { return firstValue(metrics.getProperty(field), tagExtractor); } }
@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()); }); } }