Search in sources :

Example 21 with LoggingEvent

use of org.slf4j.event.LoggingEvent in project opentelemetry-java by open-telemetry.

the class AbstractGrpcTelemetryExporterTest method errorWithEscapedMessage.

@Test
@SuppressLogger(OkHttpGrpcExporter.class)
@SuppressLogger(DefaultGrpcExporter.class)
void errorWithEscapedMessage() {
    addGrpcError(5, "クマ🐻");
    assertThat(exporter.export(Collections.singletonList(generateFakeTelemetry())).join(10, TimeUnit.SECONDS).isSuccess()).isFalse();
    LoggingEvent log = logs.assertContains("Failed to export " + type + "s. Server responded with gRPC status code 5. Error 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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with LoggingEvent

use of org.slf4j.event.LoggingEvent in project opentelemetry-java by open-telemetry.

the class AbstractGrpcTelemetryExporterTest method testExport_Unavailable.

@Test
@SuppressLogger(OkHttpGrpcExporter.class)
@SuppressLogger(DefaultGrpcExporter.class)
void testExport_Unavailable() {
    addGrpcError(14, null);
    assertThat(exporter.export(Collections.singletonList(generateFakeTelemetry())).join(10, TimeUnit.SECONDS).isSuccess()).isFalse();
    LoggingEvent log = logs.assertContains("Failed to export " + type + "s. Server is UNAVAILABLE. " + "Make sure your collector is running and reachable from this network.");
    assertThat(log.getLevel()).isEqualTo(Level.ERROR);
}
Also used : LoggingEvent(org.slf4j.event.LoggingEvent) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with LoggingEvent

use of org.slf4j.event.LoggingEvent 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)

Aggregations

LoggingEvent (org.slf4j.event.LoggingEvent)23 Test (org.junit.jupiter.api.Test)20 SuppressLogger (io.opentelemetry.internal.testing.slf4j.SuppressLogger)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 ArrayList (java.util.ArrayList)2 List (java.util.List)1 LocationInfo (org.apache.log4j.spi.LocationInfo)1 ThrowableInformation (org.apache.log4j.spi.ThrowableInformation)1 LoggerContext (org.apache.logging.log4j.core.LoggerContext)1 Statement (org.junit.runners.model.Statement)1 SetSystemProperty (org.junitpioneer.jupiter.SetSystemProperty)1 SubstituteLoggingEvent (org.slf4j.event.SubstituteLoggingEvent)1 FormattingTuple (org.slf4j.helpers.FormattingTuple)1