Enum AwsSdkMetrics
- All Implemented Interfaces:
Serializable
,Comparable<AwsSdkMetrics>
,java.lang.constant.Constable
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
.
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Deprecated.static final String
Used to specify an AWS credential property file.static final String
Used to specify the Amazon CloudWatch region for metrics uploading purposes.static final String
static final String
Used to exclude the generation of JVM metrics when the AWS SDK default metrics is enabled.static final String
Used to explicitly specify the host name for metric purposes, instead of detecting the host name viaInetAddress
when the AWS SDK default metrics is enabled.static final String
Used to generate per host level metrics when the AWS SDK default metrics is enabled.static final String
Used to generate per JVM level metrics when the AWS SDK default metrics is enabled.static final String
Used to specify a custom metric name space.static final String
Used to specify the internal in-memory queue size for queuing metrics data points.static final String
Used to specify the internal queue polling timeout in millisecond.static final String
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. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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>
booleanaddAll
(Collection<T> types) Adds the given metric types to the registry of predefined metrics to be captured at the AWS SDK level.static void
Convenient method to disable the metric collector at the AWS SDK level.static boolean
Starts the default AWS SDK metric collector, but only if no metric collector is currently in use at the AWS SDK level.static void
Used to enableAWSRequestMetrics.Field.HttpSocketReadTime
metric since by default it is disabled.static String
Returns the last set AWS credential file, or null if there is none.static AWSCredentialsProvider
Returns the credential provider for the default AWS SDK metric implementation.static String
Returns the host name for generating per-host level metrics; or null or blank if the host is to be automatically detected viaInetAddress
.static String
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>
Tstatic String
Returns the metric name space, which is never null or blank.static Integer
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> Returns an unmodifiable set of the current predefined metrics.static Long
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
Returns the region configured for the default AWS SDK metric collector; or null if the default is to be used.static String
Returns the name of the registered admin mbean; or null if the admin mbean is not currently registered.static <T extends RequestMetricCollector>
TReturns a non-null request metric collector for the SDK.static <T extends ServiceMetricCollector>
Tstatic boolean
Returns true if the system propertySDKGlobalConfiguration.DEFAULT_METRICS_SYSTEM_PROPERTY
has been set; false otherwise.static boolean
Returns true if HttpSocketReadMetric is enabled; false otherwise.static boolean
Returns true if machine metrics is to be excluded.static boolean
Returns true if the metric admin MBean is currently registered for JMX access; false otherwise.static boolean
Returns true if metrics at the AWS SDK level is enabled; false if disabled.static boolean
Returns true if per-host metrics is enabled; false otherwise.static boolean
Returns true if the per-host metrics flag has been set; false otherwise.static boolean
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
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>
voidset
(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
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
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
Unregisters the metric admin MBean from JMX for the current classloader.static AwsSdkMetrics
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.
-
Field Details
-
DEFAULT_METRIC_NAMESPACE
- See Also:
-
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.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=useSingleMetricNamespace
- See Also:
-
EXCLUDE_MACHINE_METRICS
Used to exclude the generation of JVM metrics when the AWS SDK default metrics is enabled. By default, jvm metrics is included.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=excludeJvmMetrics
- See Also:
-
INCLUDE_PER_HOST_METRICS
Used to generate per host level metrics when the AWS SDK default metrics is enabled. By default, per-host level metrics is excluded.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=includePerHostMetrics
- See Also:
-
AWS_CREDENTAIL_PROPERTIES_FILE
Deprecated.in favor ofAWS_CREDENTIAL_PROPERTIES_FILE
Used to specify an AWS credential property file. By default, theDefaultAWSCredentialsProviderChain
is used.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=credentialFile=/path/aws.properties
- See Also:
-
AWS_CREDENTIAL_PROPERTIES_FILE
Used to specify an AWS credential property file. By default, theDefaultAWSCredentialsProviderChain
is used.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=credentialFile=/path/aws.properties
- See Also:
-
CLOUDWATCH_REGION
Used to specify the Amazon CloudWatch region for metrics uploading purposes. By default, metrics are uploaded to us-east-1.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=cloudwatchRegion=us-west-2
- See Also:
-
METRIC_QUEUE_SIZE
Used to specify the internal in-memory queue size for queuing metrics data points. The default size is 1,000.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=metricQueueSize=1000
- See Also:
-
QUEUE_POLL_TIMEOUT_MILLI
Used to specify the internal queue polling timeout in millisecond. The default timeout is 1 minute, which is optimal for the default CloudWatch implementation.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=getQueuePollTimeoutMilli=60000
- See Also:
-
METRIC_NAME_SPACE
Used to specify a custom metric name space. The default name space isDEFAULT_METRIC_NAMESPACE
.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=metricNameSpace=MyNameSpace
- See Also:
-
JVM_METRIC_NAME
Used to generate per JVM level metrics when the AWS SDK default metrics is enabled. By default, JVM level metrics are not generated.Example: -Dcom.amazonaws.sdk.enableDefaultMetrics=jvmMetricName=Tomcat1
- See Also:
-
HOST_METRIC_NAME
Used to explicitly specify the host name for metric purposes, instead of detecting the host name viaInetAddress
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
- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isMetricAdminMBeanRegistered
public static boolean isMetricAdminMBeanRegistered()Returns true if the metric admin MBean is currently registered for JMX access; false otherwise. -
getRegisteredAdminMbeanName
Returns the name of the registered admin mbean; or null if the admin mbean is not currently registered. -
registerMetricAdminMBean
public static boolean registerMetricAdminMBean()Registers the metric admin MBean for JMX access for the current classloader. If an AdminMbean is found to have been registered under a different class loader, the AdminMBean of the current class loader would be registered under the same nameMBEAN_OBJECT_NAME
but with an additional suffix in the format of "/", where count is a counter incrementing from 1. - Returns:
- true if the registeration succeeded; false otherwise.
-
unregisterMetricAdminMBean
public static boolean unregisterMetricAdminMBean()Unregisters the metric admin MBean from JMX for the current classloader.- Returns:
- true if the unregistration succeeded or if there is no admin MBean registered; false otherwise.
-
getRequestMetricCollector
Returns a non-null request metric collector for the SDK. If no custom request metric collector has previously been specified viasetMetricCollector(MetricCollector)
and theSDKGlobalConfiguration.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. -
getServiceMetricCollector
-
getMetricCollector
-
setMetricCollector
Sets the metric collector to be used by the AWS SDK, and stop the previously running collector used by the AWS SDK, if any. Note, however, a request metric collector specified at the web service client level or request level, if any, always takes precedence over the one specified at the AWS SDK level.Caller of this method is responsible for starting the new metric collector specified as the input parameter.
- Parameters:
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.- See Also:
-
setMachineMetricsExcluded
public static void setMachineMetricsExcluded(boolean excludeMachineMetrics) Used to set whether the machine metrics is to be excluded.- Parameters:
excludeMachineMetrics
- true if machine metrics is to be excluded; false otherwise.
-
setPerHostMetricsIncluded
public static void setPerHostMetricsIncluded(boolean includePerHostMetrics) Used to set whether the per-host metrics is to be included.- Parameters:
includePerHostMetrics
- true if per-host metrics is to be included; false otherwise.
-
enableHttpSocketReadMetric
public static void enableHttpSocketReadMetric()Used to enableAWSRequestMetrics.Field.HttpSocketReadTime
metric since by default it is disabled. -
isDefaultMetricsEnabled
public static boolean isDefaultMetricsEnabled()Returns true if the system propertySDKGlobalConfiguration.DEFAULT_METRICS_SYSTEM_PROPERTY
has been set; false otherwise. -
isSingleMetricNamespace
public 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. -
setSingleMetricNamespace
public 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.- Parameters:
singleMetricNamespace
- true if single metric name is to be used; false otherwise.
-
isMetricsEnabled
public static boolean isMetricsEnabled()Returns true if metrics at the AWS SDK level is enabled; false if disabled. -
isMachineMetricExcluded
public static boolean isMachineMetricExcluded()Returns true if machine metrics is to be excluded. -
isPerHostMetricIncluded
public static boolean isPerHostMetricIncluded()Returns true if the per-host metrics flag has been set; false otherwise. -
isPerHostMetricEnabled
public static boolean isPerHostMetricEnabled()Returns true if per-host metrics is enabled; false otherwise. -
isHttpSocketReadMetricEnabled
public static boolean isHttpSocketReadMetricEnabled()Returns true if HttpSocketReadMetric is enabled; false otherwise. -
enableDefaultMetrics
public 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.- Returns:
- true if the default AWS SDK metric collector has been successfully started by this call; false otherwise.
-
disableMetrics
public static void disableMetrics()Convenient method to disable the metric collector at the AWS SDK level. -
add
Adds the given metric type to the registry of predefined metrics to be captured at the AWS SDK level.- Returns:
- true if the set of predefined metric types gets changed as a result of the call
-
addAll
Adds the given metric types to the registry of predefined metrics to be captured at the AWS SDK level.- Returns:
- true if the set of predefined metric types gets changed as a result of the call
-
set
Sets the given metric types to replace the registry of predefined metrics to be captured at the AWS SDK level. -
remove
Removes the given metric type from the registry of predefined metrics to be captured at the AWS SDK level.- Returns:
- true if the set of predefined metric types gets changed as a result of the call
-
getPredefinedMetrics
Returns an unmodifiable set of the current predefined metrics. -
getCredentialProvider
Returns the credential provider for the default AWS SDK metric implementation. This method is restricted to calls from the default AWS SDK metric implementation.- Throws:
SecurityException
- if called outside the default AWS SDK metric implementation.
-
setCredentialProvider
Sets the credential provider for the default AWS SDK metric implementation; or null if the default is to be used. Calling this method may result in the credential provider being different from the credential file property. -
getRegion
Returns the region configured for the default AWS SDK metric collector; or null if the default is to be used. -
setRegion
Sets the region to be used for the default AWS SDK metric collector; or null if the default is to be used. -
getCredentailFile
Returns the last set AWS credential file, or null if there is none. -
setCredentialFile
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.- Throws:
FileNotFoundException
IOException
-
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. -
setMetricQueueSize
Sets the metric queue size to be used for the default AWS SDK metric collector; or null if the default is to be used. -
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. -
setQueuePollTimeoutMilli
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. -
getMetricNameSpace
Returns the metric name space, which is never null or blank. -
setMetricNameSpace
Sets the metric name space.- Parameters:
metricNameSpace
- metric name space which must neither be null or blank.- Throws:
IllegalArgumentException
- if the specified metric name space is either null or blank.
-
getJvmMetricName
Returns the name of the JVM for generating per-JVM level metrics; or null or blank if per-JVM level metrics are disabled. -
setJvmMetricName
Sets the name of the JVM for generating per-JVM level metrics.- Parameters:
jvmMetricName
- name of the JVM for generating per-JVM level metrics; or null or blank if per-JVM level metrics are to be disabled.
-
getHostMetricName
Returns the host name for generating per-host level metrics; or null or blank if the host is to be automatically detected viaInetAddress
. -
setHostMetricName
Sets the host name for generating per-host level metrics.- Parameters:
hostMetricName
- host name for generating per-host level metrics; or null or blank if the host is to be automatically detected viaInetAddress
.
-
AWS_CREDENTIAL_PROPERTIES_FILE