public enum AwsSdkMetrics extends Enum<AwsSdkMetrics>
The default 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
.
By default, the metrics are uploaded to the us-east-1 region. You can change the region by changing the system property as -Dcom.amazonaws.sdk.enableDefaultMetrics=cloudwatchRegion={newregion} See #CLOUDWATCH_REGION
For additional optional attributes that can be specified for the system property, please read the javadoc of the individual fields of this class for more details.
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 metric collector. See the javadoc at com.amazonaws.metrics.internal.cloudwatch.CloudWatchMetricConfig for more details.
Modifier and Type | Field and Description |
---|---|
static String |
AWS_CREDENTAIL_PROPERTIES_FILE
Deprecated.
in favor of
AWS_CREDENTIAL_PROPERTIES_FILE |
static String |
AWS_CREDENTIAL_PROPERTIES_FILE
Used to specify an AWS credential property file.
|
static String |
CLOUDWATCH_REGION
Used to specify the Amazon CloudWatch region for metrics uploading purposes.
|
static String |
DEFAULT_METRIC_NAMESPACE |
static String |
EXCLUDE_MACHINE_METRICS
Used to exclude the generation of JVM metrics when the AWS SDK default
metrics is enabled.
|
static String |
HOST_METRIC_NAME
Used to explicitly specify the host name for metric purposes, instead of
detecting the host name via
InetAddress when the AWS SDK default
metrics is enabled. |
static String |
INCLUDE_PER_HOST_METRICS
Used to generate per host level metrics when the AWS SDK default
metrics is enabled.
|
static String |
JVM_METRIC_NAME
Used to generate per JVM level metrics when the AWS SDK default
metrics is enabled.
|
static String |
METRIC_NAME_SPACE
Used to specify a custom metric name space.
|
static String |
METRIC_QUEUE_SIZE
Used to specify the internal in-memory queue size for queuing metrics
data points.
|
static String |
QUEUE_POLL_TIMEOUT_MILLI
Used to specify the internal queue polling timeout in millisecond.
|
static String |
USE_SINGLE_METRIC_NAMESPACE
Used to enable the use of a single metric namespace for all levels of SDK
generated CloudWatch metrics such as JVM level, host level, etc.
|
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 metric collector at the AWS SDK
level.
|
static boolean |
enableDefaultMetrics()
Starts the default AWS SDK metric collector, but
only if no metric collector is currently in use at the AWS SDK
level.
|
static void |
enableHttpSocketReadMetric()
Used to enable
AWSRequestMetrics.Field.HttpSocketReadTime metric since by default it is disabled. |
static String |
getCredentailFile()
Returns the last set AWS credential file, or null if there is none.
|
static AWSCredentialsProvider |
getCredentialProvider()
Returns the credential provider for the default AWS SDK metric implementation.
|
static String |
getHostMetricName()
Returns the host name for generating per-host level metrics; or
null or blank if the host is to be automatically detected via
InetAddress . |
static String |
getJvmMetricName()
Returns the name of the JVM for generating per-JVM level metrics;
or null or blank if per-JVM level metrics are disabled.
|
static <T extends MetricCollector> |
getMetricCollector() |
static String |
getMetricNameSpace()
Returns the metric name space, which is never null or blank.
|
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()
Deprecated.
Use
getRegionName() |
static String |
getRegionName()
Returns the region name configured for the default AWS SDK metric collector;
or null if the default is to be used.
|
static String |
getRegisteredAdminMbeanName()
Returns the name of the registered admin mbean; or null if the admin
mbean is not currently registered.
|
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 |
isHttpSocketReadMetricEnabled()
Returns true if HttpSocketReadMetric is enabled; false otherwise.
|
static boolean |
isMachineMetricExcluded()
Returns true if machine metrics is to be excluded.
|
static boolean |
isMetricAdminMBeanRegistered()
Returns true if the metric admin MBean is currently registered for JMX
access; false otherwise.
|
static boolean |
isMetricsEnabled()
Returns true if metrics at the AWS SDK level is enabled; false
if disabled.
|
static boolean |
isPerHostMetricEnabled()
Returns true if per-host metrics is enabled; false otherwise.
|
static boolean |
isPerHostMetricIncluded()
Returns true if the per-host metrics flag has been set; false otherwise.
|
static boolean |
isSingleMetricNamespace()
Returns true if a single metric name space is to be used for all
levels of SDK generated CloudWatch metrics, including JVM level, host
level, etc.; false otherwise.
|
static boolean |
registerMetricAdminMBean()
Registers the metric admin MBean for JMX access for the current
classloader.
|
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 |
setCredentialFile(String filepath)
Sets the AWS credential file to be used for accessing Amazon CloudWatch.
|
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 |
setHostMetricName(String hostMetricName)
Sets the host name for generating per-host level metrics.
|
static void |
setJvmMetricName(String jvmMetricName)
Sets the name of the JVM for generating per-JVM level metrics.
|
static void |
setMachineMetricsExcluded(boolean excludeMachineMetrics)
Used to set whether the machine metrics is to be excluded.
|
static void |
setMetricCollector(MetricCollector mc)
Sets the metric collector to be used by the AWS SDK, and stop the
previously running collector used by the AWS SDK, if any.
|
static void |
setMetricNameSpace(String metricNameSpace)
Sets the metric name space.
|
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 |
setPerHostMetricsIncluded(boolean includePerHostMetrics)
Used to set whether the per-host metrics is to be included.
|
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 void |
setRegion(String region)
Sets the region to be used for the default AWS SDK metric collector;
or null if the default is to be used.
|
static void |
setSingleMetricNamespace(boolean singleMetricNamespace)
Used to set whether a single metric name space is to be used for all
levels of SDK generated CloudWatch metrics, including JVM level, host
level, etc.
|
static boolean |
unregisterMetricAdminMBean()
Unregisters the metric admin MBean from JMX for the current classloader.
|
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 DEFAULT_METRIC_NAMESPACE
public static final String USE_SINGLE_METRIC_NAMESPACE
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=useSingleMetricNamespace
public static final String EXCLUDE_MACHINE_METRICS
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=excludeJvmMetrics
public static final String INCLUDE_PER_HOST_METRICS
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=includePerHostMetrics
public static final String AWS_CREDENTAIL_PROPERTIES_FILE
AWS_CREDENTIAL_PROPERTIES_FILE
DefaultAWSCredentialsProviderChain
is used.
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=credentialFile=/path/aws.properties
public static final String AWS_CREDENTIAL_PROPERTIES_FILE
DefaultAWSCredentialsProviderChain
is used.
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=credentialFile=/path/aws.properties
public static final String CLOUDWATCH_REGION
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=cloudwatchRegion=us-west-2
public static final String METRIC_QUEUE_SIZE
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=metricQueueSize=1000
public static final String QUEUE_POLL_TIMEOUT_MILLI
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=getQueuePollTimeoutMilli=60000
public static final String METRIC_NAME_SPACE
DEFAULT_METRIC_NAMESPACE
.
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=metricNameSpace=MyNameSpace
public static final String JVM_METRIC_NAME
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=jvmMetricName=Tomcat1
public static final String HOST_METRIC_NAME
InetAddress
when the AWS SDK default
metrics is enabled. Specifying the host name also has the side effecting
of enabling per host level metrics.
Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=hostMetricName=MyHost
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 boolean isMetricAdminMBeanRegistered()
public static String getRegisteredAdminMbeanName()
public static boolean registerMetricAdminMBean()
MBEAN_OBJECT_NAME
but with an
additional suffix in the format of "/public static boolean unregisterMetricAdminMBean()
public 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 metric collector specified as the input parameter.
mc
- the metric collector to be used by the AWS SDK; or
null if no 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 void setPerHostMetricsIncluded(boolean includePerHostMetrics)
includePerHostMetrics
- true if per-host metrics is to be included;
false otherwise.public static void enableHttpSocketReadMetric()
AWSRequestMetrics.Field.HttpSocketReadTime
metric since by default it is disabled.public static boolean isDefaultMetricsEnabled()
SDKGlobalConfiguration.DEFAULT_METRICS_SYSTEM_PROPERTY
has been
set; false otherwise.public static boolean isSingleMetricNamespace()
public static void setSingleMetricNamespace(boolean singleMetricNamespace)
singleMetricNamespace
- true if single metric name is to be used; false otherwise.public static boolean isMetricsEnabled()
public static boolean isMachineMetricExcluded()
public static boolean isPerHostMetricIncluded()
public static boolean isPerHostMetricEnabled()
public static boolean isHttpSocketReadMetricEnabled()
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() throws IllegalArgumentException
getRegionName()
IllegalArgumentException
- when using a region not included in
Regions
public static String getRegionName()
public static void setRegion(Regions region)
public static void setRegion(String region)
public static String getCredentailFile()
public static void setCredentialFile(String filepath) throws FileNotFoundException, IOException
FileNotFoundException
IOException
public static Integer getMetricQueueSize()
public static void setMetricQueueSize(Integer size)
public static Long getQueuePollTimeoutMilli()
public static void setQueuePollTimeoutMilli(Long timeoutMilli)
public static String getMetricNameSpace()
public static void setMetricNameSpace(String metricNameSpace)
metricNameSpace
- metric name space which must neither be null or blank.IllegalArgumentException
- if the specified metric name space is either null or blank.public static String getJvmMetricName()
public static void setJvmMetricName(String jvmMetricName)
jvmMetricName
- name of the JVM for generating per-JVM level metrics; or null
or blank if per-JVM level metrics are to be disabled.public static String getHostMetricName()
InetAddress
.public static void setHostMetricName(String hostMetricName)
hostMetricName
- host name for generating per-host level metrics; or
null or blank if the host is to be automatically detected via
InetAddress
.Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.