Skip to content

Commit 4445608

Browse files
bm1549claude
andcommitted
fix: delegate peer tagging to BaseDecorator for IPv6 and config support
Use DECORATE.onPeerConnection() and setPeerPort() instead of manually setting peer tags. This correctly classifies IPv6 addresses as peer.ipv6 (instead of forcing peer.ipv4) and honors the trace.peer.hostname.enabled config toggle for peer.hostname. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent acc4558 commit 4445608

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

dd-java-agent/instrumentation/synapse-3.0/src/main/java/datadog/trace/instrumentation/synapse3/SynapseClientInstrumentation.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import datadog.trace.agent.tooling.InstrumenterModule;
2323
import datadog.trace.agent.tooling.annotation.AppliesOn;
2424
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
25-
import datadog.trace.bootstrap.instrumentation.api.Tags;
2625
import net.bytebuddy.asm.Advice;
2726
import org.apache.axis2.context.MessageContext;
2827
import org.apache.http.HttpInetConnection;
@@ -110,17 +109,11 @@ public static void requestSubmitted(
110109
AgentSpan span = spanFromContext(scope.context());
111110
DECORATE.onRequest(span, TargetContext.getRequest(connection).getRequest());
112111

113-
// set peer hostname from the connection since request URIs are relative paths
112+
// set peer info from the connection since request URIs are relative paths
114113
if (connection instanceof HttpInetConnection) {
115-
java.net.InetAddress remoteAddress = ((HttpInetConnection) connection).getRemoteAddress();
116-
if (remoteAddress != null) {
117-
span.setTag(Tags.PEER_HOSTNAME, remoteAddress.getHostName());
118-
span.setTag(Tags.PEER_HOST_IPV4, remoteAddress.getHostAddress());
119-
int remotePort = ((HttpInetConnection) connection).getRemotePort();
120-
if (remotePort > 0) {
121-
span.setTag(Tags.PEER_PORT, remotePort);
122-
}
123-
}
114+
HttpInetConnection inetConn = (HttpInetConnection) connection;
115+
DECORATE.onPeerConnection(span, inetConn.getRemoteAddress());
116+
DECORATE.setPeerPort(span, inetConn.getRemotePort());
124117
}
125118
scope.close();
126119
}

0 commit comments

Comments
 (0)