use of io.opentelemetry.sdk.logs.export.LogExporter in project opentelemetry-java by open-telemetry.
the class OtlpHttpConfigTest method configureExportersGeneral.
@Test
void configureExportersGeneral() {
Map<String, String> props = new HashMap<>();
props.put("otel.exporter.otlp.protocol", "http/protobuf");
props.put("otel.exporter.otlp.endpoint", "https://localhost:" + server.httpsPort());
props.put("otel.exporter.otlp.certificate", server.selfSignedCertificate.certificate().getPath());
props.put("otel.exporter.otlp.headers", "header-key=header-value");
props.put("otel.exporter.otlp.compression", "gzip");
props.put("otel.exporter.otlp.timeout", "15s");
ConfigProperties properties = DefaultConfigProperties.createForTest(props);
SpanExporter spanExporter = SpanExporterConfiguration.configureExporter("otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop());
MetricExporter metricExporter = MetricExporterConfiguration.configureOtlpMetrics(properties);
LogExporter logExporter = LogExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop());
assertThat(spanExporter).extracting("delegate.client", as(InstanceOfAssertFactories.type(OkHttpClient.class))).extracting(OkHttpClient::callTimeoutMillis).isEqualTo((int) TimeUnit.SECONDS.toMillis(15));
assertThat(spanExporter.export(Lists.newArrayList(generateFakeSpan())).join(15, TimeUnit.SECONDS).isSuccess()).isTrue();
assertThat(server.traceRequests).hasSize(1);
assertThat(server.requestHeaders).anyMatch(headers -> headers.contains(":path", "/v1/traces") && headers.contains("header-key", "header-value") && headers.contains("content-encoding", "gzip"));
assertThat(metricExporter).extracting("delegate.client", as(InstanceOfAssertFactories.type(OkHttpClient.class))).extracting(OkHttpClient::callTimeoutMillis).isEqualTo((int) TimeUnit.SECONDS.toMillis(15));
assertThat(metricExporter.export(Lists.newArrayList(generateFakeMetric())).join(15, TimeUnit.SECONDS).isSuccess()).isTrue();
assertThat(server.metricRequests).hasSize(1);
assertThat(server.requestHeaders).anyMatch(headers -> headers.contains(":path", "/v1/metrics") && headers.contains("header-key", "header-value") && headers.contains("content-encoding", "gzip"));
assertThat(logExporter).extracting("delegate.client", as(InstanceOfAssertFactories.type(OkHttpClient.class))).extracting(OkHttpClient::callTimeoutMillis).isEqualTo((int) TimeUnit.SECONDS.toMillis(15));
assertThat(logExporter.export(Lists.newArrayList(generateFakeLog())).join(15, TimeUnit.SECONDS).isSuccess()).isTrue();
assertThat(server.logRequests).hasSize(1);
assertThat(server.requestHeaders).anyMatch(headers -> headers.contains(":path", "/v1/logs") && headers.contains("header-key", "header-value") && headers.contains("content-encoding", "gzip"));
}
use of io.opentelemetry.sdk.logs.export.LogExporter in project opentelemetry-java by open-telemetry.
the class OtlpHttpRetryTest method configureLogExporterRetryPolicy.
@Test
@SuppressLogger(OkHttpGrpcExporter.class)
void configureLogExporterRetryPolicy() {
Map<String, String> props = new HashMap<>();
props.put("otel.exporter.otlp.logs.protocol", "http/protobuf");
props.put("otel.exporter.otlp.logs.endpoint", "https://localhost:" + server.httpsPort() + "/v1/logs");
props.put("otel.exporter.otlp.logs.certificate", server.selfSignedCertificate.certificate().getPath());
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.sdk.logs.export.LogExporter in project opentelemetry-java by open-telemetry.
the class OtlpExporterIntegrationTest method testOtlpHttpLogExport.
@ParameterizedTest
@ValueSource(strings = { "gzip", "none" })
void testOtlpHttpLogExport(String compression) {
LogExporter otlpHttpLogExporter = OtlpHttpLogExporter.builder().setEndpoint("http://" + collector.getHost() + ":" + collector.getMappedPort(COLLECTOR_OTLP_HTTP_PORT) + "/v1/logs").setCompression(compression).build();
testLogExporter(otlpHttpLogExporter);
}
use of io.opentelemetry.sdk.logs.export.LogExporter in project opentelemetry-java by open-telemetry.
the class OtlpExporterIntegrationTest method testOtlpGrpcLogExport.
@ParameterizedTest
@ValueSource(strings = { "gzip", "none" })
void testOtlpGrpcLogExport(String compression) {
LogExporter otlpGrpcLogExporter = OtlpGrpcLogExporter.builder().setEndpoint("http://" + collector.getHost() + ":" + collector.getMappedPort(COLLECTOR_OTLP_GRPC_PORT)).setCompression(compression).build();
testLogExporter(otlpGrpcLogExporter);
}
use of io.opentelemetry.sdk.logs.export.LogExporter in project splunk-otel-java by signalfx.
the class LogExporterBuilderTest method testBuildSimple.
@Test
void testBuildSimple() {
Config config = mock(Config.class);
OtlpGrpcLogExporterBuilder builder = mock(OtlpGrpcLogExporterBuilder.class);
OtlpGrpcLogExporter expected = mock(OtlpGrpcLogExporter.class);
when(builder.addHeader(EXTRA_CONTENT_TYPE, STACKTRACES_HEADER_VALUE)).thenReturn(builder);
when(builder.build()).thenReturn(expected);
LogExporter exporter = LogExporterBuilder.fromConfig(config, () -> builder);
assertSame(expected, exporter);
verify(builder, never()).setEndpoint(anyString());
}
Aggregations