Skip to content

Commit

Permalink
Deprecate uncompressed content length HTTP attributes (#6383)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek authored Jul 29, 2022
1 parent 54b8b6a commit 5a152cd
Show file tree
Hide file tree
Showing 48 changed files with 12 additions and 618 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public void onEnd(
attributes,
SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH,
getter.requestContentLength(request, response));
internalSet(
attributes,
SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,
getter.requestContentLengthUncompressed(request, response));

if (response != null) {
Integer statusCode = getter.statusCode(request, response);
Expand All @@ -76,10 +72,6 @@ public void onEnd(
attributes,
SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH,
getter.responseContentLength(request, response));
internalSet(
attributes,
SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,
getter.responseContentLengthUncompressed(request, response));

for (String name : capturedResponseHeaders) {
List<String> values = getter.responseHeader(request, response, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ public interface HttpCommonAttributesGetter<REQUEST, RESPONSE> {
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, whether
* {@code response} is {@code null} or not.
*
* @deprecated This method is deprecated and will be removed in the next release.
*/
@Deprecated
@Nullable
Long requestContentLengthUncompressed(REQUEST request, @Nullable RESPONSE response);
default Long requestContentLengthUncompressed(REQUEST request, @Nullable RESPONSE response) {
throw new UnsupportedOperationException("This method is deprecated and will be removed");
}

/**
* Extracts the {@code http.status_code} span attribute.
Expand All @@ -70,9 +75,14 @@ public interface HttpCommonAttributesGetter<REQUEST, RESPONSE> {
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
* {@code response} is non-{@code null}.
*
* @deprecated This method is deprecated and will be removed in the next release.
*/
@Deprecated
@Nullable
Long responseContentLengthUncompressed(REQUEST request, RESPONSE response);
default Long responseContentLengthUncompressed(REQUEST request, RESPONSE response) {
throw new UnsupportedOperationException("This method is deprecated and will be removed");
}

/**
* Extracts all values of header named {@code name} from the response, or an empty list if there
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ public Long requestContentLength(Map<String, String> request, Map<String, String
return value == null ? null : Long.parseLong(value);
}

@Override
public Long requestContentLengthUncompressed(
Map<String, String> request, Map<String, String> response) {
String value = request.get("requestContentLengthUncompressed");
return value == null ? null : Long.parseLong(value);
}

@Override
public Integer statusCode(Map<String, String> request, Map<String, String> response) {
return Integer.parseInt(response.get("statusCode"));
Expand All @@ -71,13 +64,6 @@ public Long responseContentLength(Map<String, String> request, Map<String, Strin
return value == null ? null : Long.parseLong(value);
}

@Override
public Long responseContentLengthUncompressed(
Map<String, String> request, Map<String, String> response) {
String value = response.get("responseContentLengthUncompressed");
return value == null ? null : Long.parseLong(value);
}

@Override
public List<String> responseHeader(
Map<String, String> request, Map<String, String> response, String name) {
Expand All @@ -92,15 +78,13 @@ void normal() {
request.put("method", "POST");
request.put("url", "http://github.com");
request.put("requestContentLength", "10");
request.put("requestContentLengthUncompressed", "11");
request.put("flavor", "http/2");
request.put("header.user-agent", "okhttp 3.x");
request.put("header.custom-request-header", "123,456");

Map<String, String> response = new HashMap<>();
response.put("statusCode", "202");
response.put("responseContentLength", "20");
response.put("responseContentLengthUncompressed", "21");
response.put("header.custom-response-header", "654,321");

HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
Expand Down Expand Up @@ -130,11 +114,9 @@ void normal() {
AttributeKey.stringArrayKey("http.request.header.custom_request_header"),
asList("123", "456")),
entry(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, 10L),
entry(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, 11L),
entry(SemanticAttributes.HTTP_FLAVOR, "http/2"),
entry(SemanticAttributes.HTTP_STATUS_CODE, 202L),
entry(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, 20L),
entry(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED, 21L),
entry(
AttributeKey.stringArrayKey("http.response.header.custom_response_header"),
asList("654", "321")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ public Long requestContentLength(Map<String, String> request, Map<String, String
return value == null ? null : Long.parseLong(value);
}

@Override
public Long requestContentLengthUncompressed(
Map<String, String> request, Map<String, String> response) {
String value = request.get("requestContentLengthUncompressed");
return value == null ? null : Long.parseLong(value);
}

@Override
public Integer statusCode(Map<String, String> request, Map<String, String> response) {
String value = response.get("statusCode");
Expand All @@ -88,13 +81,6 @@ public Long responseContentLength(Map<String, String> request, Map<String, Strin
return value == null ? null : Long.parseLong(value);
}

@Override
public Long responseContentLengthUncompressed(
Map<String, String> request, Map<String, String> response) {
String value = response.get("responseContentLengthUncompressed");
return value == null ? null : Long.parseLong(value);
}

@Override
public List<String> responseHeader(
Map<String, String> request, Map<String, String> response, String name) {
Expand All @@ -111,7 +97,6 @@ void normal() {
request.put("target", "/repositories/1");
request.put("scheme", "http");
request.put("requestContentLength", "10");
request.put("requestContentLengthUncompressed", "11");
request.put("flavor", "http/2");
request.put("route", "/repositories/{id}");
request.put("serverName", "server");
Expand All @@ -123,7 +108,6 @@ void normal() {
Map<String, String> response = new HashMap<>();
response.put("statusCode", "202");
response.put("responseContentLength", "20");
response.put("responseContentLengthUncompressed", "21");
response.put("header.custom-response-header", "654,321");

Function<Context, String> routeFromContext = ctx -> "/repositories/{repoId}";
Expand Down Expand Up @@ -168,11 +152,9 @@ void normal() {
asList("123", "456")),
entry(SemanticAttributes.HTTP_SERVER_NAME, "server"),
entry(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, 10L),
entry(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, 11L),
entry(SemanticAttributes.HTTP_FLAVOR, "http/2"),
entry(SemanticAttributes.HTTP_STATUS_CODE, 202L),
entry(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, 20L),
entry(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED, 21L),
entry(
AttributeKey.stringArrayKey("http.response.header.custom_response_header"),
asList("654", "321")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ public Long requestContentLength(Void unused, @Nullable Void unused2) {
return 100L;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(Void unused, @Nullable Void unused2) {
return null;
}

@Override
public String flavor(Void unused, @Nullable Void unused2) {
return SemanticAttributes.HttpFlavorValues.HTTP_2_0;
Expand All @@ -106,12 +100,6 @@ public Long responseContentLength(Void unused, Void unused2) {
return 100L;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(Void unused, Void unused2) {
return null;
}

@Override
public List<String> responseHeader(Void unused, Void unused2, String name) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ public Long requestContentLength(HttpRequest httpRequest, @Nullable HttpResponse
return null;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(
HttpRequest httpRequest, @Nullable HttpResponse httpResponse) {
return null;
}

@Override
public Integer statusCode(HttpRequest httpRequest, HttpResponse httpResponse) {
return httpResponse.status().intValue();
Expand All @@ -59,13 +52,6 @@ public Long responseContentLength(HttpRequest httpRequest, HttpResponse httpResp
return null;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(
HttpRequest httpRequest, HttpResponse httpResponse) {
return null;
}

@Override
public List<String> responseHeader(
HttpRequest httpRequest, HttpResponse httpResponse, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ public Long requestContentLength(HttpRequest request, @Nullable HttpResponse htt
return null;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(
HttpRequest request, @Nullable HttpResponse httpResponse) {
return null;
}

@Override
public Integer statusCode(HttpRequest request, HttpResponse httpResponse) {
return httpResponse.status().intValue();
Expand All @@ -50,12 +43,6 @@ public Long responseContentLength(HttpRequest request, HttpResponse httpResponse
return null;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(HttpRequest request, HttpResponse httpResponse) {
return null;
}

@Override
public List<String> responseHeader(HttpRequest request, HttpResponse httpResponse, String name) {
return AkkaHttpUtil.responseHeader(httpResponse, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ public Long requestContentLength(
return null;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(
ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return null;
}

@Override
@Nullable
public Integer statusCode(ApacheHttpClientRequest request, HttpResponse response) {
Expand All @@ -64,13 +57,6 @@ public Long responseContentLength(ApacheHttpClientRequest request, HttpResponse
return null;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(
ApacheHttpClientRequest request, HttpResponse response) {
return null;
}

@Override
public List<String> responseHeader(
ApacheHttpClientRequest request, HttpResponse response, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ public Long requestContentLength(HttpMethod request, @Nullable HttpMethod respon
return null;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(HttpMethod request, @Nullable HttpMethod response) {
return null;
}

@Override
@Nullable
public Integer statusCode(HttpMethod request, HttpMethod response) {
Expand All @@ -73,12 +67,6 @@ public Long responseContentLength(HttpMethod request, HttpMethod response) {
return null;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(HttpMethod request, HttpMethod response) {
return null;
}

@Override
public List<String> responseHeader(HttpMethod request, HttpMethod response, String name) {
Header header = response.getResponseHeader(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ public Long requestContentLength(
return null;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(
ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return null;
}

@Override
public Integer statusCode(ApacheHttpClientRequest request, HttpResponse response) {
return response.getStatusLine().getStatusCode();
Expand All @@ -61,13 +54,6 @@ public Long responseContentLength(ApacheHttpClientRequest request, HttpResponse
return null;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(
ApacheHttpClientRequest request, HttpResponse response) {
return null;
}

@Override
public List<String> responseHeader(
ApacheHttpClientRequest request, HttpResponse response, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ public Long requestContentLength(
return null;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(
ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return null;
}

@Override
public Integer statusCode(ApacheHttpClientRequest request, HttpResponse response) {
return response.getStatusLine().getStatusCode();
Expand All @@ -63,13 +56,6 @@ public Long responseContentLength(ApacheHttpClientRequest request, HttpResponse
return null;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(
ApacheHttpClientRequest request, HttpResponse response) {
return null;
}

@Override
public List<String> responseHeader(
ApacheHttpClientRequest request, HttpResponse response, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ public Long requestContentLength(HttpRequest request, @Nullable HttpResponse res
return null;
}

@Override
@Nullable
public Long requestContentLengthUncompressed(
HttpRequest request, @Nullable HttpResponse response) {
return null;
}

@Override
public Integer statusCode(HttpRequest request, HttpResponse response) {
return response.getCode();
Expand Down Expand Up @@ -118,12 +111,6 @@ public Long responseContentLength(HttpRequest request, HttpResponse response) {
return null;
}

@Override
@Nullable
public Long responseContentLengthUncompressed(HttpRequest request, HttpResponse response) {
return null;
}

@Override
public List<String> responseHeader(HttpRequest request, HttpResponse response, String name) {
return getHeader(response, name);
Expand Down
Loading

0 comments on commit 5a152cd

Please sign in to comment.