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

[gRPC] Does not work with stream-to-stream gRPC requests #1966

Closed
psydok opened this issue Feb 12, 2024 · 2 comments · Fixed by #1967 or psydok/apm-agent-python#1
Closed

[gRPC] Does not work with stream-to-stream gRPC requests #1966

psydok opened this issue Feb 12, 2024 · 2 comments · Fixed by #1967 or psydok/apm-agent-python#1
Labels
agent-python community Issues opened by the community triage Issues awaiting triage

Comments

@psydok
Copy link
Contributor

psydok commented Feb 12, 2024

Describe the bug: I'm trying to add elastic apm for my gRPC service with unary-to-unary requests and stream-to-stream. Everything is fine with unary-to-unary requests. But stream-to-stream requests stop working.

The service stops accepting streaming requests altogether.

I think I saw somewhere that you wrote elastic does not support stream requests for gRPC. But I didn't think it would be a service-blocking problem.

Is there any way to get around it, to make custom processing for stream specifically?

To Reproduce

  1. Create a gRPC service with stream-to-stream and unary-to-unary endpoints.
class TestService(test_pb2_grpc.TestService):
    async def Streaming(self, request_iterator, context):
           count_of_request = 0
           async for request in request_iterator:
               count_of_request += 1
               yield test_pb2.Response(message=f"#{count_of_request } - ok")

    async def Unary(self, request, context):
           return test_pb2.Response(message="ok")
  1. Connect elastic apm.
elasticapm.instrument()

async def run_serve():
    apm_client = GRPCApmClient(
            {
                "SERVICE_NAME": "grpc-test",
                "SERVER_URL": "http://localhost:8200",
                "ENVIRONMENT": "test",
                "TRANSACTION_SAMPLE_RATE": 1.0,
                "SECRET_TOKEN": "qwerty",
            }
    )
    server = grpc.aio.server(
        futures.ThreadPoolExecutor(max_workers=10),
    )
    test_pb2_grpc.add_TestServicer_to_server(
        TestService(), server
    )
    server.add_insecure_port("[::]:50051")
    await server.start()
    await server.wait_for_termination()


if __name__ == "__main__":
    asyncio.run(run_serve())
  1. Make test requests
  2. Result: unary - works, stream - returns nothing, no logs in the service

Environment (please complete the following information)

  • OS: Linux
  • Python version: 3.10
  • Framework and version: gRPC 1.43.0
  • APM Server version: 6.20.0

Additional context

Add any other context about the problem here.

  • requirements.txt:

    Click to expand
    gcloud==0.18.3
    google-api-python-client==2.39.0
    grpcio-tools==1.43.0
    grpcio-health-checking==1.43.0
    setuptools==59.5.0
    elastic-apm
    sentry-sdk[grpcio]==1.31.0
    
@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Feb 12, 2024
psydok added a commit to psydok/apm-agent-python that referenced this issue Feb 12, 2024
@psydok
Copy link
Contributor Author

psydok commented Feb 12, 2024

I found out what the problem was, I think I managed to fix it. Can I create pull requests?

psydok added a commit to psydok/apm-agent-python that referenced this issue Feb 12, 2024
psydok added a commit to psydok/apm-agent-python that referenced this issue Feb 12, 2024
psydok added a commit to psydok/apm-agent-python that referenced this issue Feb 12, 2024
Fix gprc support with streaming requests (elastic#1966)
@basepi
Copy link
Contributor

basepi commented Feb 13, 2024

Reopening this so it can be closed by #1967

@basepi basepi reopened this Feb 13, 2024
basepi pushed a commit that referenced this issue Feb 13, 2024
…bled (#1967)

* Fix gprc support with streaming requests (#1966)

* Update version.py
xrmx pushed a commit that referenced this issue Mar 20, 2024
…bled (#1967)

* Fix gprc support with streaming requests (#1966)

* Update version.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
2 participants