open-telemetry / open-telemetry/opentelemetry-python-contrib
GRPC client_interceptor does not allow the user to cancel streamed responses
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Environment
Python 3.9
opentelemetry-sdk 1.20.0
opentelemetry-instrumentation 0.41b0
opentelemetry-instrumentation-grpc 0.41b0
grpcio = "==1.48.2 || ==1.49.1"
Steps to reproduce
import grpc
from opentelemetry.instrumentation.grpc import client_interceptor
chan = grpc.insecure_channel(MY_GRPC_SERVICE_ADDRESS)
chan = intercept_channel(chan, client_interceptor()))
response = chan.MyStreamRPC(....) # Server streamed RPC where the client sends a request to the server and gets a stream to read a sequence of messages back.
for idx, item in enumerate(response):
print(item)
if idx == 4:
response.cancel() # this works with standard grpc but throws an attribute error when the otel client_interceptor is added above
chan.close()
What is the expected behavior?
Being able to cancel the streamed response client side part-way
What is the actual behavior?
Throws an attribute error
Additional context
The interceptor seems to be modifying the return type for streamed rpc responses to be of type of standard generator
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the grpc client_interceptor entry point and reproduce the issue with the streamed RPC shown in the report. Inspect how the interceptor changes the streamed response, then verify that client-side cancellation works part-way through iteration without the AttributeError; add or update coverage if the existing test area is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100