peer.hostname resolution flaws
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- java
- Ambito
- backend, observability-sre
Direzione di ricerca
Inizia con HostNameResolver e la sua inizializzazione statica, poi leggi MethodHandles.method e AgentBootstrap intorno alle righe collegate per comprendere l’accesso ai moduli e il comportamento del classloader. Controlla i test esistenti per la risoluzione dei nomi host e consulta la documentazione sul tracing Java collegata nell’issue. Il lavoro è completato quando il fallimento segnalato è coperto da un comportamento o da diagnostica chiari e la configurazione di runtime richiesta è documentata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Tracer Version(s)
1.58.0
Java Version(s)
21.0.9
JVM Vendor
Amazon Corretto
Bug Report
Hi,
we're experiencing a problem where we have traces with impossible relations between our services. Initial investigation revealed insonsistency in peer.hostname span attribute. I dug deeper and here are my findings:
- Tracer has implemented ip -> hostname resolution CACHE
- This cache may lead to wrong
peer.hostnameresolution under certain condition, when there are multiple domains under a single IP address. Which is exactly our case (services behind reverse proxy). - THIS PR mitigates cache usage by reusing already done resolutions. But didn't worked for us, because:
a)HOLDER_GETisn't loaded during static init.
b) Initially i assumed it's because ofclvariable is effectively resolves null -getClassloader()for classes loaded byBootstrap ClassLoader(which is the case because of THIS). In the end, that wasn't the problem, because it turned outMethodHandles.methoddoesn't rely on classloader passed in its constructor. But issue with nullclit could be analyzed on your side anyway, because this method of retrieving the classloader might cause problems elsewhere.
c) Ultimately the problem lay inside ofMethodHandle.methodwhere failed attempt of "enabling" reflection was swallowed by error handling and logged as debug log, which I didn't catch during my initial analysis:
[dd.trace 2026-04-10 16:54:47:569 +0200] [ioClientGroup-4-1] EXCLUDE_TELEMETRY datadog.trace.util.MethodHandles - Could not get method holder accepting [] from class class java.net.InetAddress
java.lang.reflect.InaccessibleObjectException: Unable to make java.net.InetAddress$InetAddressHolder java.net.InetAddress.holder() accessible: module java.base does not "opens java.net" to unnamed module @16b98e56
at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:203)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:197)
at datadog.trace.util.MethodHandles.lambda$method$3(MethodHandles.java:156)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at datadog.trace.util.MethodHandles.method(MethodHandles.java:141)
at datadog.trace.bootstrap.instrumentation.java.net.HostNameResolver.<clinit>(HostNameResolver.java:23)
at datadog.trace.bootstrap.instrumentation.decorator.BaseDecorator.onPeerConnection(BaseDecorator.java:137)
at datadog.trace.bootstrap.instrumentation.decorator.BaseDecorator.onPeerConnection(BaseDecorator.java:123)
at datadog.trace.instrumentation.netty41.client.HttpClientRequestTracingHandler.write(HttpClientRequestTracingHandler.java:89)
at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:346)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868)
at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:305)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868)
at io.netty.handler.logging.LoggingHandler.write(LoggingHandler.java:288)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:956)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:982)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:950)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:1000)
at software.amazon.awssdk.http.nio.netty.internal.nrs.HttpStreamsHandler.unbufferedWrite(HttpStreamsHandler.java:327)
at software.amazon.awssdk.http.nio.netty.internal.nrs.HttpStreamsHandler.flushNext(HttpStreamsHandler.java:376)
at software.amazon.awssdk.http.nio.netty.internal.nrs.HttpStreamsHandler.write(HttpStreamsHandler.java:270)
at software.amazon.awssdk.http.nio.netty.internal.nrs.HttpStreamsClientHandler.write(HttpStreamsClientHandler.java:59)
- After adding
--add-opens=java.base/java.net=ALL-UNNAMEDnow resolution works perfectly.
*I did indicate version 1.58, but looking at the code, I think the problem still exists in the latest versions
Related support tickets:
https://help.datadoghq.com/hc/en-us/requests/2443074
https://help.datadoghq.com/hc/en-us/requests/2495915
Expected Behavior
- Gather all required modules and add information about
--add-opensto official docs. Currently there is no mention about this. - During init add some warn logging in
HostNameResolverabout the inability to usegetAlreadyResolvedHostName, because it's clearly undesirable behavior, which should be noted beyond the jungle of debug logs. - Last but not least - reconsider the validity of the caching mechanism. In the era of widespread reverse proxies, depending on assumption that every domain has IP exclusively, leads to hours of head-scratching for your customers :) Maybe it's better not to resolve
peer.hostnameat all than to provide misleading data. - As bonus - Recheck relying classloader resolution on classes from the JVM agent, because they may be referenced from bootstrap classloader (I'm not sure about that point, because I haven't looked into it in depth).
Reproduction Code
No response
- Lingua principale
- Java
- Stelle
- 737
- Fork
- 361
- Merge medio
- 3g 20h
- PR unite (30g)
- 173
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DataDog/dd-trace-java
-
type: feature request
Difficoltà 1/5 1-3 ore Idoneità per principianti 70/100
DataDog/dd-trace-java#10245 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 62/100
DataDog/dd-trace-java#12608 ·
I maintainer di solito rispondono entro 1 giorno
-
type: bug report
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
DataDog/dd-trace-java#12597 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
DataDog/dd-trace-java#12540 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
DataDog/dd-trace-java#12480 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di DataDog/dd-trace-java
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
ci-failure-cause test-failure
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
nextcloud/notes-android#3367 ·
I maintainer di solito rispondono entro 1 giorno
-
Feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
MuntashirAkon/AppManager#2058 ·
-
SarifLogger: artifactLocation.uri is not properly encoded for file names containing '#', '?', or '%' Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
checkstyle/checkstyle#21721 ·
I maintainer di solito rispondono entro 1 giorno