From 6c3010dd08f7b7af553289d54ca97b6dce37d4b8 Mon Sep 17 00:00:00 2001 From: jack-berg <34418638+jack-berg@users.noreply.github.com> Date: Tue, 5 Oct 2021 18:24:06 -0500 Subject: [PATCH 1/2] Change otlp http/protobuf default port from 4317 to 4318 (#3694) --- CHANGELOG.md | 4 + .../http/logs/OtlpHttpLogExporterBuilder.java | 2 +- .../OtlpHttpMetricExporterBuilder.java | 2 +- .../metrics/OtlpHttpMetricExporterTest.java | 2 +- .../trace/OtlpHttpSpanExporterBuilder.java | 2 +- .../http/trace/OtlpHttpSpanExporterTest.java | 2 +- sdk-extensions/autoconfigure/README.md | 6 +- .../sdk/autoconfigure/OtlpConfigUtilTest.java | 102 +++++++++--------- 8 files changed, 63 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0fdeac4b08..ee37aa58913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ contain generated protobuf classes for the Jaeger API. If you were using these i you must update your build configuration to also include the new `jaeger-proto` artifact. This artifact will not be included in a future 2.0 release of the SDK so it is recommended to instead generated the protobuf classes in your own build. +- BREAKING CHANGE: The `opentelemetry-exporter-otlp-http-*` exporter default endpoint ports have + changed from `4317` to `4318`, in line + with [recent changes](https://github.com/open-telemetry/opentelemetry-specification/pull/1970) to + the spec. ### Auto-configuration (alpha) diff --git a/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java b/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java index 17f77e52380..1085d73dd0c 100644 --- a/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java +++ b/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java @@ -23,7 +23,7 @@ public final class OtlpHttpLogExporterBuilder { private static final long DEFAULT_TIMEOUT_SECS = 10; - private static final String DEFAULT_ENDPOINT = "http://localhost:4317/v1/logs"; + private static final String DEFAULT_ENDPOINT = "http://localhost:4318/v1/logs"; private long timeoutNanos = TimeUnit.SECONDS.toNanos(DEFAULT_TIMEOUT_SECS); private String endpoint = DEFAULT_ENDPOINT; diff --git a/exporters/otlp-http/metrics/src/main/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterBuilder.java b/exporters/otlp-http/metrics/src/main/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterBuilder.java index 263eb10506c..05524579a66 100644 --- a/exporters/otlp-http/metrics/src/main/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterBuilder.java +++ b/exporters/otlp-http/metrics/src/main/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterBuilder.java @@ -23,7 +23,7 @@ public final class OtlpHttpMetricExporterBuilder { private static final long DEFAULT_TIMEOUT_SECS = 10; - private static final String DEFAULT_ENDPOINT = "http://localhost:4317/v1/metrics"; + private static final String DEFAULT_ENDPOINT = "http://localhost:4318/v1/metrics"; private long timeoutNanos = TimeUnit.SECONDS.toNanos(DEFAULT_TIMEOUT_SECS); private String endpoint = DEFAULT_ENDPOINT; diff --git a/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java b/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java index 07b2e19f30b..41b3a6d2beb 100644 --- a/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java +++ b/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java @@ -108,7 +108,7 @@ void validConfig() { assertThatCode(() -> OtlpHttpMetricExporter.builder().setTimeout(Duration.ofMillis(10))) .doesNotThrowAnyException(); - assertThatCode(() -> OtlpHttpMetricExporter.builder().setEndpoint("http://localhost:4317")) + assertThatCode(() -> OtlpHttpMetricExporter.builder().setEndpoint("http://localhost:4318")) .doesNotThrowAnyException(); assertThatCode(() -> OtlpHttpMetricExporter.builder().setEndpoint("http://localhost")) .doesNotThrowAnyException(); diff --git a/exporters/otlp-http/trace/src/main/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterBuilder.java b/exporters/otlp-http/trace/src/main/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterBuilder.java index e58acad1550..75640899f83 100644 --- a/exporters/otlp-http/trace/src/main/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterBuilder.java +++ b/exporters/otlp-http/trace/src/main/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterBuilder.java @@ -23,7 +23,7 @@ public final class OtlpHttpSpanExporterBuilder { private static final long DEFAULT_TIMEOUT_SECS = 10; - private static final String DEFAULT_ENDPOINT = "http://localhost:4317/v1/traces"; + private static final String DEFAULT_ENDPOINT = "http://localhost:4318/v1/traces"; private long timeoutNanos = TimeUnit.SECONDS.toNanos(DEFAULT_TIMEOUT_SECS); private String endpoint = DEFAULT_ENDPOINT; diff --git a/exporters/otlp-http/trace/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java b/exporters/otlp-http/trace/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java index 9096abcffb2..5b58bc4e6b6 100644 --- a/exporters/otlp-http/trace/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java +++ b/exporters/otlp-http/trace/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java @@ -109,7 +109,7 @@ void validConfig() { assertThatCode(() -> OtlpHttpSpanExporter.builder().setTimeout(Duration.ofMillis(10))) .doesNotThrowAnyException(); - assertThatCode(() -> OtlpHttpSpanExporter.builder().setEndpoint("http://localhost:4317")) + assertThatCode(() -> OtlpHttpSpanExporter.builder().setEndpoint("http://localhost:4318")) .doesNotThrowAnyException(); assertThatCode(() -> OtlpHttpSpanExporter.builder().setEndpoint("http://localhost")) .doesNotThrowAnyException(); diff --git a/sdk-extensions/autoconfigure/README.md b/sdk-extensions/autoconfigure/README.md index 4c9afa508ef..265b5907946 100644 --- a/sdk-extensions/autoconfigure/README.md +++ b/sdk-extensions/autoconfigure/README.md @@ -50,9 +50,9 @@ The [OpenTelemetry Protocol (OTLP)](https://github.com/open-telemetry/openteleme |------------------------------|-----------------------------|---------------------------------------------------------------------------| | otel.traces.exporter=otlp (default) | OTEL_TRACES_EXPORTER=otlp | Select the OpenTelemetry exporter for tracing (default) | | otel.metrics.exporter=otlp | OTEL_METRICS_EXPORTER=otlp | Select the OpenTelemetry exporter for metrics | -| otel.exporter.otlp.endpoint | OTEL_EXPORTER_OTLP_ENDPOINT | The OTLP traces and metrics endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. If protocol is `http/protobuf` the version and signal will be appended to the path (e.g. `v1/traces` or `v1/metrics`). Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4317/v1/{signal}` when protocol is `http/protobuf`. | -| otel.exporter.otlp.traces.endpoint | OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | The OTLP traces endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4317/v1/traces` when protocol is `http/protobuf`. | -| otel.exporter.otlp.metrics.endpoint | OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | The OTLP metrics endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4317/v1/metrics` when protocol is `http/protobuf`. | +| otel.exporter.otlp.endpoint | OTEL_EXPORTER_OTLP_ENDPOINT | The OTLP traces and metrics endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. If protocol is `http/protobuf` the version and signal will be appended to the path (e.g. `v1/traces` or `v1/metrics`). Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/{signal}` when protocol is `http/protobuf`. | +| otel.exporter.otlp.traces.endpoint | OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | The OTLP traces endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/traces` when protocol is `http/protobuf`. | +| otel.exporter.otlp.metrics.endpoint | OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | The OTLP metrics endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/metrics` when protocol is `http/protobuf`. | | otel.exporter.otlp.certificate | OTEL_EXPORTER_OTLP_CERTIFICATE | The path to the file containing trusted certificates to use when verifying an OTLP trace or metric server's TLS credentials. The file should contain one or more X.509 certificates in PEM format. By default the host platform's trusted root certificates are used. | | otel.exporter.otlp.traces.certificate | OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE | The path to the file containing trusted certificates to use when verifying an OTLP trace server's TLS credentials. The file should contain one or more X.509 certificates in PEM format. By default the host platform's trusted root certificates are used. | | otel.exporter.otlp.metrics.certificate | OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE | The path to the file containing trusted certificates to use when verifying an OTLP metric server's TLS credentials. The file should contain one or more X.509 certificates in PEM format. By default the host platform's trusted root certificates are used. | diff --git a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtilTest.java b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtilTest.java index 26f7ab9c572..4b8d88b601f 100644 --- a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtilTest.java +++ b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtilTest.java @@ -96,7 +96,7 @@ void configureOtlpExporterBuilder_ValidEndpoints() { configureEndpointCallable( ImmutableMap.of( GENERIC_ENDPOINT_KEY, - "http://localhost:4317/path", + "http://localhost:4318/path", "otel.exporter.otlp.protocol", "http/protobuf"))) .doesNotThrowAnyException(); @@ -141,77 +141,77 @@ private static ThrowingCallable configureEndpointCallable(Map<String, String> pr void configureOtlpExporterBuilder_HttpGenericEndpointKey() { assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4317")) - .isEqualTo("http://localhost:4317/v1/traces"); + DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4318")) + .isEqualTo("http://localhost:4318/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4317/")) - .isEqualTo("http://localhost:4317/v1/traces"); + DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4318/")) + .isEqualTo("http://localhost:4318/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4317/foo")) - .isEqualTo("http://localhost:4317/foo/v1/traces"); + DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4318/foo")) + .isEqualTo("http://localhost:4318/foo/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4317/foo/")) - .isEqualTo("http://localhost:4317/foo/v1/traces"); + DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4318/foo/")) + .isEqualTo("http://localhost:4318/foo/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4317/v1/traces")) - .isEqualTo("http://localhost:4317/v1/traces/v1/traces"); + DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4318/v1/traces")) + .isEqualTo("http://localhost:4318/v1/traces/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4317/v1/metrics")) - .isEqualTo("http://localhost:4317/v1/metrics/v1/traces"); + DATA_TYPE_TRACES, GENERIC_ENDPOINT_KEY, "http://localhost:4318/v1/metrics")) + .isEqualTo("http://localhost:4318/v1/metrics/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4317")) - .isEqualTo("http://localhost:4317/v1/metrics"); + DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4318")) + .isEqualTo("http://localhost:4318/v1/metrics"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4317/")) - .isEqualTo("http://localhost:4317/v1/metrics"); + DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4318/")) + .isEqualTo("http://localhost:4318/v1/metrics"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4317/foo")) - .isEqualTo("http://localhost:4317/foo/v1/metrics"); + DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4318/foo")) + .isEqualTo("http://localhost:4318/foo/v1/metrics"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4317/foo/")) - .isEqualTo("http://localhost:4317/foo/v1/metrics"); + DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4318/foo/")) + .isEqualTo("http://localhost:4318/foo/v1/metrics"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4317/v1/metrics")) - .isEqualTo("http://localhost:4317/v1/metrics/v1/metrics"); + DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4318/v1/metrics")) + .isEqualTo("http://localhost:4318/v1/metrics/v1/metrics"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4317/v1/traces")) - .isEqualTo("http://localhost:4317/v1/traces/v1/metrics"); + DATA_TYPE_METRICS, GENERIC_ENDPOINT_KEY, "http://localhost:4318/v1/traces")) + .isEqualTo("http://localhost:4318/v1/traces/v1/metrics"); } @Test void configureOtlpExporterBuilder_HttpTracesEndpointKey() { assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4317")) - .isEqualTo("http://localhost:4317/"); + DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4318")) + .isEqualTo("http://localhost:4318/"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4317")) - .isEqualTo("http://localhost:4317/"); + DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4318")) + .isEqualTo("http://localhost:4318/"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4317/")) - .isEqualTo("http://localhost:4317/"); + DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4318/")) + .isEqualTo("http://localhost:4318/"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4317/v1/traces")) - .isEqualTo("http://localhost:4317/v1/traces"); + DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4318/v1/traces")) + .isEqualTo("http://localhost:4318/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4317/foo/bar")) - .isEqualTo("http://localhost:4317/foo/bar"); + DATA_TYPE_TRACES, TRACES_ENDPOINT_KEY, "http://localhost:4318/foo/bar")) + .isEqualTo("http://localhost:4318/foo/bar"); assertThat( configureEndpoint( DATA_TYPE_TRACES, @@ -219,34 +219,34 @@ void configureOtlpExporterBuilder_HttpTracesEndpointKey() { "otel.exporter.otlp.protocol", PROTOCOL_HTTP_PROTOBUF, GENERIC_ENDPOINT_KEY, - "http://localhost:4317/foo/bar", + "http://localhost:4318/foo/bar", TRACES_ENDPOINT_KEY, - "http://localhost:4317/baz/qux"))) - .isEqualTo("http://localhost:4317/baz/qux"); + "http://localhost:4318/baz/qux"))) + .isEqualTo("http://localhost:4318/baz/qux"); } @Test void configureOtlpExporterBuilder_HttpMetricsEndpointKey() { assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4317")) - .isEqualTo("http://localhost:4317/"); + DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4318")) + .isEqualTo("http://localhost:4318/"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4317")) - .isEqualTo("http://localhost:4317/"); + DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4318")) + .isEqualTo("http://localhost:4318/"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4317/")) - .isEqualTo("http://localhost:4317/"); + DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4318/")) + .isEqualTo("http://localhost:4318/"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4317/v1/traces")) - .isEqualTo("http://localhost:4317/v1/traces"); + DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4318/v1/traces")) + .isEqualTo("http://localhost:4318/v1/traces"); assertThat( configureEndpointForHttp( - DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4317/foo/bar")) - .isEqualTo("http://localhost:4317/foo/bar"); + DATA_TYPE_METRICS, METRICS_ENDPOINT_KEY, "http://localhost:4318/foo/bar")) + .isEqualTo("http://localhost:4318/foo/bar"); assertThat( configureEndpoint( DATA_TYPE_METRICS, @@ -254,10 +254,10 @@ void configureOtlpExporterBuilder_HttpMetricsEndpointKey() { "otel.exporter.otlp.protocol", PROTOCOL_HTTP_PROTOBUF, GENERIC_ENDPOINT_KEY, - "http://localhost:4317/foo/bar", + "http://localhost:4318/foo/bar", METRICS_ENDPOINT_KEY, - "http://localhost:4317/baz/qux"))) - .isEqualTo("http://localhost:4317/baz/qux"); + "http://localhost:4318/baz/qux"))) + .isEqualTo("http://localhost:4318/baz/qux"); } private static String configureEndpointForHttp( From 8d7cca7caea1a322d6cee8abef6fa49fe9a3c0e4 Mon Sep 17 00:00:00 2001 From: jack-berg <34418638+jack-berg@users.noreply.github.com> Date: Tue, 5 Oct 2021 18:33:09 -0500 Subject: [PATCH 2/2] Add missing none compression support to OtlpHttpLogExporter (#3693) --- .../http/logs/OtlpHttpLogExporterBuilder.java | 12 +++--- .../http/logs/OtlpHttpLogExporterTest.java | 42 ++++++++++++++++++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java b/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java index 1085d73dd0c..ac0b59e1aac 100644 --- a/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java +++ b/exporters/otlp-http/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterBuilder.java @@ -76,15 +76,17 @@ public OtlpHttpLogExporterBuilder setEndpoint(String endpoint) { } /** - * Sets the method used to compress payloads. If unset, compression is disabled. Currently the - * only supported compression method is "gzip". + * Sets the method used to compress payloads. If unset, compression is disabled. Currently + * supported compression methods include "gzip" and "none". */ public OtlpHttpLogExporterBuilder setCompression(String compressionMethod) { requireNonNull(compressionMethod, "compressionMethod"); checkArgument( - compressionMethod.equals("gzip"), - "Unsupported compression method. Supported compression methods include: gzip."); - this.compressionEnabled = true; + compressionMethod.equals("gzip") || compressionMethod.equals("none"), + "Unsupported compression method. Supported compression methods include: gzip, none."); + if (compressionMethod.equals("gzip")) { + this.compressionEnabled = true; + } return this; } diff --git a/exporters/otlp-http/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java b/exporters/otlp-http/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java index 66644d382be..da28d3518d8 100644 --- a/exporters/otlp-http/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java +++ b/exporters/otlp-http/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.exporter.otlp.http.logs; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.google.protobuf.InvalidProtocolBufferException; @@ -37,6 +38,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; +import java.time.Duration; import java.time.Instant; import java.util.Arrays; import java.util.Collections; @@ -94,6 +96,43 @@ void setup() { .addHeader("foo", "bar"); } + @Test + @SuppressWarnings("PreferJavaTimeOverload") + void validConfig() { + assertThatCode(() -> OtlpHttpLogExporter.builder().setTimeout(0, TimeUnit.MILLISECONDS)) + .doesNotThrowAnyException(); + assertThatCode(() -> OtlpHttpLogExporter.builder().setTimeout(Duration.ofMillis(0))) + .doesNotThrowAnyException(); + assertThatCode(() -> OtlpHttpLogExporter.builder().setTimeout(10, TimeUnit.MILLISECONDS)) + .doesNotThrowAnyException(); + assertThatCode(() -> OtlpHttpLogExporter.builder().setTimeout(Duration.ofMillis(10))) + .doesNotThrowAnyException(); + + assertThatCode(() -> OtlpHttpLogExporter.builder().setEndpoint("http://localhost:4317")) + .doesNotThrowAnyException(); + assertThatCode(() -> OtlpHttpLogExporter.builder().setEndpoint("http://localhost")) + .doesNotThrowAnyException(); + assertThatCode(() -> OtlpHttpLogExporter.builder().setEndpoint("https://localhost")) + .doesNotThrowAnyException(); + assertThatCode(() -> OtlpHttpLogExporter.builder().setEndpoint("http://foo:bar@localhost")) + .doesNotThrowAnyException(); + + assertThatCode(() -> OtlpHttpLogExporter.builder().setCompression("gzip")) + .doesNotThrowAnyException(); + assertThatCode(() -> OtlpHttpLogExporter.builder().setCompression("none")) + .doesNotThrowAnyException(); + + assertThatCode( + () -> OtlpHttpLogExporter.builder().addHeader("foo", "bar").addHeader("baz", "qux")) + .doesNotThrowAnyException(); + + assertThatCode( + () -> + OtlpHttpLogExporter.builder() + .setTrustedCertificates("foobar".getBytes(StandardCharsets.UTF_8))) + .doesNotThrowAnyException(); + } + @Test @SuppressWarnings("PreferJavaTimeOverload") void invalidConfig() { @@ -125,7 +164,8 @@ void invalidConfig() { .hasMessage("compressionMethod"); assertThatThrownBy(() -> OtlpHttpLogExporter.builder().setCompression("foo")) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unsupported compression method. Supported compression methods include: gzip."); + .hasMessage( + "Unsupported compression method. Supported compression methods include: gzip, none."); } @Test