Skip to content

Commit b665652

Browse files
authored
Response body bounds (#8224)
1 parent acc2b5d commit b665652

File tree

36 files changed

+807
-224
lines changed

36 files changed

+807
-224
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
Comparing source compatibility of opentelemetry-sdk-common-1.61.0-SNAPSHOT.jar against opentelemetry-sdk-common-1.60.1.jar
2-
No changes.
2+
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.common.export.GrpcSenderConfig (not serializable)
3+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
4+
+++ NEW METHOD: PUBLIC(+) long getMaxResponseBodySize()
5+
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.common.export.HttpSenderConfig (not serializable)
6+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
7+
+++ NEW METHOD: PUBLIC(+) long getMaxResponseBodySize()
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
Comparing source compatibility of opentelemetry-sdk-extension-jaeger-remote-sampler-1.61.0-SNAPSHOT.jar against opentelemetry-sdk-extension-jaeger-remote-sampler-1.60.1.jar
2-
No changes.
2+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.extension.trace.jaeger.sampler.JaegerRemoteSamplerBuilder (not serializable)
3+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
4+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.extension.trace.jaeger.sampler.JaegerRemoteSamplerBuilder setMaxSamplingStrategyResponseBodySize(long)

exporters/common/src/main/java/io/opentelemetry/exporter/internal/grpc/GrpcExporterBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ public GrpcExporter build() {
230230
isPlainHttp ? null : tlsConfigHelper.getSslContext(),
231231
isPlainHttp ? null : tlsConfigHelper.getTrustManager(),
232232
executorService,
233-
grpcChannel));
233+
grpcChannel,
234+
// 4mb to align with spec guidance - even though we don't do anything with the
235+
// response today, we will so better to have future-looking memory profile
236+
4 * 1024L * 1024L));
234237
LOGGER.log(Level.FINE, "Using GrpcSender: " + grpcSender.getClass().getName());
235238

236239
return new GrpcExporter(

exporters/common/src/main/java/io/opentelemetry/exporter/internal/grpc/ImmutableGrpcSenderConfig.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public static ImmutableGrpcSenderConfig create(
3737
@Nullable SSLContext sslContext,
3838
@Nullable X509TrustManager trustManager,
3939
@Nullable ExecutorService executorService,
40-
@Nullable Object managedChannel) {
40+
@Nullable Object managedChannel,
41+
long maxResponseBodySize) {
4142
return new AutoValue_ImmutableGrpcSenderConfig(
4243
endpoint,
4344
fullMethodName,
@@ -49,6 +50,10 @@ public static ImmutableGrpcSenderConfig create(
4950
sslContext,
5051
trustManager,
5152
executorService,
52-
managedChannel);
53+
managedChannel,
54+
maxResponseBodySize);
5355
}
56+
57+
@Override
58+
public abstract long getMaxResponseBodySize();
5459
}

exporters/common/src/main/java/io/opentelemetry/exporter/internal/http/HttpExporterBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ public HttpExporter build() {
245245
retryPolicy,
246246
isPlainHttp ? null : tlsConfigHelper.getSslContext(),
247247
isPlainHttp ? null : tlsConfigHelper.getTrustManager(),
248-
executorService));
248+
executorService,
249+
// 4mb to align with spec guidance - even though we don't do anything with the
250+
// response today, we will so better to have future-looking memory profile
251+
4 * 1024L * 1024L));
249252
LOGGER.log(Level.FINE, "Using HttpSender: " + httpSender.getClass().getName());
250253

251254
return new HttpExporter(

exporters/common/src/main/java/io/opentelemetry/exporter/internal/http/ImmutableHttpSenderConfig.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ static HttpSenderConfig create(
3535
@Nullable RetryPolicy retryPolicy,
3636
@Nullable SSLContext sslContext,
3737
@Nullable X509TrustManager trustManager,
38-
@Nullable ExecutorService executorService) {
38+
@Nullable ExecutorService executorService,
39+
long maxResponseBodySize) {
3940
return new AutoValue_ImmutableHttpSenderConfig(
4041
endpoint,
4142
contentType,
@@ -47,6 +48,10 @@ static HttpSenderConfig create(
4748
retryPolicy,
4849
sslContext,
4950
trustManager,
50-
executorService);
51+
executorService,
52+
maxResponseBodySize);
5153
}
54+
55+
@Override
56+
public abstract long getMaxResponseBodySize();
5257
}

exporters/common/src/test/java/io/opentelemetry/exporter/internal/grpc/GrpcExporterTest.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.net.URI;
2929
import java.time.Duration;
3030
import java.util.function.Consumer;
31+
import javax.annotation.Nullable;
3132
import org.junit.jupiter.api.Test;
3233
import org.junit.jupiter.params.ParameterizedTest;
3334
import org.junit.jupiter.params.provider.EnumSource;
@@ -120,8 +121,7 @@ void testInternalTelemetry(StandardComponentId.ExporterType exporterType) {
120121
pa.hasAttributes(expectedAttributes)
121122
.hasValue(42))));
122123

123-
onResponse.accept(
124-
ImmutableGrpcResponse.create(GrpcStatusCode.OK, null, new byte[0]));
124+
onResponse.accept(grpcResponse(GrpcStatusCode.OK));
125125

126126
return null;
127127
})
@@ -133,7 +133,7 @@ void testInternalTelemetry(StandardComponentId.ExporterType exporterType) {
133133
doAnswer(
134134
invoc -> {
135135
Consumer<GrpcResponse> onResponse = invoc.getArgument(1);
136-
onResponse.accept(ImmutableGrpcResponse.create(UNAVAILABLE, null, new byte[0]));
136+
onResponse.accept(grpcResponse(UNAVAILABLE));
137137

138138
return null;
139139
})
@@ -224,4 +224,24 @@ void testInternalTelemetry(StandardComponentId.ExporterType exporterType) {
224224
.hasBucketCounts(1))));
225225
}
226226
}
227+
228+
private static GrpcResponse grpcResponse(GrpcStatusCode statusCode) {
229+
return new GrpcResponse() {
230+
@Override
231+
public GrpcStatusCode getStatusCode() {
232+
return statusCode;
233+
}
234+
235+
@Override
236+
@Nullable
237+
public String getStatusDescription() {
238+
return null;
239+
}
240+
241+
@Override
242+
public byte[] getResponseMessage() {
243+
return new byte[0];
244+
}
245+
};
246+
}
227247
}

exporters/otlp/all/src/jmh/java/io/opentelemetry/exporter/otlp/trace/OltpExporterBenchmark.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public void setUp() {
110110
null,
111111
null,
112112
null,
113-
null),
113+
null,
114+
Long.MAX_VALUE),
114115
InternalTelemetryVersion.LATEST,
115116
ComponentId.generateLazy(StandardComponentId.ExporterType.OTLP_GRPC_SPAN_EXPORTER),
116117
MeterProvider::noop,

exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void usingOkHttp() throws Exception {
4242
@Override // whilst profile signal type is in development it uses a different error message
4343
@SuppressLogger(GrpcExporter.class)
4444
protected void testExport_Unimplemented() {
45-
addGrpcError(GrpcStatusCode.UNIMPLEMENTED, "UNIMPLEMENTED");
45+
addGrpcResponse(GrpcStatusCode.UNIMPLEMENTED, "UNIMPLEMENTED");
4646

4747
TelemetryExporter<ProfileData> exporter = nonRetryingExporter();
4848

0 commit comments

Comments
 (0)