Skip to content

Commit fa499f5

Browse files
diurnalistxrmx
andauthored
fix: grpc server ValueError when using unix sockets (#3394)
* fix: grpc server ValueError when using unix sockets with some grpc implementations the full .peer address is available for unix sockets, which includes the socket path. it seems that in versions of grpc prior to 1.53.0, the full path is returned by `context.peer()`. rather than change the dependency of the instrumentation, this updates it to more gracefully handle the case of the socket path being present or absent. Fixes #3393 * add changelog entry --------- Co-authored-by: Riccardo Magliocchetti <[email protected]>
1 parent 642d8c4 commit fa499f5

File tree

2 files changed

+3
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc

2 files changed

+3
-1
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- `opentelemetry-instrumentation-dbapi`, `opentelemetry-instrumentation-django`,
2626
`opentelemetry-instrumentation-sqlalchemy`: Fix sqlcomment for non string query and composable object.
2727
([#3113](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3113))
28+
- `opentelemetry-instrumentation-grpc` Fix error when using gprc versions <= 1.50.0 with unix sockets.
29+
([[#3393](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/3393)])
2830

2931
## Version 1.31.0/0.52b0 (2025-03-12)
3032

Diff for: instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _start_span(
239239
# * ipv4:127.0.0.1:57284
240240
# * ipv4:10.2.1.1:57284,127.0.0.1:57284
241241
#
242-
if context.peer() != "unix:":
242+
if not context.peer().startswith("unix:"):
243243
try:
244244
ip, port = (
245245
context.peer()

0 commit comments

Comments
 (0)