<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<br>
It's a good topic to bring up. <br>
<br>
Have you tried the JFR support for method timing and tracing events
that JEP 520 introduced in JDK 25? I'm wondering if
-XX:StartFlightRecording:jdk.MethodTrace#filter=java.net.InetAddress::getByName
records events that could help here.<br>
<br>
If new events are introduced then I could image them having
"NameService" rather than "Dns" in the name as JDK doesn't use DNS
directly (except the JNDI-DNS provider), it is whatever is
configured on the system.<br>
<br>
-Alan<br>
<br>
<br>
<div class="moz-cite-prefix">On 13/11/2025 11:07,
<a class="moz-txt-link-abbreviated" href="mailto:hashjangcyber@gmail.com">hashjangcyber@gmail.com</a> wrote:<br>
</div>
<blockquote type="cite" cite="mid:80e7ca0d-640b-48f3-8709-f59b91d4756c@Spark">
<title></title>
<div name="messageBodySection">
<div><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#262626;">Hello,</font></span><br>
<span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#262626;">I would like to start a discussion
on introducing new JFR events for DNS lookups. While many
lookups are DNS in cloud-native environments, the JDK uses
the configured name service, so the event naming and
semantics should not imply DNS-only behavior. Iām seeking
feedback on scope, naming, and payload fields.</font></span><br>
<span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#262626;">Motivation</font></span><br>
</div>
<ul>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">High-frequency,
latency-sensitive lookups are critical for service
discovery.</span><br>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Current
gaps:</span>
<ul>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Cannot
distinguish cache hits vs. network lookups</span><br>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Hard
to trace lookup latency and diagnose timeouts/failures</span><br>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Concurrent
libraries may cause redundant lookups</span><br>
</li>
</ul>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Value:</span>
<ul>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">End-to-end
observability: lookup ā socket connect ā data transfer</span><br>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Troubleshooting:
identify timeouts, resolution failures</span><br>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Performance:
evaluate cache policies, detect hotspot names</span><br>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">Security:
audit external domains accessed</span><br>
</li>
</ul>
</li>
</ul>
<div><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>Proposed event (initial
draft)</strong></font></span><br>
<span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>Event name:</strong> jdk.DnsLookup</font></span><br>
<span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>When:</strong> Emitted
around DNS hostname resolution call boundaries, including:</font></span><br>
</div>
<ul>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Actual
network DNS queries (when cache is disabled or cache miss
occurs)</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Cache
hits (when result is retrieved from DNS cache)</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Stale
data usage (when expired but still valid cached data is
used)</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Background
DNS cache refresh operations</span><br>
</li>
</ul>
<div><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>Key fields (feedback
welcome):</strong></font></span><br>
</div>
<ul>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">host (String):
The hostname being resolved</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">result (String):
Comma-separated list of resolved IP addresses, or error
message if lookup failed</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">success (boolean):
Whether the DNS lookup was successful</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">cached (boolean):
Whether the result was retrieved from cache (true) or from
actual DNS network query (false). This helps distinguish
between three use cases:</span>
<ul>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Actual
network queries (cached=false) - represents real DNS
network traffic</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Cache
hits (cached=true, stale=false) - repeated lookups
using fresh cached data</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Stale
data usage (cached=true, stale=true) - application
continues with expired but still valid cached data
when DNS refresh fails</span><br>
</li>
</ul>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">ttl (long,
seconds): Time to live in seconds. Values:</span>
<ul>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">0 or -1:
Not cached or forever cached</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">>
0: Actual remaining TTL if cached</span><br>
</li>
</ul>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">stale (boolean):
Whether stale cached data was used (only valid when
cached=true). Helps identify semi-error scenarios where
DNS errors occur but application continues using stale
cached records</span><br>
</li>
</ul>
<div><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>Event name:</strong> jdk.DnsCacheStatistics</font></span><br>
<span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>When:</strong> Periodic
event emitted at configurable intervals (default: 5
seconds in default.jfc, 1 second in profile.jfc). This is
a statistics event similar
to jdk.ExceptionStatistics, providing aggregate metrics
about the DNS cache state.</font></span><br>
<span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>Key fields (feedback
welcome):</strong></font></span><br>
</div>
<ul>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">cacheSize (long):
Current number of entries in the DNS cache. Useful for
monitoring cache growth and understanding cache
utilization patterns.</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">staleEntries (long):
Number of stale entries currently in the cache (entries
that have expired but are still within the stale period).
Helps identify how many entries are using stale data,
which is important for understanding cache behavior in
scenarios where DNS refresh fails.</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">entriesRemoved (long):
Number of entries that have been removed during cache
cleanup operations. This metric tracks cache eviction and
helps understand cache churn patterns, which is
particularly useful in Kubernetes and cloud-native
environments where DNS entries may change frequently.</span><br>
</li>
</ul>
<div><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;"><font style="color:#080808;"><strong>Use cases:</strong></font></span><br>
</div>
<ul>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Monitoring
DNS cache size growth over time</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Identifying
cache cleanup frequency and patterns</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Understanding
stale data usage in production environments</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Troubleshooting
DNS-related performance issues in microservices
architectures</span><br>
</li>
<li><span style="font-family:Helvetica , Arial , freesans , sans-serif;font-size:13px;">Observing
cache behavior during DNS server failures or network
partitions</span><br>
</li>
</ul>
<div><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#262626;">Prototype/PR</font></span><br>
</div>
<ul>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">A
preliminary PR is available for context and discussion:</span>
<ul>
<li><a href="https://git.openjdk.org/jdk/pull/28110" moz-do-not-send="true"><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#1E6FFF;">https://git.openjdk.org/jdk/pull/28110</font></span></a><br>
</li>
</ul>
</li>
<li><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;">I
will update the design/implementation per feedback from
this thread.</span><br>
</li>
</ul>
<div><span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#262626;">Thanks in advance for your
feedback!</font></span><br>
<span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#262626;">Best regards,</font></span><br>
<span style="font-family:-apple-system , system-ui , Helvetica Neue , Tahoma , PingFang SC , Microsoft Yahei , Arial , Hiragino Sans GB , sans-serif , Apple Color Emoji , Segoe UI Emoji , Segoe UI Symbol , Noto Color Emoji;font-size:15px;"><font style="color:#262626;">NeayGuyCoding</font></span></div>
</div>
</blockquote>
<br>
</body>
</html>