use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class OtlpHttpLogExporterTest method testServerError.
@Test
@SuppressLogger(OkHttpExporter.class)
void testServerError() {
server.enqueue(buildResponse(HttpStatus.INTERNAL_SERVER_ERROR, Status.newBuilder().setMessage("Server error!").build()));
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: Server error!");
assertThat(log.getLevel()).isEqualTo(Level.WARN);
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class OtlpGrpcRetryTest method configureMetricExporterRetryPolicy.
@Test
@SuppressLogger(DefaultGrpcExporter.class)
void configureMetricExporterRetryPolicy() {
Map<String, String> props = new HashMap<>();
props.put("otel.exporter.otlp.metrics.endpoint", "https://localhost:" + server.httpsPort());
props.put("otel.exporter.otlp.metrics.certificate", certificate.certificateFile().getAbsolutePath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (MetricExporter metricExporter = MetricExporterConfiguration.configureOtlpMetrics(DefaultConfigProperties.createForTest(props))) {
testRetryableStatusCodes(() -> METRIC_DATA, metricExporter::export, server.metricRequests::size);
testDefaultRetryPolicy(() -> METRIC_DATA, metricExporter::export, server.metricRequests::size);
}
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class OtlpGrpcRetryTest method configureLogExporterRetryPolicy.
@Test
@SuppressLogger(DefaultGrpcExporter.class)
void configureLogExporterRetryPolicy() {
Map<String, String> props = new HashMap<>();
props.put("otel.exporter.otlp.logs.endpoint", "https://localhost:" + server.httpsPort());
props.put("otel.exporter.otlp.logs.certificate", certificate.certificateFile().getAbsolutePath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (LogExporter logExporter = LogExporterConfiguration.configureOtlpLogs(DefaultConfigProperties.createForTest(props), MeterProvider.noop())) {
testRetryableStatusCodes(() -> LOG_DATA, logExporter::export, server.logRequests::size);
testDefaultRetryPolicy(() -> LOG_DATA, logExporter::export, server.logRequests::size);
}
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class OtlpHttpRetryTest method configureSpanExporterRetryPolicy.
@Test
@SuppressLogger(OkHttpGrpcExporter.class)
void configureSpanExporterRetryPolicy() {
Map<String, String> props = new HashMap<>();
props.put("otel.exporter.otlp.traces.protocol", "http/protobuf");
props.put("otel.exporter.otlp.traces.endpoint", "https://localhost:" + server.httpsPort() + "/v1/traces");
props.put("otel.exporter.otlp.traces.certificate", server.selfSignedCertificate.certificate().getPath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (SpanExporter spanExporter = SpanExporterConfiguration.configureExporter("otlp", DefaultConfigProperties.createForTest(props), NamedSpiManager.createEmpty(), MeterProvider.noop())) {
testRetryableStatusCodes(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
testDefaultRetryPolicy(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
}
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class JaegerRemoteSamplerTest method internal_error_server_response.
@Test
@SuppressLogger(OkHttpGrpcService.class)
void internal_error_server_response() {
addGrpcError(13, "internal error");
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 gRPC status code 13");
assertThat(log.getLevel()).isEqualTo(Level.WARN);
});
}
}
Aggregations