Class OpenTelemetryDataTestUtils

java.lang.Object
com.linkedin.venice.utils.OpenTelemetryDataTestUtils

public abstract class OpenTelemetryDataTestUtils extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    assertNoLongSumDataForAttributes(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String metricPrefix, io.opentelemetry.api.common.Attributes expectedAttributes)
    Assert that no Sum (counter) data point exists for the given metric name and attributes.
    static io.opentelemetry.sdk.metrics.data.ExponentialHistogramPointData
    getExponentialHistogramPointData(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
     
    static io.opentelemetry.sdk.metrics.data.HistogramPointData
    getHistogramPointData(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
     
    static io.opentelemetry.sdk.metrics.data.LongPointData
    getLongPointDataFromGauge(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
     
    static io.opentelemetry.sdk.metrics.data.LongPointData
    getLongPointDataFromSum(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
     
    static void
    validateAnyDoubleGaugeDataPointAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double minValue, String metricName, String metricPrefix)
     
    static void
    validateAnyGaugeDataPointAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long minValue, String metricName, String metricPrefix)
    Validate that at least one Gauge data point exists with value >= minValue, across all attribute combinations.
    static void
    validateAnyGaugeDataPointAtLeast(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, long minValue, String metricName, String metricPrefix)
     
    static void
    validateAnySumDataPointAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long minValue, String metricName, String metricPrefix)
    Validate that at least one Sum (counter) data point exists with value >= minValue, across all attribute combinations.
    static void
    validateAnySumDataPointAtLeast(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, long minValue, String metricName, String metricPrefix)
     
    static void
    validateDoublePointDataFromGauge(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double expectedValue, double tolerance, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
     
    static void
    validateExponentialHistogramPointData(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double expectedMin, double expectedMax, long expectedCount, double expectedSum, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
     
    static void
    validateExponentialHistogramPointDataAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedMinCount, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    Validate ExponentialHistogramPointData has at least expectedMinCount entries with sum > 0.
    static void
    validateExponentialHistogramPointDataForLatency(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedCount, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    Validate ExponentialHistogramPointData for latency metrics where min, max, and sum are not known but are > 0.
    static void
    validateHistogramPointData(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double expectedMin, double expectedMax, long expectedCount, double expectedSum, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
     
    static void
    validateLongPointDataFromCounter(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
     
    static void
    validateLongPointDataFromCounterAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedMinValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    Validate counter value is at least the expected minimum.
    static void
    validateLongPointDataFromGauge(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
     
    static void
    validateObservableCounterValue(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    Validate observable counter value for a specific attribute combination.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OpenTelemetryDataTestUtils

      public OpenTelemetryDataTestUtils()
  • Method Details

    • getLongPointDataFromSum

      public static io.opentelemetry.sdk.metrics.data.LongPointData getLongPointDataFromSum(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
    • getLongPointDataFromGauge

      public static io.opentelemetry.sdk.metrics.data.LongPointData getLongPointDataFromGauge(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
    • getExponentialHistogramPointData

      public static io.opentelemetry.sdk.metrics.data.ExponentialHistogramPointData getExponentialHistogramPointData(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
    • getHistogramPointData

      public static io.opentelemetry.sdk.metrics.data.HistogramPointData getHistogramPointData(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String prefix, io.opentelemetry.api.common.Attributes expectedAttributes)
    • validateLongPointDataFromCounter

      public static void validateLongPointDataFromCounter(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    • validateLongPointDataFromCounterAtLeast

      public static void validateLongPointDataFromCounterAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedMinValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
      Validate counter value is at least the expected minimum. Use this in integration tests where the exact count is non-deterministic (e.g., TopicCleanupService may delete additional topics beyond those the test explicitly tracks).
    • validateLongPointDataFromGauge

      public static void validateLongPointDataFromGauge(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    • validateDoublePointDataFromGauge

      public static void validateDoublePointDataFromGauge(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double expectedValue, double tolerance, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    • validateExponentialHistogramPointData

      public static void validateExponentialHistogramPointData(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double expectedMin, double expectedMax, long expectedCount, double expectedSum, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    • validateExponentialHistogramPointDataForLatency

      public static void validateExponentialHistogramPointDataForLatency(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedCount, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
      Validate ExponentialHistogramPointData for latency metrics where min, max, and sum are not known but are > 0.
    • validateExponentialHistogramPointDataAtLeast

      public static void validateExponentialHistogramPointDataAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedMinCount, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
      Validate ExponentialHistogramPointData has at least expectedMinCount entries with sum > 0. Use this in integration tests where the exact count is non-deterministic.
    • validateHistogramPointData

      public static void validateHistogramPointData(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double expectedMin, double expectedMax, long expectedCount, double expectedSum, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
    • validateObservableCounterValue

      public static void validateObservableCounterValue(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long expectedValue, io.opentelemetry.api.common.Attributes expectedAttributes, String metricName, String metricPrefix)
      Validate observable counter value for a specific attribute combination. Observable counters report as Sum data in OpenTelemetry.
    • validateAnySumDataPointAtLeast

      public static void validateAnySumDataPointAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long minValue, String metricName, String metricPrefix)
      Validate that at least one Sum (counter) data point exists with value >= minValue, across all attribute combinations. Use this in integration tests where the exact attributes are non-deterministic (e.g., replica type depends on leader election).

      Note: When validating multiple metrics, prefer collecting once via reader.collectAllMetrics() and calling the Collection<MetricData> overload to avoid draining async counter adders between calls.

    • validateAnySumDataPointAtLeast

      public static void validateAnySumDataPointAtLeast(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, long minValue, String metricName, String metricPrefix)
    • validateAnyGaugeDataPointAtLeast

      public static void validateAnyGaugeDataPointAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, long minValue, String metricName, String metricPrefix)
      Validate that at least one Gauge data point exists with value >= minValue, across all attribute combinations. Use this in integration tests where the exact attributes are non-deterministic.

      Note: When validating multiple metrics, prefer collecting once via reader.collectAllMetrics() and calling the Collection<MetricData> overload to avoid draining async counter adders between calls.

    • validateAnyGaugeDataPointAtLeast

      public static void validateAnyGaugeDataPointAtLeast(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, long minValue, String metricName, String metricPrefix)
    • validateAnyDoubleGaugeDataPointAtLeast

      public static void validateAnyDoubleGaugeDataPointAtLeast(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader inMemoryMetricReader, double minValue, String metricName, String metricPrefix)
    • assertNoLongSumDataForAttributes

      public static void assertNoLongSumDataForAttributes(Collection<io.opentelemetry.sdk.metrics.data.MetricData> metricsData, String metricName, String metricPrefix, io.opentelemetry.api.common.Attributes expectedAttributes)
      Assert that no Sum (counter) data point exists for the given metric name and attributes. If the metric is not present at all, this passes (no data = no counter data). If attributes is null, asserts that no data points exist at all for the metric.