Skip to content

Commit

Permalink
Add back compat for http.host attribute (#2608)
Browse files Browse the repository at this point in the history
I realized I should have kept backwards compatibility in mind when
upgrading to otel 1.19, for (manual) instrumentation that may still be
using older semantic convention.
  • Loading branch information
trask authored Oct 20, 2022
1 parent a77b14d commit f62ba96
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -602,15 +602,20 @@ public static String getHttpUrlFromServerSpan(Attributes attributes) {
if (scheme == null) {
return null;
}
String host = attributes.get(SemanticAttributes.NET_HOST_NAME);
if (host == null) {
return null;
}
Long port = attributes.get(SemanticAttributes.NET_HOST_PORT);
String target = attributes.get(SemanticAttributes.HTTP_TARGET);
if (target == null) {
return null;
}
String host = attributes.get(SemanticAttributes.NET_HOST_NAME);
if (host == null) {
// fall back to deprecated http.host if available
host = attributes.get(SemanticAttributes.HTTP_HOST);
if (host == null) {
return null;
}
return scheme + "://" + host + target;
}
Long port = attributes.get(SemanticAttributes.NET_HOST_PORT);
if (port != null && port > 0) {
return scheme + "://" + host + ":" + port + target;
}
Expand Down

0 comments on commit f62ba96

Please sign in to comment.