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

fix(grpc): Allow gRPC connections via Unix socket #1833

Merged
merged 8 commits into from
Jun 21, 2023

Commits on Jun 1, 2023

  1. fix(grpc): Allow gRPC connections via Unix socket

    This commit addresses issue open-telemetry#1832.
    
    The way `NET_PEER_IP` and `NET_PEER_PORT` are retrieved raises a `ValueError`
    when gRPC connections are handled via Unix sockets.
    
    ```py
    ip, port = (
        context.peer().split(",")[0].split(":", 1)[1].rsplit(":", 1)
    )
    ```
    
    When using an address like `unix:///tmp/grpc.sock` the value of `context.peer()` is `"unix:"`.
    Substituting that in the function above...
    
    ```py
    ip, port = "unix:".split(",")[0].split(":", 1)[1].rsplit(":", 1)
    ip, port = ["unix:"][0].split(":", 1)[1].rsplit(":", 1)
    ip, port = "unix:".split(":", 1)[1].rsplit(":", 1)
    ip, port = ["unix", ""][1].rsplit(":", 1)
    ip, port = "".rsplit(":", 1)
    ip, port = [""]  # ValueError
    ```
    
    I "addressed" the issue by guarding the retrieval of `net.peer.*` values under
    an `if` statement that checks if we are using a Unix socket.
    
    I extended the `server_interceptor` tests to run against TCP and Unix socket configurations.
    
    ---
    
    **Open Questions**
    
    - [ ] The socket tests will fail on Windows. Is there a way to annotate that?
    - [ ] Are there other span values we should be setting for the unix socket?
    mattoberle committed Jun 1, 2023
    Configuration menu
    Copy the full SHA
    f6eae8f View commit details
    Browse the repository at this point in the history
  2. Update CHANGELOG

    mattoberle committed Jun 1, 2023
    Configuration menu
    Copy the full SHA
    ec25dd5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    80a518f View commit details
    Browse the repository at this point in the history
  4. fix lint

    mattoberle committed Jun 1, 2023
    Configuration menu
    Copy the full SHA
    67beb25 View commit details
    Browse the repository at this point in the history

Commits on Jun 11, 2023

  1. Configuration menu
    Copy the full SHA
    e498b91 View commit details
    Browse the repository at this point in the history

Commits on Jun 16, 2023

  1. Configuration menu
    Copy the full SHA
    eb3779d View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2023

  1. Configuration menu
    Copy the full SHA
    cf329fe View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5e622b6 View commit details
    Browse the repository at this point in the history