-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: Add support for SOFARPC framework #15589
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
base: main
Are you sure you want to change the base?
Conversation
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0 through 5.12.0+ Fixes open-telemetry#15496
|
|
...main/java/io/opentelemetry/javaagent/instrumentation/sofa/rpc/OpenTelemetryClientFilter.java
Outdated
Show resolved
Hide resolved
...n/java/io/opentelemetry/javaagent/instrumentation/sofa/rpc/SofaRpcInstrumentationModule.java
Outdated
Show resolved
Hide resolved
...n/java/io/opentelemetry/javaagent/instrumentation/sofa/rpc/SofaRpcInstrumentationModule.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/sofa/rpc/internal/SofaRpcClientNetworkAttributesGetter.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/sofa/rpc/internal/SofaRpcClientNetworkAttributesGetter.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/sofa/rpc/internal/SofaRpcClientNetworkAttributesGetter.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/sofa/rpc/internal/SofaRpcClientNetworkAttributesGetter.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/sofa/rpc/internal/SofaRpcClientNetworkAttributesGetter.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/sofa/rpc/internal/SofaRpcClientNetworkAttributesGetter.java
Outdated
Show resolved
Hide resolved
...nfigure/src/main/java/io/opentelemetry/instrumentation/sofa/rpc/SofaRpcAttributesGetter.java
Outdated
Show resolved
Hide resolved
...ain/java/io/opentelemetry/instrumentation/sofa/rpc/SofaRpcNetworkServerAttributesGetter.java
Outdated
Show resolved
Hide resolved
...nfigure/src/main/java/io/opentelemetry/instrumentation/sofa/rpc/SofaRpcTelemetryBuilder.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive instrumentation support for the SOFARPC framework, enabling distributed tracing for RPC calls. The implementation includes both javaagent-based auto-instrumentation and library-based manual instrumentation approaches, with full support for synchronous, asynchronous, and generic invocations.
Key changes:
- Adds javaagent instrumentation module with automatic filter injection via SPI
- Adds library autoconfigure module with manual instrumentation API
- Implements comprehensive test coverage including chain tracing, error handling, async calls, and local call detection
- Supports SOFARPC versions 5.4.0 through 5.12.0+
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| settings.gradle.kts | Adds three new subprojects for SOFARPC instrumentation (javaagent, library-autoconfigure, testing) |
| instrumentation/sofa-rpc/metadata.yaml | Defines instrumentation metadata including supported versions, semantic conventions, and configuration options |
| instrumentation/sofa-rpc/testing/build.gradle.kts | Configures test dependencies and runtime classpath with SOFARPC 5.4.0 and compatible logging dependencies |
| instrumentation/sofa-rpc/testing/src/main/java/.../api/* | Defines test service interfaces (HelloService, MiddleService, ErrorService) for testing RPC scenarios |
| instrumentation/sofa-rpc/testing/src/main/java/.../impl/* | Implements test services including error handling, chaining, and timeout scenarios |
| instrumentation/sofa-rpc/testing/src/main/java/.../AbstractSofaRpcTest.java | Provides base test class for synchronous, asynchronous, and error handling test scenarios |
| instrumentation/sofa-rpc/testing/src/main/java/.../AbstractSofaRpcTraceChainTest.java | Tests trace propagation through chained RPC calls and local call filtering |
| instrumentation/sofa-rpc/library-autoconfigure/src/main/java/.../* | Core library instrumentation including telemetry builder, filters, attribute extractors, and context propagation |
| instrumentation/sofa-rpc/library-autoconfigure/src/test/java/.../* | Library instrumentation tests extending abstract test classes |
| instrumentation/sofa-rpc/library-autoconfigure/build.gradle.kts | Configures library dependencies with SOFARPC 5.4.0 and AutoValue for code generation |
| instrumentation/sofa-rpc/library-autoconfigure/src/main/resources/META-INF/services/* | SPI configuration for auto-registering OpenTelemetry filters with SOFARPC |
| instrumentation/sofa-rpc/javaagent/src/main/java/.../* | Javaagent instrumentation module with resource injection and filter delegation |
| instrumentation/sofa-rpc/javaagent/src/testSofaRpc/java/.../* | Javaagent-specific tests with peer service attribute support |
| instrumentation/sofa-rpc/javaagent/build.gradle.kts | Configures javaagent build with muzzle checks for version 5.0.0+ and test suites |
| instrumentation/sofa-rpc/javaagent/src/main/resources/* | SPI configuration for javaagent filter registration |
...ure/src/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/SofaRpcTelemetryBuilder.java
Outdated
Show resolved
Hide resolved
...autoconfigure/src/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/TracingFilter.java
Outdated
Show resolved
Hide resolved
...ary-autoconfigure/src/main/java/io/opentelemetry/instrumentation/sofa/rpc/TracingFilter.java
Outdated
Show resolved
Hide resolved
...autoconfigure/src/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/TracingFilter.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/AbstractSofaRpcTraceChainTest.java
Show resolved
Hide resolved
...autoconfigure/src/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/TracingFilter.java
Outdated
Show resolved
Hide resolved
...testing/src/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/AbstractSofaRpcTest.java
Show resolved
Hide resolved
...fa-rpc/testing/src/main/java/io/opentelemetry/instrumentation/sofa/rpc/api/ErrorService.java
Outdated
Show resolved
Hide resolved
...testing/src/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/AbstractSofaRpcTest.java
Show resolved
Hide resolved
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0 through 5.12.0+ Fixes open-telemetry#15496
…va/io/opentelemetry/instrumentation/sofarpc/v5_4/SofaRpcTelemetryBuilder.java Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0 through 5.12.0+ Fixes open-telemetry#15496
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0+ Fixes open-telemetry#15496
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0+ Fixes open-telemetry#15496
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0+ Fixes open-telemetry#15496
...autoconfigure/src/main/java/io/opentelemetry/instrumentation/sofarpc/v5_4/TracingFilter.java
Outdated
Show resolved
Hide resolved
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0+ Fixes open-telemetry#15496
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0+ Fixes open-telemetry#15496
This PR adds instrumentation support for SOFARPC framework, including: - Javaagent instrumentation module - Library autoconfigure module - Testing utilities and test cases - Support for SOFARPC 5.4.0+ Fixes open-telemetry#15496
| | [RxJava](https://github.com/ReactiveX/RxJava) | 1.0+ | [opentelemetry-rxjava-1.0](../instrumentation/rxjava/rxjava-1.0/library),<br>[opentelemetry-rxjava-2.0](../instrumentation/rxjava/rxjava-2.0/library),<br>[opentelemetry-rxjava-3.0](../instrumentation/rxjava/rxjava-3.0/library),<br>[opentelemetry-rxjava-3.1.1](../instrumentation/rxjava/rxjava-3.1.1/library) | Context propagation | | ||
| | [Scala ForkJoinPool](https://www.scala-lang.org/api/2.12.0/scala/concurrent/forkjoin/package$$ForkJoinPool$.html) | 2.8+ | N/A | Context propagation | | ||
| | [Servlet](https://javaee.github.io/javaee-spec/javadocs/javax/servlet/package-summary.html) | 2.2+ | [opentelemetry-servlet-3.0](../instrumentation/servlet/servlet-3.0/library) | [HTTP Server Spans], [HTTP Server Metrics] | | ||
| | [SOFARPC](https://github.com/sofastack/sofa-rpc/) | 5.4.0+ | [opentelemetry-sofa-rpc-5.4](../instrumentation/sofa-rpc-5.4/library-autoconfigure) | [RPC Client Spans], [RPC Server Spans] | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| | [SOFARPC](https://github.com/sofastack/sofa-rpc/) | 5.4.0+ | [opentelemetry-sofa-rpc-5.4](../instrumentation/sofa-rpc-5.4/library-autoconfigure) | [RPC Client Spans], [RPC Server Spans] | | |
| | [SOFARPC](https://github.com/sofastack/sofa-rpc/) | 5.4+ | [opentelemetry-sofa-rpc-5.4](../instrumentation/sofa-rpc-5.4/library-autoconfigure) | [RPC Client Spans], [RPC Client Metrics], [RPC Server Spans], [RPC Server Metrics] | |
| target: ':instrumentation:sofa-rpc-5.4:javaagent' | ||
| - type: gradle | ||
| path: ./ | ||
| target: ':instrumentation:sofa-rpc-5.4:library-autoconfigure' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name autoconfigure here doesn't follow the normal pattern. Seems like it should just be library ? I see that this is also the case in the dubbo module, which is maybe where you copied from, but I'm not sure it's correct there either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
library-autoconfigure is used by library instrumentations that are automatically enabled when the library instrumentation jar is added to the project as opposed to library instrumentations where user has to write code to enable the instrumentation. Typically the library-autoconfigure use some sort of spi that is automatically picked up by the instrumented framework. Often it makes sense for instrumentation to provide both library and library-autoconfigure modules (for example see aws2.2 instrumentation) since library-autoconfigure instrumentations can't often be configured.
| } | ||
|
|
||
| // A type instrumentation is needed to trigger resource injection. | ||
| public static class ResourceInjectingTypeInstrumentation implements TypeInstrumentation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason not to put this in a separate file? we don't typically include instrumentations in the InstrumentationModule itself
| String errorMsg = response.getErrorMsg(); | ||
| if (errorMsg != null) { | ||
| return new SofaRpcException( | ||
| com.alipay.sofa.rpc.core.exception.RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is having the FQCN useful in this case or could we import?
| com.alipay.sofa.rpc.core.exception.RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg); | |
| RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg); |
| @BeforeAll | ||
| static void setUp() {} | ||
|
|
||
| @AfterAll | ||
| static void tearDown() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @BeforeAll | |
| static void setUp() {} | |
| @AfterAll | |
| static void tearDown() {} |
| return consumer; | ||
| } | ||
|
|
||
| ConsumerConfig<GenericService> configureGenericClient(int port) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like it is unused?
| "io.opentelemetry.instrumentation.sofarpc.v5_4.api.HelloService/hello") | ||
| .hasKind(SpanKind.SERVER) | ||
| .hasParent(trace.getSpan(1)) | ||
| .hasAttributesSatisfying( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A handful of the server spans in this test don't use the exactly flavor of this assertion, is that intentional?
| .hasAttributesSatisfying( | |
| .hasAttributesSatisfyingExactly( |
| @BeforeAll | ||
| static void setUp() {} | ||
|
|
||
| @AfterAll | ||
| static void tearDown() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @BeforeAll | |
| static void setUp() {} | |
| @AfterAll | |
| static void tearDown() {} |
| "io.opentelemetry.instrumentation.sofarpc.v5_4.api.MiddleService/hello") | ||
| .hasKind(SpanKind.SERVER) | ||
| .hasParent(trace.getSpan(1)) | ||
| .hasAttributesSatisfying( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as other test, is there a reason we can't use the strict version?
| .hasAttributesSatisfying( | |
| .hasAttributesSatisfyingExactly( |
| return; | ||
| } | ||
| Throwable error = exception != null ? exception : extractException(response); | ||
| instrumenter.end(context, SofaRpcRequest.create(request), response, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in some of our other similar instrumentations, we clear the virtual field after we grab it to avoid memory leaks. See jaxrs, and asynchttpclient and kafka as examples
| instrumenter.end(context, SofaRpcRequest.create(request), response, error); | |
| instrumenter.end(context, SofaRpcRequest.create(request), response, error); | |
| ASYNC_CONTEXT.set(request, null); // Clear to prevent memory leak |
This PR adds instrumentation support for SOFARPC framework, including:
Fixes #15496