Skip to content

Commit

Permalink
Update to otel 1.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Sep 9, 2022
1 parent 9257ab6 commit 2e4f737
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ public final class AiSemanticAttributes {
public static final AttributeKey<String> DEVICE_OS_VERSION =
AttributeKey.stringKey("applicationinsights.internal.operating_system_version");

// TODO (trask) remove once this makes it into SemanticAttributes
// TODO (trask) remove these once they make it into SemanticAttributes
public static final AttributeKey<String> NET_SOCK_PEER_NAME =
AttributeKey.stringKey("net.sock.peer.name");
public static final AttributeKey<String> NET_SOCK_PEER_ADDR =
AttributeKey.stringKey("net.sock.peer.addr");
public static final AttributeKey<Long> NET_SOCK_PEER_PORT =
AttributeKey.longKey("net.sock.peer.port");

// TODO (trask) this can go away once new indexer is rolled out to gov clouds
public static final AttributeKey<List<String>> REQUEST_CONTEXT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,28 @@ private static String getTargetOrNull(Attributes attributes, int defaultPort) {
if (peerService != null) {
return peerService;
}
String netPeerName = attributes.get(SemanticAttributes.NET_PEER_NAME);
if (netPeerName == null) {
return null;
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;
}
}
Long netPeerPort = attributes.get(SemanticAttributes.NET_PEER_PORT);
if (netPeerPort != null && netPeerPort != defaultPort) {
return netPeerName + ":" + netPeerPort;
} else {
return netPeerName;
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 null;
}

private static void applyDatabaseClientSpan(
Expand Down

0 comments on commit 2e4f737

Please sign in to comment.