Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V5.13.3 release to v5.14.0 #1486

Merged
merged 14 commits into from
Mar 25, 2025
Merged

Conversation

EvenLjj
Copy link
Collaborator

@EvenLjj EvenLjj commented Mar 18, 2025

v5.13.3 merge into main branch.

Summary by CodeRabbit

  • New Features

    • Introduced new service endpoints and extended service interfaces to enhance streaming communication.
    • Integrated distributed tracing support with advanced context handling.
    • Updated connection management with refined keep-alive settings for improved stability.
  • Refactor

    • Enhanced timeout processing, error handling, and asynchronous request management for more reliable operations.
  • Tests

    • Added comprehensive tests to validate the new service methods and improved timeout logic.

liujianjun.ljj and others added 14 commits January 17, 2025 15:37
…elease_to_v5.14.0

# Conflicts:
#	all/pom.xml
#	bom/pom.xml
#	core/api/src/main/java/com/alipay/sofa/rpc/common/Version.java
#	pom.xml
#	remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ServerReqHeaderInterceptor.java
Copy link
Contributor

coderabbitai bot commented Mar 18, 2025

Walkthrough

The pull request includes modifications across multiple modules. In the core API, constant naming conventions and timeout retrieval logic were refined while expanding the asynchronous invocation conditions. In the remoting module, new OpenTracing dependencies were introduced and various interceptors, tracing adapters, and stream handlers were updated to improve context management, error handling, and class loader usage. Additionally, test cases were added to validate timeout behavior, service inheritance, and streaming requests.

Changes

File(s) Change Summary
core/api/.../RpcConstants.java Renamed constant values for invocation types from camel case to underscore format.
core/api/.../ConsumerConfig.java, core/api/.../ConsumerConfigTest.java Updated getMethodTimeout to check for null/zero values and return default timeout; added tests to validate timeout behavior.
core/api/.../SofaRequest.java Expanded isAsync method to include additional streaming invoke types.
remoting/pom.xml, remoting/remoting-triple/pom.xml Added dependency for sofa-rpc-tracer-opentracing to support OpenTracing functionality.
remoting/remoting-triple/.../ClientHeaderClientInterceptor.java Enhanced tracing in the start method (with updated beforeSend) and added a new sendMessage method with error logging.
remoting/remoting-triple/.../ServerReqHeaderInterceptor.java Introduced try-catch blocks in key operations with improved error logging and context management in interceptCall.
remoting/remoting-triple/.../ClientStreamObserverAdapter.java, remoting/remoting-triple/.../GenericServiceImpl.java Updated to accept a ClassLoader parameter and manage context class loader in stream callbacks (onNext, onError, onCompleted).
remoting/remoting-triple/.../TripleServer.java Configured keep-alive settings by adding .permitKeepAliveTime(1, TimeUnit.SECONDS) and .permitKeepAliveWithoutCalls(true) to the NettyServerBuilder.
remoting/remoting-triple/.../TripleTracerAdapter.java, remoting/remoting-triple/.../TripleClientInvoker.java, remoting/remoting-triple/.../TripleTracerAdapterTest.java Added overloaded methods in tracing adapter for detailed tracing (with method descriptor and context); updated test calls with an extra parameter; modified client invoker to pass the current class loader.
remoting/remoting-triple/.../SofaProtoUtils.java Changed method retrieval from getDeclaredMethods() to getMethods() to include inherited public methods.
remoting/remoting-triple/.../TripleExceptionUtils.java Added getThrowableFromStatus method to return appropriate exceptions based on gRPC status.
test/test-integration/.../HelloService.java, test/test-integration/.../HelloServiceImpl.java, test/test-integration/.../ParentService.java Modified HelloService to extend ParentService and added new service methods for direct and streaming responses.
test/test-integration/.../TripleGenericStreamTest.java Added testTripleParentCall to verify streaming communication and service integration.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ClientHeaderInterceptor
    participant TracerAdapter
    participant ServerInterceptor
    participant Server

    Client->>ClientHeaderInterceptor: Send RPC request
    ClientHeaderInterceptor->>TracerAdapter: Call beforeSend (with method details)
    TracerAdapter-->>ClientHeaderInterceptor: Return tracing context
    ClientHeaderInterceptor->>ServerInterceptor: Forward request with metadata
    ServerInterceptor->>Server: Process request\n(begin stream)
    Server-->>ServerInterceptor: Stream response(s)
    ServerInterceptor-->>ClientHeaderInterceptor: Forward responses with error handling
    ClientHeaderInterceptor-->>Client: Deliver responses
Loading

Suggested labels

size/XXL

Suggested reviewers

  • Lo1nt
  • chuailiwu

Poem

I'm a rabbit, hopping with delight,
In code fields fresh and ever so bright.
Constants renamed and streams refined,
Tracing lines with care aligned.
With each update, I twitch my nose—
Celebrating changes as the magic grows!
🐇🌟

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (8)
test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/ParentService.java (1)

25-31: Consider adding JavaDoc for methods:
Although the interface is straightforward, adding JavaDoc for sayHello() and parentSayHelloServerStream() would clarify their parameters, expected behavior, and potential usage scenarios—especially for streaming methods where additional detail is often helpful.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/message/triple/stream/ClientStreamObserverAdapter.java (1)

34-34: Restrict logger visibility:
It’s common practice to declare SLF4J loggers as private static final. Making it private aligns with typical conventions and avoids exposing the logger unnecessarily.

-    public static final Logger LOGGER = LoggerFactory.getLogger(ClientStreamObserverAdapter.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ClientStreamObserverAdapter.class);
remoting/remoting-triple/src/test/java/com/alipay/sofa/rpc/tracer/sofatracer/TripleTracerAdapterTest.java (1)

49-49: Updated test to match new method signature.

The test has been updated to call the new version of beforeSend that takes an additional MethodDescriptor parameter (passing null here). This keeps the test compatible with the updated API.

Consider enhancing this test to also verify behavior with a non-null MethodDescriptor parameter to ensure complete coverage of the new functionality.

-TripleTracerAdapter.beforeSend(sofaRequest, consumerConfig, metadata, null);
+// Add test with a mock MethodDescriptor
+MethodDescriptor<Object, Object> mockMethod = MethodDescriptor
+    .newBuilder()
+    .setType(MethodDescriptor.MethodType.UNARY)
+    .setFullMethodName("testService/testMethod")
+    .setRequestMarshaller(null)
+    .setResponseMarshaller(null)
+    .build();
+
+// Test with the mock method descriptor
+Metadata metadataWithMethod = new Metadata();
+TripleTracerAdapter.beforeSend(sofaRequest, consumerConfig, metadataWithMethod, mockMethod);
+// Add assertions to verify behavior with the method descriptor
test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/TripleGenericStreamTest.java (1)

76-76: Consider removing or replacing long sleeps in test code.

Using Thread.sleep(5000); can slow down the test suite. Prefer more deterministic synchronization methods, like waiting for a specific server start signal or using more granular countdown latches, if possible.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ServerReqHeaderInterceptor.java (1)

72-124: ForwardingServerCall override is comprehensive.

  1. Each overridden method (sendHeaders, sendMessage, close) includes try-catch blocks to capture exceptions—a good practice for robust error handling.
  2. The final block in close correctly calls TripleTracerAdapter.serverSend(...) on non-OK status.

Consider factoring out repeated error-logging logic to improve maintainability, but otherwise fine.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ClientHeaderClientInterceptor.java (3)

70-70: Consider null checks for consumerConfig and sofaRequest before calling TripleTracerAdapter.
In scenarios where the context might be incomplete, a null ConsumerConfig or SofaRequest could trigger unexpected behavior.

Also applies to: 74-78


114-135: Check for potential concurrency or resource leaks in onClose for async requests.
Clearing sofaTraceContext and removing invocation contexts in the finally block is good practice. Confirm no other asynchronous threads rely on these contexts while the event is processed.


148-156: Ensure robust error handling logic in sendMessage.
Catching and logging errors is helpful. In certain streaming scenarios, consider whether additional fallback or partial cleanup might be required.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d1a052 and d428cf4.

📒 Files selected for processing (20)
  • core/api/src/main/java/com/alipay/sofa/rpc/common/RpcConstants.java (1 hunks)
  • core/api/src/main/java/com/alipay/sofa/rpc/config/ConsumerConfig.java (1 hunks)
  • core/api/src/main/java/com/alipay/sofa/rpc/core/request/SofaRequest.java (1 hunks)
  • core/api/src/test/java/com/alipay/sofa/rpc/config/ConsumerConfigTest.java (1 hunks)
  • remoting/pom.xml (1 hunks)
  • remoting/remoting-triple/pom.xml (1 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ClientHeaderClientInterceptor.java (4 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ServerReqHeaderInterceptor.java (1 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/message/triple/stream/ClientStreamObserverAdapter.java (1 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/server/triple/GenericServiceImpl.java (1 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/server/triple/TripleServer.java (2 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/tracer/sofatracer/TripleTracerAdapter.java (4 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/transport/triple/TripleClientInvoker.java (2 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java (1 hunks)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/TripleExceptionUtils.java (2 hunks)
  • remoting/remoting-triple/src/test/java/com/alipay/sofa/rpc/tracer/sofatracer/TripleTracerAdapterTest.java (1 hunks)
  • test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/HelloService.java (1 hunks)
  • test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/HelloServiceImpl.java (1 hunks)
  • test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/ParentService.java (1 hunks)
  • test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/TripleGenericStreamTest.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: sca
🔇 Additional comments (39)
test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/ParentService.java (1)

1-16: License header review:
These lines look like a standard ASF license header. No issues found here.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/message/triple/stream/ClientStreamObserverAdapter.java (6)

26-27: Logger imports:
Importing SLF4J Logger and LoggerFactory is the standard approach for logging.


42-43: New field for class loader:
Adding the final ClassLoader field appears proper for handling dynamic loading. No immediate issues identified.


44-55: Constructor refactoring with class loader:
The new constructor parameter classLoader is a clean way to pass in the relevant loader context. Consider adding a quick null check or fallback for safety if classLoader might be null.

Please confirm whether classLoader can be null in the calling code. If so, you may want to handle it gracefully or document that it must be non-null.


65-79: Thread context class loader usage in onNext:
Switching the thread context class loader around each invocation can be fragile if multiple threads use the same observer instance concurrently. Confirm that each ClientStreamObserverAdapter is thread-confined or concurrency-safe.

Would you like me to generate a script to check if instances of ClientStreamObserverAdapter might be shared among multiple threads?


84-90: Same concurrency concern in onError:
The pattern of setting and restoring the context class loader is repeated here. The same concurrency considerations apply.


95-101: Same concurrency concern in onCompleted:
Again, setting and restoring the thread context class loader is ideal for single-thread usage. Please ensure this is not shared across multiple threads.

remoting/remoting-triple/pom.xml (1)

69-72:

❓ Verification inconclusive

Add tracer-opentracing dependency:
Ensure that this dependency version is managed properly. Having an explicit version in <dependencyManagement> or confirming its inherited version can prevent mismatched library issues.


🏁 Script executed:

#!/bin/bash
# Description: Search for the dependencyManagement entry for sofa-rpc-tracer-opentracing in the repo.

fd pom.xml --exec rg -A 5 'dependencyManagement' | rg -A 10 'sofa-rpc-tracer-opentracing'

Length of output: 87


Attention: Verify Dependency Version Management for Tracer-Opentracing

Our automated search did not locate any <dependencyManagement> entry for the sofa-rpc-tracer-opentracing dependency. Please manually verify that its version is inherited from a parent POM or, if not, add an explicit version in the <dependencyManagement> section to avoid potential mismatches.

  • Confirm that a parent POM is managing the version for this dependency.
  • If not managed, update the dependency management to include the appropriate version.
test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/HelloService.java (1)

21-21: Interface now extends ParentService

The HelloService interface has been updated to extend ParentService, which means it now inherits methods and contracts from the parent interface. This change enhances the service capability by inheriting the parent's methods (sayHello and parentSayHelloServerStream as mentioned in the summary).

Ensure that all implementations of HelloService now also implement the methods required by ParentService.

remoting/pom.xml (1)

91-95: Added OpenTracing dependency

A new dependency for sofa-rpc-tracer-opentracing has been added to the dependency management section. This addition enables OpenTracing functionality for distributed request tracing across the RPC infrastructure.

The version is correctly tied to the parent project version (${project.parent.version}), ensuring consistent versioning across modules.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/server/triple/TripleServer.java (1)

146-147: Improved keep-alive configuration for gRPC connections

Two important keep-alive configurations have been added to the NettyServerBuilder:

  1. .permitKeepAliveTime(1, TimeUnit.SECONDS) - Sets the minimum time between client keep-alive pings
  2. .permitKeepAliveWithoutCalls(true) - Allows clients to send keep-alive pings even when there are no active calls

These changes enhance connection stability, especially in environments with proxies or firewalls that might close idle connections, reducing connection reset issues and improving overall reliability.

core/api/src/main/java/com/alipay/sofa/rpc/core/request/SofaRequest.java (1)

308-314: Enhanced isAsync detection for streaming operations

The isAsync() method has been improved to recognize more invocation types as asynchronous. In addition to the traditional callback and future patterns, it now correctly identifies all streaming types (bi-directional, server-side, and client-side streaming) as asynchronous operations.

This change aligns with the true nature of streaming operations, which are inherently asynchronous, and ensures they will be properly handled by asynchronous processing mechanisms within the framework.

core/api/src/test/java/com/alipay/sofa/rpc/config/ConsumerConfigTest.java (1)

1-56: Test for method timeout retrieval added - good coverage!

This new test class provides good coverage for the getMethodTimeout functionality of the ConsumerConfig class. The test verifies:

  1. Default timeout retrieval when no method config exists
  2. Default timeout propagation when method config exists without timeout
  3. Custom timeout retrieval when explicitly set
  4. Negative timeout handling

The test is well-structured and comprehensive.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/TripleExceptionUtils.java (2)

19-23: New exception imports added to support mapping from gRPC Status to Throwable types.

These imports are necessary for the new method implementation.


36-46: Effective mapping from gRPC Status to Throwable types.

This new method provides a clean mapping between gRPC Status codes and SOFA RPC exception types, which allows for consistent error handling throughout the codebase. The mapping correctly handles:

  1. OK status → null (no exception)
  2. UNAVAILABLE status → SofaRouteException
  3. DEADLINE_EXCEEDED status → SofaTimeOutException
  4. Other statuses → generic SofaRpcException with UNKNOWN type

The method preserves the original status description and cause for better error reporting.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java (1)

99-99:

✅ Verification successful

Changed to include inherited methods in stream call type caching.

Replacing getDeclaredMethods() with getMethods() is a significant improvement that ensures all methods, including those inherited from parent classes, are properly considered when caching stream call types. This change helps maintain consistency in RPC invocation behavior across class hierarchies.


🏁 Script executed:

#!/bin/bash
# Check for classes that extend interfaces with stream methods to verify the impact of this change

# Find Java interfaces that might have streaming methods
echo "Looking for interfaces with potential stream methods..."
rg -l "extends.*implements" --type java | xargs grep -l "SofaStreamObserver" || echo "No stream interfaces found with inheritance"

Length of output: 294


Verification: Inherited Methods Caching Update

The change from using getDeclaredMethods() to getMethods() correctly ensures that inherited methods are now included in stream call type caching. Our verification script did not reveal any interfaces (e.g., those involving SofaStreamObserver) with inheritance issues, confirming that the updated approach does not introduce unintended side effects.

  • Location: remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java (Line 99)
  • Change Impact: Now considers all methods (inherited and declared), which improves consistency in RPC invocation behavior across class hierarchies.
core/api/src/main/java/com/alipay/sofa/rpc/config/ConsumerConfig.java (1)

936-940: Improved timeout handling logic with fallback mechanism

The method now explicitly checks for null or zero timeout values and returns the default timeout in those cases. This is a clearer implementation that makes the fallback behavior more explicit.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/server/triple/GenericServiceImpl.java (3)

134-142: Enhanced classloader management in onNext method

The addition of proper class loader handling with try/finally blocks ensures that the correct service classloader is used during stream processing and then restored, preventing potential classloader leaks or context issues.


147-152: Enhanced classloader management in onError method

Adding the try/finally block to properly manage the thread's context classloader during error handling ensures consistent classloader management across all callback methods.


158-163: Enhanced classloader management in onCompleted method

Similar to the other methods, proper classloader management has been added to ensure the service classloader is used during stream completion and then restored afterward.

test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/HelloServiceImpl.java (2)

81-84: Implementation of sayHello method for interface inheritance

This adds the unary request/response method implementation needed to satisfy the ParentService interface contract.


86-90: Implementation of streaming method from parent interface

Correctly delegates to the existing implementation to avoid code duplication while satisfying the interface contract from the parent service.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/transport/triple/TripleClientInvoker.java (2)

196-198: Added classloader parameter to stream adapter

This change passes the current classloader to the ClientStreamObserverAdapter, enabling proper classloader handling during bi-directional streaming calls.


235-235: Added classloader parameter to server stream adapter

Similarly to the bi-directional streaming case, now passing the current classloader to the ClientStreamObserverAdapter for server streaming calls to ensure proper class loading during RPC operations.

test/test-integration/src/test/java/com/alipay/sofa/rpc/test/triple/stream/TripleGenericStreamTest.java (1)

88-119: Test logic validation and coverage are good.

  1. The newly introduced method testTripleParentCall() correctly verifies streaming responses and completion signals.
  2. The CountDownLatch usage appears correct; ensuring 5 onNext calls plus one onCompleted equals 6 latch counts.
  3. The final asserts checking list size and receivedFinish strongly validate the desired behavior.

No issues found that block merging.

core/api/src/main/java/com/alipay/sofa/rpc/common/RpcConstants.java (1)

131-139: Naming convention update aligns with underscore style.

Renaming the constants to client_stream, server_stream, and bi_stream is consistent. No functional concerns are observed.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ServerReqHeaderInterceptor.java (7)

59-61: Logical flow initialization.

Acquiring the ServerServiceDefinition before constructing SofaRequest and SofaResponse is clear and well-structured. No concerns at this point.


62-64: Object creation is straightforward.

Creating SofaRequest/SofaResponse instances here is consistent. Ensure that any relevant fields (like method or interface metadata) are properly set in upstream logic.


65-65: Context injection.

ctxWithSpan effectively injects tracing context into the gRPC call. No concerns.


67-69: Debug logging.

Logging request headers in debug mode is useful for diagnostics. No issues here.


125-132: Intercept call logic with context.

  1. Properly handles any exceptions during the intercept phase by logging and rethrowing a StatusRuntimeException.
  2. Good approach for bridging gRPC and the tracing logic.

No further issues.


133-213: ForwardingServerCallListener overrides manage concurrency and tracing.

  1. onCancel, onComplete, onMessage, and onHalfClose each set the trace and context, handle operations, and then finalize with TripleTracerAdapter.serverSend.
  2. Removing the RpcInvokeContext and clearing the SofaTraceContext in the finally block ensures no context leaks into subsequent calls.

Overall, a robust handling of server streaming lifecycle events.


214-216: Final cleanup.

Clearing the RpcInvokeContext and SofaTraceContext after intercept completion avoids leftover context data. This is consistent with best practices for ephemeral tracing data.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ClientHeaderClientInterceptor.java (2)

19-21: New imports appear valid and necessary for tracing enhancements.
No issues found; these additional imports align with the updated tracing and event handling logic.

Also applies to: 23-23, 27-29, 32-32


94-109: Confirm thread safety of the async context manipulation in onMessage.
We see that the async request logic pushes/pops the tracer context. This pattern is correct but ensure that exceptions thrown by super.onMessage won’t leave the context in a partially updated state.

remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/tracer/sofatracer/TripleTracerAdapter.java (4)

44-45: New imports for tracer tags and gRPC context.
These additions correctly support the new methods for enriched tracing functionality.

Also applies to: 48-48


82-85: Deprecation of the old beforeSend method.
Marking it as deprecated while directing usage to the new overloaded version is appropriate for backward compatibility.


87-145: Enhanced beforeSend with MethodDescriptor support.
The logic for setting invokeType and tagging spans according to method type is well-structured. Ensure all streaming scenarios are covered, and confirm that synchronous calls default to “sync” gracefully.


326-345: Refactoring serverSend with an additional Context parameter.
The updated implementation is coherent; pushing the original span from the provided context if the current span is null is a valuable fallback. Maintain the deprecated method to preserve existing integrations without forcing an immediate upgrade.

@EvenLjj EvenLjj merged commit d1375ba into sofastack:master Mar 25, 2025
5 checks passed
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.

3 participants