Search in sources :

Example 1 with OtlpGrpcLogExporter

use of io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter in project splunk-otel-java by signalfx.

the class LogExporterBuilderTest method testCustomEndpoint.

@Test
void testCustomEndpoint() {
    String endpoint = "http://example.com:9122/";
    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);
    when(config.getString(Configuration.CONFIG_KEY_OTEL_OTLP_URL, null)).thenReturn("http://shadowed.example.com:9122/");
    when(config.getString(Configuration.CONFIG_KEY_INGEST_URL, "http://shadowed.example.com:9122/")).thenReturn(endpoint);
    LogExporter exporter = LogExporterBuilder.fromConfig(config, () -> builder);
    assertNotNull(exporter);
    verify(builder).setEndpoint(endpoint);
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) LogExporter(io.opentelemetry.sdk.logs.export.LogExporter) OtlpGrpcLogExporter(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) OtlpGrpcLogExporterBuilder(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder) OtlpGrpcLogExporter(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter) Test(org.junit.jupiter.api.Test)

Example 2 with OtlpGrpcLogExporter

use of io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter 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);
}
Also used : OtlpHttpLogExporter(io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporter) LogExporter(io.opentelemetry.sdk.logs.export.LogExporter) OtlpGrpcLogExporter(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with OtlpGrpcLogExporter

use of io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter 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());
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) LogExporter(io.opentelemetry.sdk.logs.export.LogExporter) OtlpGrpcLogExporter(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter) OtlpGrpcLogExporterBuilder(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder) OtlpGrpcLogExporter(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter) Test(org.junit.jupiter.api.Test)

Aggregations

OtlpGrpcLogExporter (io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter)3 LogExporter (io.opentelemetry.sdk.logs.export.LogExporter)3 OtlpGrpcLogExporterBuilder (io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder)2 Config (io.opentelemetry.instrumentation.api.config.Config)2 Test (org.junit.jupiter.api.Test)2 OtlpHttpLogExporter (io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporter)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1