diff --git a/semantic-convention-utils/src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java b/semantic-convention-utils/src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java index e594692a8..18493e92f 100644 --- a/semantic-convention-utils/src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java +++ b/semantic-convention-utils/src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java @@ -184,8 +184,10 @@ public static boolean isAbsoluteUrl(String urlStr) { */ public static Optional getHttpUrlForOTelFormat( Map attributeValueMap) { - if (attributeValueMap.containsKey(HTTP_URL.getValue())) { - return Optional.of(attributeValueMap.get(HTTP_URL.getValue()).getValue()); + Optional httpUrlForOTelFormat = Optional.empty(); + if (attributeValueMap.containsKey(HTTP_URL.getValue()) + && isAbsoluteUrl(attributeValueMap.get(HTTP_URL.getValue()).getValue())) { + httpUrlForOTelFormat = Optional.of(attributeValueMap.get(HTTP_URL.getValue()).getValue()); } else if (attributeValueMap.containsKey(HTTP_SCHEME.getValue()) && attributeValueMap.containsKey(HTTP_HOST.getValue()) && attributeValueMap.containsKey(HTTP_TARGET.getValue())) { @@ -195,15 +197,19 @@ public static Optional getHttpUrlForOTelFormat( attributeValueMap.get(HTTP_SCHEME.getValue()).getValue(), attributeValueMap.get(HTTP_HOST.getValue()).getValue(), attributeValueMap.get(HTTP_TARGET.getValue()).getValue()); - return Optional.of(url); + httpUrlForOTelFormat = Optional.of(url); } else if (SpanSemanticConventionUtils.isClientSpanForOtelFormat(attributeValueMap) || SpanSemanticConventionUtils.isClientSpanForOCFormat(attributeValueMap)) { - return getHttpUrlForOtelFormatClientSpan(attributeValueMap); + httpUrlForOTelFormat = getHttpUrlForOtelFormatClientSpan(attributeValueMap); } else if (SpanSemanticConventionUtils.isServerSpanForOtelFormat(attributeValueMap) || SpanSemanticConventionUtils.isServerSpanForOCFormat(attributeValueMap)) { - return getHttpUrlForOtelFormatServerSpan(attributeValueMap); + httpUrlForOTelFormat = getHttpUrlForOtelFormatServerSpan(attributeValueMap); } - return Optional.empty(); + + if (httpUrlForOTelFormat.isEmpty() && attributeValueMap.containsKey(HTTP_URL.getValue())) { + return Optional.of(attributeValueMap.get(HTTP_URL.getValue()).getValue()); + } + return httpUrlForOTelFormat; } private static Optional getHttpUrlForOtelFormatClientSpan(