Search in sources :

Example 1 with SuppressLogger

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);
}
Also used : LoggingEvent(org.slf4j.event.LoggingEvent) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 2 with SuppressLogger

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);
    }
}
Also used : MetricExporter(io.opentelemetry.sdk.metrics.export.MetricExporter) HashMap(java.util.HashMap) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 3 with SuppressLogger

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);
    }
}
Also used : HashMap(java.util.HashMap) LogExporter(io.opentelemetry.sdk.logs.export.LogExporter) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 4 with SuppressLogger

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);
    }
}
Also used : SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) HashMap(java.util.HashMap) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 5 with SuppressLogger

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);
        });
    }
}
Also used : LoggingEvent(org.slf4j.event.LoggingEvent) 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