Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ public static boolean isAbsoluteUrl(String urlStr) {
*/
public static Optional<String> getHttpUrlForOTelFormat(
Map<String, AttributeValue> attributeValueMap) {
if (attributeValueMap.containsKey(HTTP_URL.getValue())) {
return Optional.of(attributeValueMap.get(HTTP_URL.getValue()).getValue());
Optional<String> httpUrlForOTelFormat = Optional.empty();
if (attributeValueMap.containsKey(HTTP_URL.getValue())
&& isAbsoluteUrl(attributeValueMap.get(HTTP_URL.getValue()).getValue())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this is not an absolute url but we don't have enough attributes to build the url as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fallback to present case only?

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())) {
Expand All @@ -195,15 +197,19 @@ public static Optional<String> 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<String> getHttpUrlForOtelFormatClientSpan(
Expand Down