Skip to content

Commit 72be770

Browse files
committed
fix revert request size attribute
1 parent c6da324 commit 72be770

9 files changed

Lines changed: 0 additions & 64 deletions

File tree

gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpRequestRunnable.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import com.google.api.client.json.JsonObjectParser;
4545
import com.google.api.client.json.gson.GsonFactory;
4646
import com.google.api.client.util.GenericData;
47-
import com.google.api.gax.tracing.ApiTracer;
4847
import com.google.auth.Credentials;
4948
import com.google.auth.http.HttpCredentialsAdapter;
5049
import com.google.auto.value.AutoValue;
@@ -113,14 +112,6 @@ public void run() {
113112
return;
114113
}
115114

116-
ApiTracer tracer = httpJsonCallOptions.getTracer();
117-
if (tracer != null) {
118-
// If the request is using transport encoding (e.g. gzip), this should be the compressed
119-
// size. getContent().getLength() returns the length of the content which would be the
120-
// compressed size if transport encoding is used.
121-
tracer.requestSent(httpRequest.getContent().getLength());
122-
}
123-
124115
httpResponse = httpRequest.execute();
125116

126117
// Check if already cancelled before trying to construct and read the response

gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/BodySizeRecordingTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,6 @@ void testBodySizeRecording() throws Exception {
138138

139139
callable.futureCall(request, callContext).get();
140140

141-
// Verify request size
142-
// The request body should be Field with number=42 (name is cleared in extractor)
143-
// HttpRequestRunnable re-serializes it compactly.
144-
String expectedRequestBody = "{\"number\":42}";
145-
long expectedRequestSize = expectedRequestBody.getBytes("UTF-8").length;
146-
assertThat(tracer.getRequestSentSize()).isEqualTo(expectedRequestSize);
147-
148141
// Verify response size
149142
// MockHttpService uses ProtoRestSerializer which pretty-prints.
150143
String expectedResponseBody = ProtoRestSerializer.create().toBody("*", response, false);
@@ -219,11 +212,6 @@ public void onComplete() {
219212

220213
assertThat(receivedResponses).hasSize(2);
221214

222-
// Verify request size
223-
String expectedRequestBody = "{\"number\":42}";
224-
long expectedRequestSize = expectedRequestBody.getBytes("UTF-8").length;
225-
assertThat(tracer.getRequestSentSize()).isEqualTo(expectedRequestSize);
226-
227215
// Verify response size
228216
// MockHttpService server-streaming response construction adds [ ] and ,
229217
String resp1Json = methodServerStreaming.getResponseParser().serialize(response1);

gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/testing/TestApiTracer.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class TestApiTracer implements ApiTracer {
4444
private final AtomicInteger attemptsStarted = new AtomicInteger();
4545
private final AtomicInteger attemptsFailed = new AtomicInteger();
4646
private final AtomicBoolean retriesExhausted = new AtomicBoolean(false);
47-
private final AtomicLong requestSentSize = new AtomicLong();
4847
private final AtomicLong responseReceivedSize = new AtomicLong();
4948

5049
public TestApiTracer() {}
@@ -61,10 +60,6 @@ public AtomicBoolean getRetriesExhausted() {
6160
return retriesExhausted;
6261
}
6362

64-
public long getRequestSentSize() {
65-
return requestSentSize.get();
66-
}
67-
6863
public long getResponseReceivedSize() {
6964
return responseReceivedSize.get();
7065
}
@@ -90,11 +85,6 @@ public void attemptFailedRetriesExhausted(Throwable error) {
9085
retriesExhausted.set(true);
9186
}
9287

93-
@Override
94-
public void requestSent(long requestSize) {
95-
requestSentSize.addAndGet(requestSize);
96-
}
97-
9888
@Override
9989
public void responseReceived(long responseSize) {
10090
responseReceivedSize.addAndGet(responseSize);

gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ default void responseReceived(long responseSize) {}
187187
default void requestSent() {}
188188
;
189189

190-
/** Adds an annotation that a streaming request has been sent with size. */
191-
default void requestSent(long requestSize) {}
192-
;
193-
194190
/**
195191
* Adds an annotation that a batch of writes has been flushed.
196192
*

gax-java/gax/src/main/java/com/google/api/gax/tracing/BaseApiTracer.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ public void requestSent() {
149149
// noop
150150
}
151151

152-
@Override
153-
public void requestSent(long requestSize) {
154-
// noop
155-
}
156-
157152
@Override
158153
public void batchRequestSent(long elementCount, long requestSize) {
159154
// noop

gax-java/gax/src/main/java/com/google/api/gax/tracing/ObservabilityAttributes.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ public class ObservabilityAttributes {
7474
/** The url template of the request (e.g. /v1/{name}:access). */
7575
public static final String URL_TEMPLATE_ATTRIBUTE = "url.template";
7676

77-
/** Size of the request body in bytes. */
78-
public static final String HTTP_REQUEST_BODY_SIZE = "http.request.body.size";
79-
8077
/** Size of the response body in bytes. */
8178
public static final String HTTP_RESPONSE_BODY_SIZE = "http.response.body.size";
8279
}

gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracer.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,6 @@ public void requestSent() {
422422
totalSentMessages.incrementAndGet();
423423
}
424424

425-
/** {@inheritDoc} */
426-
@Override
427-
public void requestSent(long requestSize) {
428-
requestSent();
429-
span.putAttribute(
430-
ObservabilityAttributes.HTTP_REQUEST_BODY_SIZE,
431-
AttributeValue.longAttributeValue(requestSize));
432-
}
433-
434425
/** {@inheritDoc} */
435426
@Override
436427
public void batchRequestSent(long elementCount, long requestSize) {

gax-java/gax/src/main/java/com/google/api/gax/tracing/SpanTracer.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ public void attemptSucceeded() {
8585
endAttempt();
8686
}
8787

88-
@Override
89-
public void requestSent(long requestSize) {
90-
if (attemptHandle != null) {
91-
attemptHandle.setAttribute(ObservabilityAttributes.HTTP_REQUEST_BODY_SIZE, requestSize);
92-
}
93-
}
94-
9588
@Override
9689
public void responseReceived(long responseSize) {
9790
if (attemptHandle != null) {

java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelTracing.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ void testTracing_httpjson_bodySizes() throws Exception {
205205
.findFirst()
206206
.orElseThrow(() -> new AssertionError("Attempt span 'Echo/Echo/attempt' not found"));
207207

208-
assertThat(
209-
attemptSpan
210-
.getAttributes()
211-
.get(AttributeKey.longKey(ObservabilityAttributes.HTTP_REQUEST_BODY_SIZE)))
212-
.isAtLeast(1L);
213208
assertThat(
214209
attemptSpan
215210
.getAttributes()

0 commit comments

Comments
 (0)