use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class ConfigErrorTest method globalOpenTelemetryWhenError.
@Test
@SetSystemProperty(key = "otel.traces.sampler", value = "traceidratio")
@SetSystemProperty(key = "otel.traces.sampler.arg", value = "bar")
@SuppressLogger(GlobalOpenTelemetry.class)
void globalOpenTelemetryWhenError() {
assertThat(GlobalOpenTelemetry.get()).isInstanceOf(OpenTelemetry.class).extracting("propagators").isEqualTo(ContextPropagators.noop());
LoggingEvent log = logs.assertContains("Error automatically configuring OpenTelemetry SDK. " + "OpenTelemetry will not be enabled.");
assertThat(log.getLevel()).isEqualTo(Level.ERROR);
assertThat(log.getThrowable()).isInstanceOf(ConfigurationException.class);
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger 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);
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class AbstractGrpcTelemetryExporterTest method testExport_Unimplemented.
@Test
@SuppressLogger(OkHttpGrpcExporter.class)
@SuppressLogger(DefaultGrpcExporter.class)
void testExport_Unimplemented() {
addGrpcError(12, "UNIMPLEMENTED");
assertThat(exporter.export(Collections.singletonList(generateFakeTelemetry())).join(10, TimeUnit.SECONDS).isSuccess()).isFalse();
LoggingEvent log = logs.assertContains("Failed to export " + type + "s. Server responded with UNIMPLEMENTED. " + "This usually means that your collector is not configured with an otlp " + "receiver in the \"pipelines\" section of the configuration. " + "Full error message: UNIMPLEMENTED");
assertThat(log.getLevel()).isEqualTo(Level.ERROR);
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger 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);
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class ZipkinSpanExporterTest method testExport_failed.
@Test
@SuppressLogger(ZipkinSpanExporter.class)
void testExport_failed() {
ZipkinSpanExporter zipkinSpanExporter = new ZipkinSpanExporter(mockEncoder, mockSender);
byte[] someBytes = new byte[0];
when(mockEncoder.encode(standardZipkinSpanBuilder(Span.Kind.SERVER).putTag(ZipkinSpanExporter.OTEL_STATUS_CODE, "OK").build())).thenReturn(someBytes);
when(mockSender.sendSpans(Collections.singletonList(someBytes))).thenReturn(mockZipkinCall);
doAnswer(invocation -> {
Callback<Void> callback = invocation.getArgument(0);
callback.onError(new IOException());
return null;
}).when(mockZipkinCall).enqueue(any());
CompletableResultCode resultCode = zipkinSpanExporter.export(Collections.singleton(buildStandardSpan().build()));
assertThat(resultCode.isSuccess()).isFalse();
}
Aggregations