public enum AwsSdkMetrics extends Enum<AwsSdkMetrics>
The default request metric collection of the Java AWS SDK is disabled by
default. To enable it, simply specify the system property
"com.amazonaws.sdk.enableDefaultMetrics" when starting up the JVM.
When the system property is specified, a default metric collector will be
started at the AWS SDK level. The default implementation uploads the
request/response metrics captured to Amazon CloudWatch using AWS credentials
obtained via the DefaultAWSCredentialsProviderChain
.
Instead of via system properties, the default AWS SDK metric collection can
also be enabled programmatically via enableDefaultMetrics()
.
Similarly, metric collection at the AWS SDK level can be disabled via
disableMetrics()
.
Clients who needs to fully customize the metric collection can implement the
SPI MetricCollector
, and then replace the default AWS SDK
implementation of the collector via
setMetricCollector(MetricCollector)
.
Alternatively, for limited customization of the internal collector implementation provided by the AWS SDK, one can extend the internal Amazon CloudWatch request metric collector. See the javadoc at com.amazonaws.metrics.internal.cloudwatch.CloudWatchMetricConfig for more details.
Modifier and Type | Class and Description |
---|---|
static interface |
AwsSdkMetrics.AdminMBean
MBean interface for AwsSdkMetrics administration.
|
Modifier and Type | Field and Description |
---|---|
static String |
AWS_CREDENTAIL_PROPERTIES_FILE |
static String |
CLOUDWATCH_REGION |
static String |
EXCLUDE_MACHINE_METRICS
Used to exclude the generation of JVM metrics when the AWS SDK default
metrics is enabled when starting up the JVM.
|
static String |
METRIC_QUEUE_SIZE |
static String |
METRICS_NAMESPACE |
static String |
QUEUE_POLL_TIMEOUT_MILLI |
Modifier and Type | Method and Description |
---|---|
static boolean |
add(MetricType type)
Adds the given metric type to the registry of predefined metrics to be
captured at the AWS SDK level.
|
static <T extends MetricType> |
addAll(Collection<T> types)
Adds the given metric types to the registry of predefined metrics to be
captured at the AWS SDK level.
|
static void |
disableMetrics()
Convenient method to disable the request metric collector at the AWS SDK
level.
|
static boolean |
enableDefaultMetrics()
Starts the default AWS SDK request metric collector, but
only if no request metric collector is currently in use at the AWS SDK
level.
|
static AWSCredentialsProvider |
getCredentialProvider()
Returns the credential provider for the default AWS SDK metric implementation.
|
static <T extends MetricCollector> |
getMetricCollector() |
static Integer |
getMetricQueueSize()
Returns the internal metric queue size to be used for the default AWS SDK
metric collector; or null if the default is to be used.
|
static Set<MetricType> |
getPredefinedMetrics()
Returns an unmodifiable set of the current predefined metrics.
|
static Long |
getQueuePollTimeoutMilli()
Returns the internal metric queue timeout in millisecond to be used for
the default AWS SDK metric collector; or null if the default is to be
used.
|
static Regions |
getRegion()
Returns the region configured for the default AWS SDK metric collector;
or null if the default is to be used.
|
static <T extends RequestMetricCollector> |
getRequestMetricCollector()
Returns a non-null request metric collector for the SDK.
|
static <T extends ServiceMetricCollector> |
getServiceMetricCollector() |
static boolean |
isDefaultMetricsEnabled()
Returns true if the system property
SDKGlobalConfiguration.DEFAULT_METRICS_SYSTEM_PROPERTY has been
set; false otherwise. |
static boolean |
isMachineMetricExcluded()
Returns true if machine metrics is to be excluded.
|
static boolean |
isMetricsEnabled()
Returns true if metrics at the AWS SDK level is enabled; false
if disabled.
|
static boolean |
remove(MetricType type)
Removes the given metric type from the registry of predefined metrics to
be captured at the AWS SDK level.
|
static <T extends MetricType> |
set(Collection<T> types)
Sets the given metric types to replace the registry of predefined metrics
to be captured at the AWS SDK level.
|
static void |
setCredentialProvider(AWSCredentialsProvider provider)
Sets the credential provider for the default AWS SDK metric implementation;
or null if the default is to be used.
|
static void |
setMachineMetricsExcluded(boolean excludeMachineMetrics)
Used to set whether the machine metrics is to be excluded.
|
static void |
setMetricCollector(MetricCollector mc)
Sets the request metric collector to be used by the AWS SDK, and stop the
previously running collector used by the AWS SDK, if any.
|
static void |
setMetricQueueSize(Integer size)
Sets the metric queue size to be used for the default AWS SDK metric collector;
or null if the default is to be used.
|
static void |
setQueuePollTimeoutMilli(Long timeoutMilli)
Sets the queue poll time in millisecond to be used for the default AWS
SDK metric collector; or null if the default is to be used.
|
static void |
setRegion(Regions region)
Sets the region to be used for the default AWS SDK metric collector;
or null if the default is to be used.
|
static AwsSdkMetrics |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static AwsSdkMetrics[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final String METRICS_NAMESPACE
public static final String EXCLUDE_MACHINE_METRICS
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=excludeJvmMetrics
public static final String AWS_CREDENTAIL_PROPERTIES_FILE
public static final String CLOUDWATCH_REGION
public static final String METRIC_QUEUE_SIZE
public static final String QUEUE_POLL_TIMEOUT_MILLI
public static AwsSdkMetrics[] values()
for (AwsSdkMetrics c : AwsSdkMetrics.values()) System.out.println(c);
public static AwsSdkMetrics valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant
with the specified nameNullPointerException
- if the argument is nullpublic static <T extends RequestMetricCollector> T getRequestMetricCollector()
setMetricCollector(MetricCollector)
and the
SDKGlobalConfiguration.DEFAULT_METRICS_SYSTEM_PROPERTY
has been set, then this method
will initialize and return the default metric collector provided by the
AWS SDK on a best-attempt basis.public static <T extends ServiceMetricCollector> T getServiceMetricCollector()
public static <T extends MetricCollector> T getMetricCollector()
public static void setMetricCollector(MetricCollector mc)
Caller of this method is responsible for starting the new request metric collector specified as the input parameter.
mc
- the request metric collector to be used by the AWS SDK; or
null if no request metric collection is to be performed
at the AWS SDK level.RequestMetricCollector
,
RequestMetricCollector.NONE
public static void setMachineMetricsExcluded(boolean excludeMachineMetrics)
excludeMachineMetrics
- true if machine metrics is to be excluded;
false otherwise.public static boolean isDefaultMetricsEnabled()
SDKGlobalConfiguration.DEFAULT_METRICS_SYSTEM_PROPERTY
has been
set; false otherwise.public static boolean isMetricsEnabled()
public static boolean isMachineMetricExcluded()
public static boolean enableDefaultMetrics()
public static void disableMetrics()
public static boolean add(MetricType type)
public static <T extends MetricType> boolean addAll(Collection<T> types)
public static <T extends MetricType> void set(Collection<T> types)
public static boolean remove(MetricType type)
public static Set<MetricType> getPredefinedMetrics()
public static AWSCredentialsProvider getCredentialProvider()
SecurityException
- if called outside the default AWS SDK metric implementation.public static void setCredentialProvider(AWSCredentialsProvider provider)
public static Regions getRegion()
public static void setRegion(Regions region)
public static Integer getMetricQueueSize()
public static void setMetricQueueSize(Integer size)
public static Long getQueuePollTimeoutMilli()
public static void setQueuePollTimeoutMilli(Long timeoutMilli)
Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.