com.appsflyer.otelawsmetrics.LongHistogramStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-sdk-java-opentelemetry-metrics Show documentation
Show all versions of aws-sdk-java-opentelemetry-metrics Show documentation
OpenTelemetry Metric Publisher for AWS SDK for Java
The newest version!
package com.appsflyer.otelawsmetrics;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.LongHistogram;
import io.opentelemetry.api.metrics.Meter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.metrics.MetricRecord;
public class LongHistogramStrategy implements MetricStrategy {
private static final Logger log = LoggerFactory.getLogger(LongHistogramStrategy.class);
private final LongHistogram histogram;
public LongHistogramStrategy(Meter meter, String metricName, String description) {
this.histogram = meter.histogramBuilder(metricName)
.setDescription(description)
.ofLongs()
.build();
}
@Override
public void record(MetricRecord> metricRecord, Attributes attributes) {
if (metricRecord.value() instanceof Number) {
Number value = (Number) metricRecord.value();
histogram.record(value.longValue(), attributes);
} else {
log.warn("Invalid value type for a LongHistogram metric: {}", metricRecord.metric().name());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy