Skip to content

enhance remote ip get logic#1529

Open
EvenLjj wants to merge 1 commit intosofastack:masterfrom
EvenLjj:enhance/getRemote_ip
Open

enhance remote ip get logic#1529
EvenLjj wants to merge 1 commit intosofastack:masterfrom
EvenLjj:enhance/getRemote_ip

Conversation

@EvenLjj
Copy link
Collaborator

@EvenLjj EvenLjj commented Jan 28, 2026

enhance remote ip get logic

Summary by CodeRabbit

  • Bug Fixes
    • Improved remote IP address extraction in request tracing to use IP addresses instead of hostnames for more accurate and consistent monitoring and debugging.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

The remote IP extraction logic in TripleTracerAdapter's serverReceived method now retrieves the raw IP address instead of the host name from InetSocketAddress objects, using getAddress().getHostAddress() instead of getHostName().

Changes

Cohort / File(s) Summary
IP Address Extraction
remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/tracer/sofatracer/TripleTracerAdapter.java
Modified remote IP extraction in serverReceived to use raw IP address (getAddress().getHostAddress()) instead of host name (getHostName())

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • chuailiwu
  • OrezzerO
  • Lo1nt

Poem

🐰 A hop, a skip, through tracer's trace,
Where IPs now show their true face,
No hostnames blur the picture clear—
Just addresses, precise and dear! 🌐

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'enhance remote ip get logic' directly aligns with the main change: updating how remote IP is extracted from InetSocketAddress using getAddress().getHostAddress() instead of getHostName().
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/tracer/sofatracer/TripleTracerAdapter.java (1)

309-314: Potential NullPointerException if getAddress() returns null.

The change from getHostName() to getAddress().getHostAddress() is a good improvement to avoid DNS reverse lookups. However, InetSocketAddress.getAddress() can return null for unresolved addresses, which would cause an NPE.

🛡️ Suggested defensive null check
             String remoteIp = "";
             SocketAddress socketAddress = call.getAttributes().get(
                 Grpc.TRANSPORT_ATTR_REMOTE_ADDR);
-            if (socketAddress instanceof InetSocketAddress) {
-                remoteIp = ((InetSocketAddress) socketAddress).getAddress().getHostAddress();
+            if (socketAddress instanceof InetSocketAddress) {
+                InetAddress inetAddress = ((InetSocketAddress) socketAddress).getAddress();
+                if (inetAddress != null) {
+                    remoteIp = inetAddress.getHostAddress();
+                }
             }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant