void reportMetrics() { if (getByteCount() > 0) { ServiceMetricCollector col = AwsSdkMetrics.getServiceMetricCollector(); col.collectByteThroughput(this); reset(); } }
public static <T extends ServiceMetricCollector> T getServiceMetricCollector() { if (mc == null) { if (isDefaultMetricsEnabled()) enableDefaultMetrics(); } @SuppressWarnings("unchecked") T t = (T)(mc == null ? ServiceMetricCollector.NONE : mc.getServiceMetricCollector()); return t; }
/** * Returns true if metrics at the AWS SDK level is enabled; false * if disabled. */ public static boolean isMetricsEnabled() { MetricCollector mc = AwsSdkMetrics.mc; return mc != null && mc.isEnabled(); }
@Override public int read(byte b[], int off, int len) throws IOException { abortIfNeeded(); long startNano = helper.startTiming(); int bytesRead = in.read(b, off, len); if (bytesRead > 0) { helper.increment(bytesRead, startNano); } return bytesRead; }
public static <T extends MetricCollector> T getMetricCollector() { if (mc == null) { if (isDefaultMetricsEnabled()) enableDefaultMetrics(); } @SuppressWarnings("unchecked") T t = (T)(mc == null ? MetricCollector.NONE : mc); return t; }
/** * Convenient method to disable the metric collector at the AWS SDK * level. */ public static void disableMetrics() { setMetricCollector(MetricCollector.NONE); }
/** * Returns the client specific request metric collector if there is one; or the one at the AWS * SDK level otherwise. */ private RequestMetricCollector requestMetricCollector() { return clientLevelMetricCollector != null ? clientLevelMetricCollector : AwsSdkMetrics.getRequestMetricCollector(); }
/** * Sets the AWS credential file to be used for accessing Amazon CloudWatch. * Successfully calling this method would result in the AWS credential * provider to make use of the given credential file. */ public static void setCredentialFile(String filepath) throws FileNotFoundException, IOException { setCredentialFile0(filepath); }
@Override public void increment(int bytesDelta, long startTimeNano) { super.increment(bytesDelta, startTimeNano); } }
/** * Adds the given metric type to the registry of predefined metrics to be * captured at the AWS SDK level. * * @return true if the set of predefined metric types gets changed as a * result of the call */ public static boolean add(MetricType type) { return type == null ? false : registry.addMetricType(type); } /**
/** * Sets the given metric types to replace the registry of predefined metrics * to be captured at the AWS SDK level. */ public static <T extends MetricType> void set(Collection<T> types) { registry.setMetricTypes(types); } /**
/** * Removes the given metric type from the registry of predefined metrics to * be captured at the AWS SDK level. * * @return true if the set of predefined metric types gets changed as a * result of the call */ public static boolean remove(MetricType type) { return type == null ? false : registry.removeMetricType(type); } /**
@Override public boolean isMachineMetricsExcluded() { return AwsSdkMetrics.isMachineMetricExcluded(); } @Override
@Override public void disableMetrics() { AwsSdkMetrics.disableMetrics(); } @Override
@Override public void setMachineMetricsExcluded(boolean excludeJvmMetrics) { AwsSdkMetrics.setMachineMetricsExcluded(excludeJvmMetrics); } @Override
@Override public boolean isSingleMetricNamespace() { return AwsSdkMetrics.isSingleMetricNamespace(); } @Override
@Override public String getMetricNameSpace() { return AwsSdkMetrics.getMetricNameSpace(); } @Override
@Override public void setPerHostMetricsIncluded(boolean includePerHostMetrics) { AwsSdkMetrics.setPerHostMetricsIncluded(includePerHostMetrics); } @Override
@Override public void setMetricQueueSize(Integer metricQueueSize) { AwsSdkMetrics.setMetricQueueSize(metricQueueSize); } @Override
@Override public void setSingleMetricNamespace(boolean singleMetricNamespace) { AwsSdkMetrics.setSingleMetricNamespace(singleMetricNamespace); } }