Skip to content

Commit

Permalink
fix: aligns http attributes names with latest open telemetry specific…
Browse files Browse the repository at this point in the history
…ation

Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Dec 18, 2024
1 parent 2e15fa5 commit d38411a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private Span startSpan(
GlobalOpenTelemetry.getTracer(obsOptions.getTracerInstrumentationName())
.spanBuilder(methodName + " - " + cleanedUriTemplate)
.startSpan();
span.setAttribute("http.uri_template", decodedUriTemplate);
span.setAttribute(URL_TEMPLATE, decodedUriTemplate);
return span;
}

Expand Down Expand Up @@ -725,11 +725,11 @@ private Response getHttpResponseMessage(
final String contentTypeHeaderValue = getHeaderValue(response, CONTENT_TYPE_HEADER_KEY);
if (contentTypeHeaderValue != null && !contentTypeHeaderValue.isEmpty()) {
spanForAttributes.setAttribute(
CUSTOM_HTTP_RESPONSE_CONTENT_TYPE, contentTypeHeaderValue);
HTTP_RESPONSE_HEADER_CONTENT_TYPE, contentTypeHeaderValue);
}
spanForAttributes.setAttribute(HTTP_RESPONSE_STATUS_CODE, response.code());
spanForAttributes.setAttribute(
NETWORK_PROTOCOL_VERSION,
NETWORK_PROTOCOL_NAME,
response.protocol().toString().toUpperCase(Locale.ROOT));
return this.retryCAEResponseIfRequired(
response, requestInfo, span, spanForAttributes, claims);
Expand Down Expand Up @@ -869,7 +869,7 @@ public MediaType contentType() {
final String contentType =
contentTypes.toArray(new String[] {})[0];
spanForAttributes.setAttribute(
CUSTOM_HTTP_REQUEST_CONTENT_TYPE, contentType);
HTTP_REQUEST_HEADER_CONTENT_TYPE, contentType);
return MediaType.parse(contentType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@ private TelemetrySemanticConventions() {}
/**
* Network connection protocol version
*/
public static final AttributeKey<String> NETWORK_PROTOCOL_VERSION =
stringKey("network.protocol.version"); // stable
public static final AttributeKey<String> NETWORK_PROTOCOL_NAME =
stringKey("network.protocol.name"); // stable

/**
* Full HTTP request URL
*/
public static final AttributeKey<String> URL_FULL = stringKey("url.full"); // stable

/**
* Full HTTP request URL template
*/
public static final AttributeKey<String> URL_TEMPLATE = stringKey("url.uri_template"); // custom

/**
* HTTP request URL scheme
*/
Expand Down Expand Up @@ -78,12 +83,12 @@ private TelemetrySemanticConventions() {}
/**
* HTTP response content type
*/
public static final AttributeKey<String> CUSTOM_HTTP_RESPONSE_CONTENT_TYPE =
stringKey("http.response_content_type"); // custom
public static final AttributeKey<String> HTTP_RESPONSE_HEADER_CONTENT_TYPE =
stringKey("http.response.header.content-type"); // stable

/**
* HTTP request content type
*/
public static final AttributeKey<String> CUSTOM_HTTP_REQUEST_CONTENT_TYPE =
stringKey("http.request_content_type"); // custom
public static final AttributeKey<String> HTTP_REQUEST_HEADER_CONTENT_TYPE =
stringKey("http.request.header.content-type"); // stable
}

0 comments on commit d38411a

Please sign in to comment.