Search in sources :

Example 11 with LoggingEvent

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

the class JaegerRemoteSamplerGrpcNettyTest method unimplemented_error_server_response.

@Test
void unimplemented_error_server_response() {
    addGrpcError(12, null);
    try (JaegerRemoteSampler sampler = JaegerRemoteSampler.builder().setEndpoint(server.httpUri().toString()).setServiceName(SERVICE_NAME).setPollingInterval(50, TimeUnit.MILLISECONDS).build()) {
        assertThat(sampler.getDescription()).startsWith("JaegerRemoteSampler{ParentBased{root:TraceIdRatioBased{0.001000}");
        await().untilAsserted(() -> {
            LoggingEvent log = logs.assertContains("Server responded with UNIMPLEMENTED.");
            assertThat(log.getLevel()).isEqualTo(Level.ERROR);
        });
    }
}
Also used : LoggingEvent(org.slf4j.event.LoggingEvent) Test(org.junit.jupiter.api.Test)

Example 12 with LoggingEvent

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

the class JaegerRemoteSamplerGrpcNettyTest method unavailable_error_server_response.

@Test
void unavailable_error_server_response() {
    addGrpcError(14, "クマ🐻 resource exhausted");
    try (JaegerRemoteSampler sampler = JaegerRemoteSampler.builder().setEndpoint(server.httpUri().toString()).setServiceName(SERVICE_NAME).setPollingInterval(50, TimeUnit.MILLISECONDS).build()) {
        assertThat(sampler.getDescription()).startsWith("JaegerRemoteSampler{ParentBased{root:TraceIdRatioBased{0.001000}");
        await().untilAsserted(() -> {
            LoggingEvent log = logs.assertContains("Server is UNAVAILABLE");
            assertThat(log.getLevel()).isEqualTo(Level.ERROR);
        });
    }
}
Also used : LoggingEvent(org.slf4j.event.LoggingEvent) Test(org.junit.jupiter.api.Test)

Example 13 with LoggingEvent

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

the class OtlpHttpSpanExporterTest method testServerErrorParseError.

@Test
@SuppressLogger(OkHttpExporter.class)
void testServerErrorParseError() {
    server.enqueue(HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR, APPLICATION_PROTOBUF, "Server error!"));
    OtlpHttpSpanExporter exporter = builder.build();
    exportAndAssertResult(exporter, /* expectedResult= */
    false);
    LoggingEvent log = logs.assertContains("Failed to export spans. 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 14 with LoggingEvent

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

the class OtlpHttpSpanExporterTest method testServerError.

@Test
@SuppressLogger(OkHttpExporter.class)
void testServerError() {
    server.enqueue(buildResponse(HttpStatus.INTERNAL_SERVER_ERROR, Status.newBuilder().setMessage("Server error!").build()));
    OtlpHttpSpanExporter exporter = builder.build();
    exportAndAssertResult(exporter, /* expectedResult= */
    false);
    LoggingEvent log = logs.assertContains("Failed to export spans. Server responded with HTTP status code 500. Error message: Server error!");
    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 15 with LoggingEvent

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

the class StrictContextStorageTest method garbageCollectedScope.

@Test
void garbageCollectedScope() {
    Context.current().with(ANIMAL, "cat").makeCurrent();
    await().atMost(Duration.ofSeconds(30)).untilAsserted(() -> {
        System.gc();
        LoggingEvent log = logs.assertContains("Scope garbage collected before being closed.");
        assertThat(log.getLevel()).isEqualTo(Level.ERROR);
        assertThat(log.getThrowable().getMessage()).matches("Thread \\[Test worker\\] opened a scope of .* here:");
    });
}
Also used : LoggingEvent(org.slf4j.event.LoggingEvent) 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