Search in sources :

Example 6 with SuppressLogger

use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.

the class SdkDoubleHistogramTest method doubleHistogramRecord_NonNegativeCheck.

@Test
@SuppressLogger(SdkDoubleHistogram.class)
void doubleHistogramRecord_NonNegativeCheck() {
    DoubleHistogram histogram = sdkMeter.histogramBuilder("testHistogram").build();
    histogram.record(-45);
    assertThat(sdkMeterReader.collectAllMetrics()).hasSize(0);
    logs.assertContains("Histograms can only record non-negative values. Instrument testHistogram has recorded a negative value.");
}
Also used : DoubleHistogram(io.opentelemetry.api.metrics.DoubleHistogram) BoundDoubleHistogram(io.opentelemetry.sdk.metrics.internal.instrument.BoundDoubleHistogram) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 7 with SuppressLogger

use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.

the class SdkLongCounterTest method longCounterAdd_Monotonicity.

@Test
@SuppressLogger(SdkLongCounter.class)
void longCounterAdd_Monotonicity() {
    LongCounter longCounter = sdkMeter.counterBuilder("testCounter").build();
    longCounter.add(-45);
    assertThat(sdkMeterReader.collectAllMetrics()).hasSize(0);
    logs.assertContains("Counters can only increase. Instrument testCounter has recorded a negative value.");
}
Also used : LongCounter(io.opentelemetry.api.metrics.LongCounter) BoundLongCounter(io.opentelemetry.sdk.metrics.internal.instrument.BoundLongCounter) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 8 with SuppressLogger

use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.

the class SdkLongCounterTest method boundLongCounterAdd_Monotonicity.

@Test
@SuppressLogger(SdkLongCounter.class)
void boundLongCounterAdd_Monotonicity() {
    LongCounter longCounter = sdkMeter.counterBuilder("testCounter").build();
    BoundLongCounter bound = ((SdkLongCounter) longCounter).bind(Attributes.empty());
    try {
        bound.add(-9);
        assertThat(sdkMeterReader.collectAllMetrics()).hasSize(0);
        logs.assertContains("Counters can only increase. Instrument testCounter has recorded a negative value.");
    } finally {
        bound.unbind();
    }
}
Also used : BoundLongCounter(io.opentelemetry.sdk.metrics.internal.instrument.BoundLongCounter) LongCounter(io.opentelemetry.api.metrics.LongCounter) BoundLongCounter(io.opentelemetry.sdk.metrics.internal.instrument.BoundLongCounter) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 9 with SuppressLogger

use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.

the class SdkLongHistogramTest method longHistogramRecord_NonNegativeCheck.

@Test
@SuppressLogger(SdkLongHistogram.class)
void longHistogramRecord_NonNegativeCheck() {
    LongHistogram histogram = sdkMeter.histogramBuilder("testHistogram").ofLongs().build();
    histogram.record(-45);
    assertThat(sdkMeterReader.collectAllMetrics()).hasSize(0);
    logs.assertContains("Histograms can only record non-negative values. Instrument testHistogram has recorded a negative value.");
}
Also used : BoundLongHistogram(io.opentelemetry.sdk.metrics.internal.instrument.BoundLongHistogram) LongHistogram(io.opentelemetry.api.metrics.LongHistogram) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 10 with SuppressLogger

use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.

the class AbstractGrpcTelemetryExporterTest method tls_untrusted.

@Test
@SuppressLogger(OkHttpGrpcExporter.class)
@SuppressLogger(DefaultGrpcExporter.class)
void tls_untrusted() {
    TelemetryExporter<T> exporter = exporterBuilder().setEndpoint(server.httpsUri().toString()).build();
    try {
        CompletableResultCode result = exporter.export(Collections.singletonList(generateFakeTelemetry()));
        assertThat(result.join(10, TimeUnit.SECONDS).isSuccess()).isFalse();
    } finally {
        exporter.shutdown();
    }
}
Also used : CompletableResultCode(io.opentelemetry.sdk.common.CompletableResultCode) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SuppressLogger (io.opentelemetry.internal.testing.slf4j.SuppressLogger)32 Test (org.junit.jupiter.api.Test)32 LoggingEvent (org.slf4j.event.LoggingEvent)11 HashMap (java.util.HashMap)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Attributes (io.opentelemetry.api.common.Attributes)3 ResourceAttributes (io.opentelemetry.semconv.resource.attributes.ResourceAttributes)3 DoubleHistogram (io.opentelemetry.api.metrics.DoubleHistogram)2 LongCounter (io.opentelemetry.api.metrics.LongCounter)2 LongHistogram (io.opentelemetry.api.metrics.LongHistogram)2 CompletableResultCode (io.opentelemetry.sdk.common.CompletableResultCode)2 LogData (io.opentelemetry.sdk.logs.data.LogData)2 LogExporter (io.opentelemetry.sdk.logs.export.LogExporter)2 MetricExporter (io.opentelemetry.sdk.metrics.export.MetricExporter)2 BoundDoubleHistogram (io.opentelemetry.sdk.metrics.internal.instrument.BoundDoubleHistogram)2 BoundLongCounter (io.opentelemetry.sdk.metrics.internal.instrument.BoundLongCounter)2 BoundLongHistogram (io.opentelemetry.sdk.metrics.internal.instrument.BoundLongHistogram)2 SpanExporter (io.opentelemetry.sdk.trace.export.SpanExporter)2 File (java.io.File)2 AggregatedHttpRequest (com.linecorp.armeria.common.AggregatedHttpRequest)1