use of io.opentelemetry.sdk.logs.export.LogExporter 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.sdk.logs.export.LogExporter in project opentelemetry-java by open-telemetry.
the class OtlpHttpConfigTest method configureLogExporter.
@Test
public void configureLogExporter() {
// Set values for general and signal specific properties. Signal specific should override
// general.
Map<String, String> props = new HashMap<>();
props.put("otel.exporter.otlp.protocol", "grpc");
props.put("otel.exporter.otlp.endpoint", "http://foo.bar");
props.put("otel.exporter.otlp.certificate", Paths.get("foo", "bar", "baz").toString());
props.put("otel.exporter.otlp.headers", "header-key=dummy-value");
props.put("otel.exporter.otlp.compression", "foo");
props.put("otel.exporter.otlp.timeout", "10s");
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.exporter.otlp.logs.headers", "header-key=header-value");
props.put("otel.exporter.otlp.logs.compression", "gzip");
props.put("otel.exporter.otlp.logs.timeout", "15s");
LogExporter logExporter = LogExporterConfiguration.configureOtlpLogs(DefaultConfigProperties.createForTest(props), MeterProvider.noop());
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"));
}
use of io.opentelemetry.sdk.logs.export.LogExporter in project opentelemetry-java by open-telemetry.
the class LogEmitterProviderConfiguration method configureLogProcessors.
// Visible for testing
static List<LogProcessor> configureLogProcessors(Map<String, LogExporter> exportersByName, MeterProvider meterProvider) {
Map<String, LogExporter> exportersByNameCopy = new HashMap<>(exportersByName);
List<LogProcessor> logProcessors = new ArrayList<>();
LogExporter exporter = exportersByNameCopy.remove("logging");
if (exporter != null) {
logProcessors.add(SimpleLogProcessor.create(exporter));
}
if (!exportersByNameCopy.isEmpty()) {
LogExporter compositeLogExporter = LogExporter.composite(exportersByNameCopy.values());
logProcessors.add(BatchLogProcessor.builder(compositeLogExporter).setMeterProvider(meterProvider).build());
}
return logProcessors;
}
use of io.opentelemetry.sdk.logs.export.LogExporter in project opentelemetry-java by open-telemetry.
the class OtlpExporterIntegrationTest method testOtlpHttpLogExport_mtls.
@Test
void testOtlpHttpLogExport_mtls() throws Exception {
LogExporter exporter = OtlpHttpLogExporter.builder().setEndpoint("https://" + collector.getHost() + ":" + collector.getMappedPort(COLLECTOR_OTLP_HTTP_MTLS_PORT) + "/v1/logs").setClientTls(clientTls.privateKey().getEncoded(), clientTls.certificate().getEncoded()).setTrustedCertificates(serverTls.certificate().getEncoded()).build();
testLogExporter(exporter);
}
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);
}
Aggregations