public class MetricsLogger
extends java.lang.Object
| Constructor and Description |
|---|
MetricsLogger() |
MetricsLogger(Environment environment) |
MetricsLogger(EnvironmentProvider environmentProvider) |
MetricsLogger(EnvironmentProvider environmentProvider,
MetricsContext metricsContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
flush()
Flushes the current context state to the configured sink.
|
MetricsLogger |
putDimensions(DimensionSet dimensions)
Adds a dimension.
|
MetricsLogger |
putMetadata(java.lang.String key,
java.lang.Object value)
Add a custom key-value pair to the Metadata object.
|
MetricsLogger |
putMetric(java.lang.String key,
double value)
Put a metric value.
|
MetricsLogger |
putMetric(java.lang.String key,
double value,
StorageResolution storageResolution)
Put a metric value.
|
MetricsLogger |
putMetric(java.lang.String key,
double value,
Unit unit)
Put a metric value.
|
MetricsLogger |
putMetric(java.lang.String key,
double value,
Unit unit,
StorageResolution storageResolution)
Put a metric value.
|
MetricsLogger |
putProperty(java.lang.String key,
java.lang.Object value)
Set a property on the published metrics.
|
MetricsLogger |
resetDimensions(boolean useDefault)
Clear all custom dimensions on this MetricsLogger instance.
|
MetricsLogger |
setDimensions(boolean useDefault,
DimensionSet... dimensionSets)
Overwrite custom dimensions on this MetricsLogger instance, with an option to preserve
default dimensions.
|
MetricsLogger |
setDimensions(DimensionSet... dimensionSets)
Overwrite all dimensions on this MetricsLogger instance.
|
MetricsLogger |
setNamespace(java.lang.String namespace)
Set the CloudWatch namespace that metrics should be published to.
|
MetricsLogger |
setTimestamp(java.time.Instant timestamp)
Set the timestamp to be used for metrics.
|
public MetricsLogger()
public MetricsLogger(Environment environment)
public MetricsLogger(EnvironmentProvider environmentProvider)
public MetricsLogger(EnvironmentProvider environmentProvider, MetricsContext metricsContext)
public void flush()
public MetricsLogger putProperty(java.lang.String key, java.lang.Object value)
key - Property namevalue - Property valuepublic MetricsLogger putDimensions(DimensionSet dimensions)
dimensions - the DimensionSet to addpublic MetricsLogger setDimensions(DimensionSet... dimensionSets)
dimensionSets - the dimensionSets to setpublic MetricsLogger setDimensions(boolean useDefault, DimensionSet... dimensionSets)
useDefault - indicates whether default dimensions should be useddimensionSets - the dimensionSets to setpublic MetricsLogger resetDimensions(boolean useDefault)
useDefault - indicates whether default dimensions should be usedpublic MetricsLogger putMetric(java.lang.String key, double value, Unit unit, StorageResolution storageResolution) throws InvalidMetricException
key - is the name of the metricvalue - is the value of the metricunit - is the unit of the metric valuestorageResolution - is the resolution of the metricInvalidMetricException - if the metric is invalidpublic MetricsLogger putMetric(java.lang.String key, double value, StorageResolution storageResolution) throws InvalidMetricException
key - is the name of the metricvalue - is the value of the metricstorageResolution - is the resolution of the metricInvalidMetricException - if the metric is invalidpublic MetricsLogger putMetric(java.lang.String key, double value, Unit unit) throws InvalidMetricException
key - is the name of the metricvalue - is the value of the metricunit - is the unit of the metric valueInvalidMetricException - if the metric is invalidpublic MetricsLogger putMetric(java.lang.String key, double value) throws InvalidMetricException
key - the name of the metricvalue - the value of the metricInvalidMetricException - if the metric is invalidpublic MetricsLogger putMetadata(java.lang.String key, java.lang.Object value)
key - the name of the keyvalue - the value associated with the keypublic MetricsLogger setNamespace(java.lang.String namespace) throws InvalidNamespaceException
namespace - the namespace of the logsInvalidNamespaceException - if the namespace is invalidpublic MetricsLogger setTimestamp(java.time.Instant timestamp) throws InvalidTimestampException
timestamp - value of timestamp to be setInvalidTimestampException - if the timestamp is invalid