Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ public OtlpHttpLogRecordExporterBuilder setConnectTimeout(Duration timeout) {
}

/**
* Sets the maximum OTLP HTTP request body size in bytes. If unset, defaults to 64 MiB.
* Sets the maximum OTLP HTTP request body size in bytes. If unset, defaults to 64 MiB. A value of
* 0 means no limit.
*
* @since 1.67.0
*/
public OtlpHttpLogRecordExporterBuilder setMaxRequestBodySize(long maxRequestBodySizeBytes) {
checkArgument(maxRequestBodySizeBytes > 0, "maxRequestBodySizeBytes must be positive");
checkArgument(maxRequestBodySizeBytes >= 0, "maxRequestBodySizeBytes must be non-negative");
delegate.setMaxRequestBodySize(maxRequestBodySizeBytes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ public OtlpHttpMetricExporterBuilder setConnectTimeout(Duration timeout) {
}

/**
* Sets the maximum OTLP HTTP request body size in bytes. If unset, defaults to 64 MiB.
* Sets the maximum OTLP HTTP request body size in bytes. If unset, defaults to 64 MiB. A value of
* 0 means no limit.
*
* @since 1.67.0
*/
public OtlpHttpMetricExporterBuilder setMaxRequestBodySize(long maxRequestBodySizeBytes) {
checkArgument(maxRequestBodySizeBytes > 0, "maxRequestBodySizeBytes must be positive");
checkArgument(maxRequestBodySizeBytes >= 0, "maxRequestBodySizeBytes must be non-negative");
delegate.setMaxRequestBodySize(maxRequestBodySizeBytes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ public OtlpHttpSpanExporterBuilder setConnectTimeout(Duration timeout) {
}

/**
* Sets the maximum OTLP HTTP request body size in bytes. If unset, defaults to 64 MiB.
* Sets the maximum OTLP HTTP request body size in bytes. If unset, defaults to 64 MiB. A value of
* 0 means no limit.
*
* @since 1.67.0
*/
public OtlpHttpSpanExporterBuilder setMaxRequestBodySize(long maxRequestBodySizeBytes) {
checkArgument(maxRequestBodySizeBytes > 0, "maxRequestBodySizeBytes must be positive");
checkArgument(maxRequestBodySizeBytes >= 0, "maxRequestBodySizeBytes must be non-negative");
delegate.setMaxRequestBodySize(maxRequestBodySizeBytes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ public GrpcExporterBuilder setExecutorService(ExecutorService executorService) {
}

public GrpcExporterBuilder setMaxRequestMessageSize(long maxRequestMessageSize) {
this.maxRequestMessageSize = maxRequestMessageSize;
this.maxRequestMessageSize =
maxRequestMessageSize == 0 ? Long.MAX_VALUE : maxRequestMessageSize;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public HttpExporterBuilder setExecutorService(ExecutorService executorService) {
}

public HttpExporterBuilder setMaxRequestBodySize(long maxRequestBodySize) {
this.maxRequestBodySize = maxRequestBodySize;
this.maxRequestBodySize = maxRequestBodySize == 0 ? Long.MAX_VALUE : maxRequestBodySize;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ public OtlpGrpcLogRecordExporterBuilder setConnectTimeout(Duration timeout) {
}

/**
* Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB.
* Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB. A value
* of 0 means no limit.
*
* @since 1.67.0
*/
public OtlpGrpcLogRecordExporterBuilder setMaxRequestMessageSize(
long maxRequestMessageSizeBytes) {
checkArgument(maxRequestMessageSizeBytes > 0, "maxRequestMessageSizeBytes must be positive");
checkArgument(
maxRequestMessageSizeBytes >= 0, "maxRequestMessageSizeBytes must be non-negative");
delegate.setMaxRequestMessageSize(maxRequestMessageSizeBytes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ public OtlpGrpcMetricExporterBuilder setConnectTimeout(Duration timeout) {
}

/**
* Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB.
* Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB. A value
* of 0 means no limit.
*
* @since 1.67.0
*/
public OtlpGrpcMetricExporterBuilder setMaxRequestMessageSize(long maxRequestMessageSizeBytes) {
checkArgument(maxRequestMessageSizeBytes > 0, "maxRequestMessageSizeBytes must be positive");
checkArgument(
maxRequestMessageSizeBytes >= 0, "maxRequestMessageSizeBytes must be non-negative");
delegate.setMaxRequestMessageSize(maxRequestMessageSizeBytes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ public OtlpGrpcSpanExporterBuilder setConnectTimeout(Duration timeout) {
}

/**
* Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB.
* Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB. A value
* of 0 means no limit.
*
* @since 1.67.0
*/
public OtlpGrpcSpanExporterBuilder setMaxRequestMessageSize(long maxRequestMessageSizeBytes) {
checkArgument(maxRequestMessageSizeBytes > 0, "maxRequestMessageSizeBytes must be positive");
checkArgument(
maxRequestMessageSizeBytes >= 0, "maxRequestMessageSizeBytes must be non-negative");
delegate.setMaxRequestMessageSize(maxRequestMessageSizeBytes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ public OtlpGrpcProfilesExporterBuilder setConnectTimeout(Duration timeout) {
return this;
}

/** Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB. */
/**
* Sets the maximum OTLP gRPC request message size in bytes. If unset, defaults to 64 MiB. A value
* of 0 means no limit.
*/
public OtlpGrpcProfilesExporterBuilder setMaxRequestMessageSize(long maxRequestMessageSizeBytes) {
checkArgument(maxRequestMessageSizeBytes > 0, "maxRequestMessageSizeBytes must be positive");
checkArgument(
maxRequestMessageSizeBytes >= 0, "maxRequestMessageSizeBytes must be non-negative");
delegate.setMaxRequestMessageSize(maxRequestMessageSizeBytes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,8 @@ void validConfig() {
.doesNotThrowAnyException();
assertThatCode(() -> buildAndShutdown(exporterBuilder().setMaxRequestSize(1)))
.doesNotThrowAnyException();
assertThatCode(() -> buildAndShutdown(exporterBuilder().setMaxRequestSize(0)))
.doesNotThrowAnyException();

assertThatCode(() -> exporterBuilder().setEndpoint("http://localhost:4317"))
.doesNotThrowAnyException();
Expand Down Expand Up @@ -1262,12 +1264,9 @@ void invalidConfig() {
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(
"Unsupported compressionMethod. Compression method must be \"none\" or one of: [base64,gzip]");
assertThatThrownBy(() -> exporterBuilder().setMaxRequestSize(0))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("maxRequestMessageSizeBytes must be positive");
assertThatThrownBy(() -> exporterBuilder().setMaxRequestSize(-1))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("maxRequestMessageSizeBytes must be positive");
.hasMessage("maxRequestMessageSizeBytes must be non-negative");

assertThatThrownBy(() -> exporterBuilder().setEnabledProtocols(null))
.isInstanceOf(NullPointerException.class)
Expand All @@ -1292,6 +1291,17 @@ void requestMessageSizeLimit() {
}
}

@Test
void requestMessageSizeLimitDisabledWithZero() {
try (TelemetryExporter<T> exporter =
exporterBuilder().setEndpoint(server.httpUri().toString()).setMaxRequestSize(0).build()) {
CompletableResultCode result =
exporter.export(Collections.singletonList(generateFakeTelemetry()));

assertThat(result.join(10, TimeUnit.SECONDS).isSuccess()).isTrue();
}
}

@Test
void toBuilderEquality()
throws CertificateEncodingException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,8 @@ void validConfig() {
.doesNotThrowAnyException();
assertThatCode(() -> buildAndShutdown(exporterBuilder().setMaxRequestSize(1)))
.doesNotThrowAnyException();
assertThatCode(() -> buildAndShutdown(exporterBuilder().setMaxRequestSize(0)))
.doesNotThrowAnyException();

assertThatCode(() -> exporterBuilder().setEndpoint("http://localhost:4318"))
.doesNotThrowAnyException();
Expand Down Expand Up @@ -1012,12 +1014,9 @@ void invalidConfig() {
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(
"Unsupported compressionMethod. Compression method must be \"none\" or one of: [base64,gzip]");
assertThatThrownBy(() -> exporterBuilder().setMaxRequestSize(0))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("maxRequestBodySizeBytes must be positive");
assertThatThrownBy(() -> exporterBuilder().setMaxRequestSize(-1))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("maxRequestBodySizeBytes must be positive");
.hasMessage("maxRequestBodySizeBytes must be non-negative");

assertThatThrownBy(() -> exporterBuilder().setEnabledProtocols(null))
.isInstanceOf(NullPointerException.class)
Expand All @@ -1042,6 +1041,17 @@ void requestBodySizeLimit() {
}
}

@Test
void requestBodySizeLimitDisabledWithZero() {
try (TelemetryExporter<T> exporter =
exporterBuilder().setEndpoint(server.httpUri() + path).setMaxRequestSize(0).build()) {
CompletableResultCode result =
exporter.export(Collections.singletonList(generateFakeTelemetry()));

assertThat(result.join(10, TimeUnit.SECONDS).isSuccess()).isTrue();
}
}

@Test
void toBuilderEquality()
throws CertificateEncodingException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ Stream<Arguments> createTestCases() {
.setMaxRequestBodySize(1234)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_http max_request_size 0",
new LogRecordExporterModel()
.setOtlpHttp(new OtlpHttpExporterModel().setMaxRequestSize(0)),
OtlpHttpLogRecordExporter.getDefault().toBuilder()
.setMaxRequestBodySize(Long.MAX_VALUE)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_grpc default",
new LogRecordExporterModel().setOtlpGrpc(new OtlpGrpcExporterModel()),
Expand Down Expand Up @@ -155,6 +163,14 @@ Stream<Arguments> createTestCases() {
.setMaxRequestMessageSize(1234)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_grpc max_request_size 0",
new LogRecordExporterModel()
.setOtlpGrpc(new OtlpGrpcExporterModel().setMaxRequestSize(0)),
OtlpGrpcLogRecordExporter.getDefault().toBuilder()
.setMaxRequestMessageSize(Long.MAX_VALUE)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_file/development",
LogRecordExporterModelAccessor.setOtlpFile(
Expand All @@ -176,7 +192,17 @@ Stream<Arguments> createInvalidTestCases() {
"unknown component provider",
new LogRecordExporterModel()
.setExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")),
"No component provider detected for io.opentelemetry.sdk.logs.export.LogRecordExporter with name \"unknown_key\"."));
"No component provider detected for io.opentelemetry.sdk.logs.export.LogRecordExporter with name \"unknown_key\"."),
Arguments.argumentSet(
"otlp_http negative max_request_size",
new LogRecordExporterModel()
.setOtlpHttp(new OtlpHttpExporterModel().setMaxRequestSize(-1)),
"Error configuring io.opentelemetry.sdk.logs.export.LogRecordExporter with name \"otlp_http\""),
Arguments.argumentSet(
"otlp_grpc negative max_request_size",
new LogRecordExporterModel()
.setOtlpGrpc(new OtlpGrpcExporterModel().setMaxRequestSize(-1)),
"Error configuring io.opentelemetry.sdk.logs.export.LogRecordExporter with name \"otlp_grpc\""));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ Stream<Arguments> createTestCases() {
Aggregation.base2ExponentialBucketHistogram()))
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_http max_request_size 0",
new PushMetricExporterModel()
.setOtlpHttp(new OtlpHttpMetricExporterModel().setMaxRequestSize(0)),
OtlpHttpMetricExporter.getDefault().toBuilder()
.setMaxRequestBodySize(Long.MAX_VALUE)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_grpc default",
new PushMetricExporterModel().setOtlpGrpc(new OtlpGrpcMetricExporterModel()),
Expand Down Expand Up @@ -181,6 +189,14 @@ Stream<Arguments> createTestCases() {
Aggregation.base2ExponentialBucketHistogram()))
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_grpc max_request_size 0",
new PushMetricExporterModel()
.setOtlpGrpc(new OtlpGrpcMetricExporterModel().setMaxRequestSize(0)),
OtlpGrpcMetricExporter.getDefault().toBuilder()
.setMaxRequestMessageSize(Long.MAX_VALUE)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"console",
new PushMetricExporterModel().setConsole(new ConsoleMetricExporterModel()),
Expand All @@ -206,7 +222,17 @@ Stream<Arguments> createInvalidTestCases() {
"unknown component provider",
new PushMetricExporterModel()
.setExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")),
"No component provider detected for io.opentelemetry.sdk.metrics.export.MetricExporter with name \"unknown_key\"."));
"No component provider detected for io.opentelemetry.sdk.metrics.export.MetricExporter with name \"unknown_key\"."),
Arguments.argumentSet(
"otlp_http negative max_request_size",
new PushMetricExporterModel()
.setOtlpHttp(new OtlpHttpMetricExporterModel().setMaxRequestSize(-1)),
"Error configuring io.opentelemetry.sdk.metrics.export.MetricExporter with name \"otlp_http\""),
Arguments.argumentSet(
"otlp_grpc negative max_request_size",
new PushMetricExporterModel()
.setOtlpGrpc(new OtlpGrpcMetricExporterModel().setMaxRequestSize(-1)),
"Error configuring io.opentelemetry.sdk.metrics.export.MetricExporter with name \"otlp_grpc\""));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ Stream<Arguments> createTestCases() {
.setMaxRequestBodySize(1234)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_http max_request_size 0",
new SpanExporterModel().setOtlpHttp(new OtlpHttpExporterModel().setMaxRequestSize(0)),
OtlpHttpSpanExporter.getDefault().toBuilder()
.setMaxRequestBodySize(Long.MAX_VALUE)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_grpc default",
new SpanExporterModel().setOtlpGrpc(new OtlpGrpcExporterModel()),
Expand Down Expand Up @@ -158,6 +165,13 @@ Stream<Arguments> createTestCases() {
.setMaxRequestMessageSize(1234)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"otlp_grpc max_request_size 0",
new SpanExporterModel().setOtlpGrpc(new OtlpGrpcExporterModel().setMaxRequestSize(0)),
OtlpGrpcSpanExporter.getDefault().toBuilder()
.setMaxRequestMessageSize(Long.MAX_VALUE)
.setComponentLoader(context)
.build()),
Arguments.argumentSet(
"console",
new SpanExporterModel().setConsole(new ConsoleExporterModel()),
Expand All @@ -183,7 +197,15 @@ Stream<Arguments> createInvalidTestCases() {
"unknown component provider",
new SpanExporterModel()
.setExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")),
"No component provider detected for io.opentelemetry.sdk.trace.export.SpanExporter with name \"unknown_key\"."));
"No component provider detected for io.opentelemetry.sdk.trace.export.SpanExporter with name \"unknown_key\"."),
Arguments.argumentSet(
"otlp_http negative max_request_size",
new SpanExporterModel().setOtlpHttp(new OtlpHttpExporterModel().setMaxRequestSize(-1)),
"Error configuring io.opentelemetry.sdk.trace.export.SpanExporter with name \"otlp_http\""),
Arguments.argumentSet(
"otlp_grpc negative max_request_size",
new SpanExporterModel().setOtlpGrpc(new OtlpGrpcExporterModel().setMaxRequestSize(-1)),
"Error configuring io.opentelemetry.sdk.trace.export.SpanExporter with name \"otlp_grpc\""));
}

@Test
Expand Down
Loading