Search in sources :

Example 31 with SuppressLogger

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

the class OtlpHttpLogExporterTest method testServerErrorParseError.

@Test
@SuppressLogger(OkHttpExporter.class)
void testServerErrorParseError() {
    server.enqueue(HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR, APPLICATION_PROTOBUF, "Server error!"));
    OtlpHttpLogExporter exporter = builder.build();
    exportAndAssertResult(exporter, /* expectedResult= */
    false);
    LoggingEvent log = logs.assertContains("Failed to export logs. Server responded with HTTP status code 500. Error message: Unable to parse response body, HTTP status message:");
    assertThat(log.getLevel()).isEqualTo(Level.WARN);
}
Also used : LoggingEvent(org.slf4j.event.LoggingEvent) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 32 with SuppressLogger

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

the class SimpleLogProcessorTest method addLogRecord_ExporterError.

@Test
@SuppressLogger(SimpleLogProcessor.class)
void addLogRecord_ExporterError() {
    LogData logData = TestUtil.createLogData(DEBUG, "Log message");
    when(logExporter.export(any())).thenThrow(new RuntimeException("Exporter error!"));
    logProcessor.emit(logData);
    logProcessor.emit(logData);
    verify(logExporter, times(2)).export(Collections.singletonList(logData));
}
Also used : LogData(io.opentelemetry.sdk.logs.data.LogData) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

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