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
.
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
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
Constant for 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 String |
getCredentailFile() |
static AWSCredentialsProvider |
getCredentialProvider() |
static String |
getHostMetricName() |
static String |
getJvmMetricName() |
static <T extends MetricCollector> |
getMetricCollector() |
static String |
getMetricNameSpace() |
static Integer |
getMetricQueueSize() |
static Set<MetricType> |
getPredefinedMetrics() |
static Long |
getQueuePollTimeoutMilli() |
static Regions |
getRegion() |
static <T extends RequestMetricCollector> |
getRequestMetricCollector() |
static <T extends ServiceMetricCollector> |
getServiceMetricCollector() |
static boolean |
isDefaultMetricsEnabled() |
static boolean |
isMachineMetricExcluded() |
static boolean |
isMetricsEnabled() |
static boolean |
isPerHostMetricEnabled() |
static boolean |
isPerHostMetricIncluded() |
static boolean |
isSingleMetricNamespace() |
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 |
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 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
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 <T extends RequestMetricCollector> T getRequestMetricCollector()
T
- RequestMetricCollector type.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()
T
- Tje ServiceMetricCollector type.public static <T extends MetricCollector> T getMetricCollector()
T
- The MetricCollector type.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 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 enableDefaultMetrics()
public static void disableMetrics()
public static boolean add(MetricType type)
type
- the metric type.public static <T extends MetricType> boolean addAll(Collection<T> types)
T
- the MetricType type.types
- the collection of metric types.public static <T extends MetricType> void set(Collection<T> types)
T
- the MetricType type.types
- the collection of metric types.public static boolean remove(MetricType type)
type
- the collection of metric types.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)
provider
- the AWSCredentialsProvider.public static Regions getRegion()
public static void setRegion(Regions region)
region
- the region.public static String getCredentailFile()
public static void setCredentialFile(String filepath) throws IOException
filepath
- the credential filepath.IOException
public static Integer getMetricQueueSize()
public static void setMetricQueueSize(Integer size)
size
- the size of the metric queue.public static Long getQueuePollTimeoutMilli()
public static void setQueuePollTimeoutMilli(Long timeoutMilli)
timeoutMilli
- the timeout in milliseconds.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 © 2019. All rights reserved.