public class OtelMetricsScope extends Object implements MetricsScope
MetricsScope directly.
Records raw observations immediately on OTel Meter instruments (DoubleHistogram,
DoubleCounter, DoubleGauge) as addData(java.lang.String, double, software.amazon.awssdk.services.cloudwatch.model.StandardUnit) is called. The OTel SDK
(configured by the application owner) handles aggregation, batching, and export.
Dimensions must be added via addDimension(java.lang.String, java.lang.String) before calling addData(java.lang.String, double, software.amazon.awssdk.services.cloudwatch.model.StandardUnit),
as observations are recorded immediately with the current set of accumulated attributes.
METRICS_DIMENSIONS_ALL| Constructor and Description |
|---|
OtelMetricsScope(io.opentelemetry.api.metrics.Meter meter,
MetricsLevel metricsLevel,
Set<String> metricsEnabledDimensions)
Creates an OTel-native metrics scope.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addData(String name,
double value,
software.amazon.awssdk.services.cloudwatch.model.StandardUnit unit)
Adds a data point to this IMetricsScope.
|
void |
addData(String name,
double value,
software.amazon.awssdk.services.cloudwatch.model.StandardUnit unit,
MetricsLevel level)
Adds a data point to this IMetricsScope if given metrics level is enabled.
|
void |
addDimension(String name,
String value)
Adds a dimension that applies to all metrics in this IMetricsScope.
|
void |
end()
Flushes the data from this IMetricsScope and causes future calls to addData and addDimension to fail.
|
public OtelMetricsScope(io.opentelemetry.api.metrics.Meter meter,
MetricsLevel metricsLevel,
Set<String> metricsEnabledDimensions)
meter - the OTel Meter to record observations onmetricsLevel - the minimum metrics level threshold; data points below this are droppedmetricsEnabledDimensions - the set of dimension names to include; use MetricsScope.METRICS_DIMENSIONS_ALL to include allpublic void addData(String name, double value, software.amazon.awssdk.services.cloudwatch.model.StandardUnit unit)
MetricsScopeaddData in interface MetricsScopename - data point namevalue - data point valueunit - unit of data pointpublic void addData(String name, double value, software.amazon.awssdk.services.cloudwatch.model.StandardUnit unit, MetricsLevel level)
MetricsScopeaddData in interface MetricsScopename - data point namevalue - data point valueunit - unit of data pointlevel - metrics level of this data pointpublic void addDimension(String name, String value)
MetricsScopeaddDimension in interface MetricsScopename - dimension namevalue - dimension valuepublic void end()
MetricsScopeend in interface MetricsScopeCopyright © 2026. All rights reserved.