Add async server instrumentation for Apache Thrift 0.13#18994
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds end-to-end async server support for Thrift 0.13 instrumentation by decorating nonblocking server protocols, propagating service metadata, and ending server spans at the correct lifecycle points (including async callbacks and one-way requests).
Changes:
- Introduces an async Thrift test handler and adds javaagent tests covering async server spans (success, many, one-way, error).
- Adds protocol decoration/caching via
VirtualFieldand new javaagent instrumentations forTBaseAsyncProcessorandAsyncProcessFunction. - Updates test utilities to assert server span names by handler class and validate
error.typefor stable RPC semconv.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| instrumentation/thrift-0.13/testing/src/main/java/io/opentelemetry/instrumentation/thrift/v0_13/CustomAsyncHandler.java | Adds async server handler used by new async-server tests. |
| instrumentation/thrift-0.13/testing/src/main/java/io/opentelemetry/instrumentation/thrift/v0_13/AbstractThriftTest.java | Refactors server helpers and expands server span assertions (class name + error.type). |
| instrumentation/thrift-0.13/library/src/main/java/io/opentelemetry/instrumentation/thrift/v0_13/internal/ServerInProtocolDecorator.java | Tracks one-way messages, allows late service-name injection, and de-dupes endSpan(). |
| instrumentation/thrift-0.13/library/src/main/java/io/opentelemetry/instrumentation/thrift/v0_13/internal/AsyncMethodCallbackUtil.java | Adds callback wrapper for async server flows to end spans and restore context. |
| instrumentation/thrift-0.13/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/thrift/v0_13/ThriftTest.java | Adds javaagent tests validating async server instrumentation behavior. |
| instrumentation/thrift-0.13/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/thrift/v0_13/ThriftTBaseAsyncProcessorInstrumentation.java | Sets service name for async server spans and handles one-way/sync-exception end conditions. |
| instrumentation/thrift-0.13/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/thrift/v0_13/ThriftSingletons.java | Adds protocol decorator caching to ensure consistent decorator instances per protocol. |
| instrumentation/thrift-0.13/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/thrift/v0_13/ThriftInstrumentationModule.java | Registers new async-server instrumentations. |
| instrumentation/thrift-0.13/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/thrift/v0_13/ThriftFrameBufferInstrumentation.java | Ensures getInputProtocol/getOutputProtocol return decorated protocols. |
| instrumentation/thrift-0.13/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/thrift/v0_13/ThriftAsyncProcessFunctionInstrumentation.java | Wraps result handler callbacks to end spans for async server workflows. |
laurit
approved these changes
Jun 19, 2026
Contributor
|
Thank you for your contribution @YaoYingLong! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously the Thrift 0.13 instrumentation covered async clients and nonblocking sync server processing, but async server handlers using
CustomService.AsyncProcessorwere notcovered as a server-side async workflow.
This PR adds instrumentation for:
org.apache.thrift.TBaseAsyncProcessor#processorg.apache.thrift.AsyncProcessFunction#getResultHandlerThe test fixture now separates nonblocking sync server startup from true async server startup and adds a
CustomAsyncHandlerfor async server test coverage.