Skip to content

Commit

Permalink
bugfix: fixes wrong attribute to header mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed May 21, 2024
1 parent 9ce719f commit 37cf2a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,10 @@ private Response getHttpResponseMessage(
EXPERIMENTAL_HTTP_RESPONSE_BODY_SIZE, contentLengthHeaderValueAsLong);
}
final String contentTypeHeaderValue =
getHeaderValue(response, CONTENT_LENGTH_HEADER_KEY);
getHeaderValue(response, CONTENT_TYPE_HEADER_KEY);
if (contentTypeHeaderValue != null && !contentTypeHeaderValue.isEmpty()) {
spanForAttributes.setAttribute(
"http.response_content_type", contentTypeHeaderValue);
CUSTOM_HTTP_RESPONSE_CONTENT_TYPE, contentTypeHeaderValue);
}
spanForAttributes.setAttribute(HTTP_RESPONSE_STATUS_CODE, response.code());
spanForAttributes.setAttribute(
Expand Down Expand Up @@ -895,7 +895,7 @@ public MediaType contentType() {
final String contentType =
contentTypes.toArray(new String[] {})[0];
spanForAttributes.setAttribute(
"http.request_content_type", contentType);
CUSTOM_HTTP_REQUEST_CONTENT_TYPE, contentType);
return MediaType.parse(contentType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ private TelemetrySemanticConventions() {}
longKey("http.response.body.size"); // experimental
public static final AttributeKey<Long> EXPERIMENTAL_HTTP_REQUEST_BODY_SIZE =
longKey("http.request.body.size"); // experimental

public static final AttributeKey<String> CUSTOM_HTTP_RESPONSE_CONTENT_TYPE = stringKey("http.response_content_type"); // custom
public static final AttributeKey<String> CUSTOM_HTTP_REQUEST_CONTENT_TYPE = stringKey("http.request_content_type"); // custom
}

0 comments on commit 37cf2a7

Please sign in to comment.