Skip to content

Commit

Permalink
Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Sep 12, 2022
1 parent e291f47 commit ca1340d
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,27 +396,27 @@ private static String getTargetOrNull(Attributes attributes, int defaultPort) {
String host = attributes.get(SemanticAttributes.NET_PEER_NAME);
if (host != null) {
Long port = attributes.get(SemanticAttributes.NET_PEER_PORT);
if (port != null && port != defaultPort) {
return host + ":" + port;
} else {
return host;
}
return getTarget(host, port, defaultPort);
}
host = attributes.get(AiSemanticAttributes.NET_SOCK_PEER_NAME);
if (host == null) {
host = attributes.get(AiSemanticAttributes.NET_SOCK_PEER_ADDR);
}
if (host != null) {
Long port = attributes.get(AiSemanticAttributes.NET_SOCK_PEER_PORT);
if (port != null && port != defaultPort) {
return host + ":" + port;
} else {
return host;
}
return getTarget(host, port, defaultPort);
}
return null;
}

private static String getTarget(String host, @Nullable Long port, int defaultPort) {
if (port != null && port != defaultPort) {
return host + ":" + port;
} else {
return host;
}
}

private static void applyDatabaseClientSpan(
RemoteDependencyTelemetryBuilder telemetryBuilder, String dbSystem, Attributes attributes) {
String dbStatement = attributes.get(SemanticAttributes.DB_STATEMENT);
Expand Down

0 comments on commit ca1340d

Please sign in to comment.