From d38411a5d4351b2b0ed5f59180d278ee16813064 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 18 Dec 2024 10:49:43 -0500 Subject: [PATCH] fix: aligns http attributes names with latest open telemetry specification Signed-off-by: Vincent Biret --- .../kiota/http/OkHttpRequestAdapter.java | 8 ++++---- .../http/TelemetrySemanticConventions.java | 17 +++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java index b634cf7da..1b830f71e 100644 --- a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java +++ b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java @@ -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; } @@ -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); @@ -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); } } diff --git a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java index f55d8e3bc..7ac1ac94a 100644 --- a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java +++ b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java @@ -40,14 +40,19 @@ private TelemetrySemanticConventions() {} /** * Network connection protocol version */ - public static final AttributeKey NETWORK_PROTOCOL_VERSION = - stringKey("network.protocol.version"); // stable + public static final AttributeKey NETWORK_PROTOCOL_NAME = + stringKey("network.protocol.name"); // stable /** * Full HTTP request URL */ public static final AttributeKey URL_FULL = stringKey("url.full"); // stable + /** + * Full HTTP request URL template + */ + public static final AttributeKey URL_TEMPLATE = stringKey("url.uri_template"); // custom + /** * HTTP request URL scheme */ @@ -78,12 +83,12 @@ private TelemetrySemanticConventions() {} /** * HTTP response content type */ - public static final AttributeKey CUSTOM_HTTP_RESPONSE_CONTENT_TYPE = - stringKey("http.response_content_type"); // custom + public static final AttributeKey HTTP_RESPONSE_HEADER_CONTENT_TYPE = + stringKey("http.response.header.content-type"); // stable /** * HTTP request content type */ - public static final AttributeKey CUSTOM_HTTP_REQUEST_CONTENT_TYPE = - stringKey("http.request_content_type"); // custom + public static final AttributeKey HTTP_REQUEST_HEADER_CONTENT_TYPE = + stringKey("http.request.header.content-type"); // stable }